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 6f2b3ba027 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
This commit is contained in:
Randy Eckenrode 2023-08-20 00:17:10 -04:00
parent f6a4c6f912
commit e7cf9a7c45
No known key found for this signature in database
GPG key ID: 64C1CD4EC2A600D9

View file

@ -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"
'';