From e7cf9a7c458ba188fba69f703c349c22bc42c6f4 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 20 Aug 2023 00:17:10 -0400 Subject: [PATCH] swift: update for cc-wrapper changes The Swift compiler derivation modifies the clang wrapper to use `exec -a "$0"` to allow it to use the same binary for both `clang` and `clang++`. The sed script it uses to do this fails after the cc-wrapper changes in 6f2b3ba027f0d74614ba1b21f15ea45b0beb0385 were merged. This is fixed by updating `makeClangWrapper` to work with the cc-wrapper changes by having Bash invoke a simple script that uses `exec -a "$0"` to set the required name for clang. This fixes the staging-next build failures with Swift on Darwin and Linux. https://github.com/NixOS/nixpkgs/pull/248496#issuecomment-1676831102 --- pkgs/development/compilers/swift/compiler/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index 821d61229d8d..30fb18db8fd2 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -2,6 +2,7 @@ , stdenv , callPackage , cmake +, bash , coreutils , gnugrep , perl @@ -133,7 +134,8 @@ let sed < '${clang}/bin/clang' > "$targetFile" \ -e 's|^\s*exec|exec -a "$0"|g' \ -e 's|^\[\[ "${clang.cc}/bin/clang" = \*++ ]]|[[ "$0" = *++ ]]|' \ - -e "s|${clang.cc}/bin/clang|$unwrappedClang|g" + -e "s|${clang.cc}/bin/clang|$unwrappedClang|g" \ + -e "s|^\(\s*\)\($unwrappedClang\) \"@\\\$responseFile\"|\1argv0=\$0\n\1${bash}/bin/bash -c \"exec -a '\$argv0' \2 '@\$responseFile'\"|" chmod a+x "$targetFile" '';