Skip to content

Commit

Permalink
configd: fix build with newer LLVM and bootstrap
Browse files Browse the repository at this point in the history
Clang 15 does not like the fake xpc headers. Use the real ones instead.
Doing this no longer causes an infinite recursion because xnu now
depends on python3Minimal, which does not include configd support.
  • Loading branch information
reckenrode committed May 29, 2023
1 parent 5611fa7 commit 15da7dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 50 deletions.
65 changes: 15 additions & 50 deletions pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
Original file line number Diff line number Diff line change
@@ -1,67 +1,32 @@
{ lib, stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security
{ lib, stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, xpc, ppp, IOKit, eap8021x, Security
, headersOnly ? false }:

appleDerivation' stdenv {
meta.broken = stdenv.cc.nativeLibc;

nativeBuildInputs = lib.optionals (!headersOnly) [ bootstrap_cmds ];
buildInputs = lib.optionals (!headersOnly) [ launchd ppp IOKit eap8021x ];
buildInputs = lib.optionals (!headersOnly) [ launchd ppp xpc IOKit eap8021x ];

propagatedBuildInputs = lib.optionals (!headersOnly) [ Security ];

patchPhase = lib.optionalString (!headersOnly) ''
HACK=$PWD/hack
mkdir $HACK
cp -r ${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/net $HACK
env = lib.optionalAttrs (!headersOnly) {
NIX_CFLAGS_COMPILE = toString [
"-ISystemConfiguration.framework/Headers"
"-I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders"
];
};

substituteInPlace SystemConfiguration.fproj/SCNetworkReachabilityInternal.h \
--replace '#include <xpc/xpc.h>' ""
patchPhase = lib.optionalString (!headersOnly) ''
substituteInPlace SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c \
--replace '#include <xpc/private.h>' ""
substituteInPlace SystemConfiguration.fproj/SCNetworkReachability.c \
--replace ''$'#define\tHAVE_VPN_STATUS' ""
substituteInPlace SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c \
--replace '#include <xpc/xpc.h>' '#include "fake_xpc.h"' \
--replace '#include <xpc/private.h>' "" \
# Our neutered CoreFoundation doesn't have this function, but I think we'll live...
substituteInPlace SystemConfiguration.fproj/SCNetworkConnectionPrivate.c \
--replace 'CFPreferencesAppValueIsForced(serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE' \
--replace 'CFPreferencesAppValueIsForced(userPrivate->serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE'
cat >SystemConfiguration.fproj/fake_xpc.h <<EOF
typedef void *xpc_type_t;
typedef void *xpc_object_t;
typedef void *xpc_connection_t;
xpc_type_t xpc_get_type(xpc_object_t object);
xpc_object_t xpc_dictionary_create(const char * const *keys, const xpc_object_t *values, size_t count);
char *xpc_copy_description(xpc_object_t object);
int64_t xpc_dictionary_get_int64(xpc_object_t xdict, const char *key);
uint64_t xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key);
void xpc_connection_set_event_handler(xpc_connection_t connection, void *handler);
extern const struct _xpc_type_s _xpc_type_error;
#define XPC_TYPE_ERROR (&_xpc_type_error)
extern const struct _xpc_type_s _xpc_type_dictionary;
#define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
extern const struct _xpc_type_s _xpc_type_array;
#define XPC_TYPE_ARRAY (&_xpc_type_array)
extern const struct _xpc_dictionary_s _xpc_error_connection_interrupted;
#define XPC_ERROR_CONNECTION_INTERRUPTED (&_xpc_error_connection_interrupted)
extern const struct _xpc_dictionary_s _xpc_error_connection_invalid;
#define XPC_ERROR_CONNECTION_INVALID (&_xpc_error_connection_invalid)
extern const char *const _xpc_error_key_description;
#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
#define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1)
EOF
'';

dontBuild = headersOnly;
Expand Down Expand Up @@ -177,9 +142,9 @@ appleDerivation' stdenv {
$CC -I. -Ihelper -Iderived -F. -c DHCP.c -o DHCP.o
$CC -I. -Ihelper -Iderived -F. -c moh.c -o moh.o
$CC -I. -Ihelper -Iderived -F. -c DeviceOnHold.c -o DeviceOnHold.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c LinkConfiguration.c -o LinkConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c LinkConfiguration.c -o LinkConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c dy_framework.c -o dy_framework.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c VLANConfiguration.c -o VLANConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c VLANConfiguration.c -o VLANConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c derived/configUser.c -o configUser.o
$CC -I. -Ihelper -Iderived -F. -c SCPreferencesPathKey.c -o SCPreferencesPathKey.o
$CC -I. -Ihelper -Iderived -I../dnsinfo -F. -c derived/shared_dns_infoUser.c -o shared_dns_infoUser.o
Expand All @@ -188,8 +153,8 @@ appleDerivation' stdenv {
$CC -I. -Ihelper -Iderived -F. -c SCNetworkProtocol.c -o SCNetworkProtocol.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkService.c -o SCNetworkService.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkSet.c -o SCNetworkSet.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c BondConfiguration.c -o BondConfiguration.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c BridgeConfiguration.c -o BridgeConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c BondConfiguration.c -o BondConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c BridgeConfiguration.c -o BridgeConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c helper/SCHelper_client.c -o SCHelper_client.o
$CC -I. -Ihelper -Iderived -F. -c SCPreferencesKeychainPrivate.c -o SCPreferencesKeychainPrivate.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkSignature.c -o SCNetworkSignature.o
Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/darwin/apple-source-releases/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
CommonCrypto = applePackage "CommonCrypto" "osx-10.12.6" "sha256-FLgODBrfv+XsGaAjddncYAm/BIJJYw6LcwX/z7ncKFM=" {};
configd = applePackage "configd" "osx-10.8.5" "sha256-6I3FWNjTgds5abEcZrD++s9b+P9a2+qUf8KFAb72DwI=" {
Security = applePackage "Security/boot.nix" "osx-10.9.5" "sha256-7qr0IamjCXCobIJ6V9KtvbMBkJDfRCy4C5eqpHJlQLI=" {};
inherit (pkgs.darwin.apple_sdk.libs) xpc;
};
copyfile = applePackage "copyfile" "osx-10.12.6" "sha256-uHqLFOIpXK+n0RHyOZzVsP2DDZcFDivKCnqHBaXvHns=" {};
Csu = applePackage "Csu" "osx-10.11.6" "sha256-h6a/sQMEVeFxKNWAPgKBXjWhyL2L2nvX9BQUMaTQ6sY=" {};
Expand Down Expand Up @@ -310,6 +311,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
configdHeaders = applePackage "configd" "osx-10.8.5" "sha256-6I3FWNjTgds5abEcZrD++s9b+P9a2+qUf8KFAb72DwI=" {
headersOnly = true;
Security = null;
xpc = null;
};
libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; };
hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; };
Expand Down

0 comments on commit 15da7dc

Please sign in to comment.