Skip to content

Commit

Permalink
darwin.xnu: use unwrapped clang for MIGCC
Browse files Browse the repository at this point in the history
the mig header build requires a 32 bit arch but the wrapped compiler
specifies `-arch 64-bit-arch` on the command line causing compile
failures. This was worked around for aarch64 by patching out the 32 bit
arch but that ignores the comment and the code saying that 32 bit arch
is required and thus will generate the wrong sizes for the structures in
the headers. Using the unwrapped clang mig can pass whatever arch it
desires.
  • Loading branch information
paparodeo committed Jul 10, 2024
1 parent 176a56c commit bae30f2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
--replace " -o 0" "" \
--replace '$SRC/$mig' '-I$DSTROOT/include $SRC/$mig' \
--replace '$SRC/servers/netname.defs' '-I$DSTROOT/include $SRC/servers/netname.defs' \
--replace '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR' \
--replace 'MACHINE_ARCH=armv7' 'MACHINE_ARCH=arm64' # this might break the comments saying 32-bit is required
--replace '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR'
patchShebangs .
'' + lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11") ''
Expand All @@ -72,11 +71,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
HOST_FLEX = "flex";
HOST_BISON = "bison";
HOST_GM4 = "m4";
# use unwrapped clang to generate headers because wrapper is not compatible with a 32 bit -arch.
# aarch64 should likely do this as well and remove the --replace MACHINE_ARCH above
MIGCC = if stdenv.isx86_64 && lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11"
then "${lib.getBin pkgsBuildBuild.stdenv.cc.cc}/bin/clang"
else "cc";
MIGCC = "${lib.getBin pkgsBuildBuild.stdenv.cc.cc}/bin/clang";
ARCHS = arch;
ARCH_CONFIGS = arch;

Expand Down

0 comments on commit bae30f2

Please sign in to comment.