apple-sdk: add hack for C++ issues on x86_64-darwin (#397398)

This commit is contained in:
Emily
2025-04-24 12:46:32 +01:00
committed by GitHub
3 changed files with 18 additions and 4 deletions
@@ -35,7 +35,24 @@ self: super: {
| .main_library.reexported_libraries[].names[] |= select([.] | inside($libs) | not)
' > usr/lib/$libSystem~
# Convert libSystem back to tbd-v4 because not all tooling supports the JSON-based format yet.
llvm-readtapi -delete-input --filetype=tbd-v4 usr/lib/$libSystem~ -o usr/lib/$libSystem
llvm-readtapi --filetype=tbd-v4 usr/lib/$libSystem~ -o usr/lib/$libSystem
rm usr/lib/$libSystem~
done
# Strip weak C++ symbols to work around `libc++` leakage in system
# frameworks for now. These are only present on `x86_64-darwin`, so
# it should hopefully be harmless.
#
# TODO FIXME: This is kind of horrible.
while read -r -d "" stub; do
printf 'Stripping weak C++ symbols from %s\n' "$stub"
llvm-readtapi --filetype=tbd-v5 "$stub" \
| jq '
(.main_library, .libraries[]?).exported_symbols[]?.data.weak[]? |=
select(startswith("__Z") | not)
' > $stub~
llvm-readtapi --filetype=tbd-v4 $stub~ -o $stub
rm $stub~
done < <(find . -name '*.tbd' -print0)
'';
}
@@ -88,7 +88,6 @@
enabledModules ? [ ],
bzip2,
apple-sdk_14, # earlier SDKs cause linking issues on x86_64
callPackage,
}@inputs:
@@ -417,7 +416,6 @@ effectiveStdenv.mkDerivation {
]
++ optionals effectiveStdenv.hostPlatform.isDarwin [
bzip2
apple-sdk_14
]
++ optionals enableDocs [
doxygen
@@ -88,7 +88,6 @@ let
throw "Please add a qtPlatformCross entry for ${plat.config}";
# Per https://doc.qt.io/qt-5/macos.html#supported-versions: build SDK = 13.x or 14.x.
# SDK 13.x causes weird linking errors on x86_64-darwin, so use 14.x
darwinVersionInputs = [
apple-sdk_14
];