mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-17 12:50:04 +00:00
swiftPackages_ng.swift: include the stdlib in the toolchain
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
apple-sdk_14,
|
||||
apple-sdk_26,
|
||||
llvmPackages_upstream,
|
||||
patchelf,
|
||||
stdenv,
|
||||
stdlib,
|
||||
swift-corelibs-foundation,
|
||||
swift-corelibs-libdispatch,
|
||||
swift-driver,
|
||||
@@ -29,6 +31,11 @@ let
|
||||
swiftc.out
|
||||
swiftc.dev
|
||||
]
|
||||
++ lib.optionals (stdlib != null) [
|
||||
stdlib.dev
|
||||
stdlib.out
|
||||
swiftc.dev
|
||||
]
|
||||
++ lib.optionals (swift-driver != null) [
|
||||
swift-driver.out
|
||||
swift-driver.dev
|
||||
@@ -87,6 +94,10 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# Will effectively be `buildInputs` when swift is put in `nativeBuildInputs`.
|
||||
depsTargetTargetPropagated =
|
||||
lib.optionals stdenv.targetPlatform.isDarwin [ propagated-sdk ]
|
||||
++ lib.optionals (stdlib != null) [
|
||||
# Propagate the stdlib to make sure the linker wrapper will pick up the dynamic and static libraries.
|
||||
stdlib
|
||||
]
|
||||
++ lib.optionals (!stdenv.hostPlatform.isDarwin) (
|
||||
lib.optionals (swift-corelibs-libdispatch != null) [
|
||||
swift-corelibs-libdispatch-no-overlay.out
|
||||
@@ -152,6 +163,16 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
recordPropagatedDependencies
|
||||
|
||||
${lib.optionalString (stdlib != null) ''
|
||||
# Can’t use `replaceVars` because it needs to substitute $out.
|
||||
substitute ${./setup-hook.sh} "$out/nix-support/setup-hook" \
|
||||
--replace-fail @patchelf@ ${lib.escapeShellArg (lib.getExe patchelf)} \
|
||||
--replace-fail @objdump@ ${lib.escapeShellArg (lib.getExe' llvmPackages_upstream.llvm "llvm-objdump")} \
|
||||
--replace-fail @install_name_tool@ ${lib.escapeShellArg (lib.getExe' llvmPackages_upstream.llvm "llvm-install-name-tool")} \
|
||||
--replace-fail @stdlibPath@ ${lib.escapeShellArg stdlib.out} \
|
||||
--replace-fail @swiftPath@ "$out" \
|
||||
--replace-fail @swiftPlatform@ ${stdenv.hostPlatform.swift.platform}
|
||||
''}
|
||||
chmod -R u-w "$out/bin" "$out/lib" "$out/nix-support"
|
||||
|
||||
# Have to invoke manually because of `buildCommand`.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
fixSwiftRpathsIn() {
|
||||
local dir=$1
|
||||
|
||||
local swiftPath=@swiftPath@/lib
|
||||
local swiftPathForPlatform=@swiftPath@/lib/swift/@swiftPlatform@
|
||||
local stdlibPath=@stdlibPath@/lib
|
||||
|
||||
local f
|
||||
while IFS= read -d "" f; do
|
||||
if LC_ALL=C isMachO "$f"; then
|
||||
IFS= readarray -d $'\n' -t rpaths < <(@objdump@ --macho --rpaths "$f" | tail -n +2)
|
||||
for oldPath in "${rpaths[@]}"; do
|
||||
local newPath=${oldPath/$swiftPathForPlatform/$stdlibPath}
|
||||
newPath=${newPath/$swiftPath/$stdlibPath}
|
||||
if [ "$newPath" != "$oldPath" ]; then
|
||||
@install_name_tool@ "$f" -rpath "$oldPath" "$newPath"
|
||||
fi
|
||||
done
|
||||
elif isELF "$f"; then
|
||||
local oldRpaths=$(@patchelf@ --print-rpath "$f")
|
||||
local newRpaths=${oldRpaths/$swiftPathForPlatform/$stdlibPath}
|
||||
newRpaths=${newRpaths/$swiftPath/$stdlibPath}
|
||||
if [ "$newRpaths" != "$oldRpaths" ]; then
|
||||
@patchelf@ --set-rpath "$newRpaths" "$f"
|
||||
fi
|
||||
fi
|
||||
done < <(find "$dir" -type f -print0)
|
||||
}
|
||||
|
||||
fixupOutputHooks+=('fixSwiftRpathsIn $prefix')
|
||||
@@ -31,6 +31,7 @@ let
|
||||
);
|
||||
}
|
||||
// lib.optionalAttrs (bootstrapStage != 2) {
|
||||
stdlib = null; # Have the bootstrap compiler use its own build of the stdlib.
|
||||
swift-driver = prev.swift-driver.overrideAttrs (old: {
|
||||
pname = "early-${old.pname}";
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user