Merge pull request #11965 from Bo98/swift-shim

shims: enforce usage of Swift-bundled Clang on Linux
This commit is contained in:
Bo Anderson 2021-09-15 12:26:08 +01:00 committed by GitHub
commit 1cfafde5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1 @@
../../super/swift

View File

@ -0,0 +1 @@
swift

View File

@ -11,5 +11,5 @@ if [[ -z "${SDKROOT}" && -n "${HOMEBREW_SDKROOT}" ]]; then
export SDKROOT=${HOMEBREW_SDKROOT}
fi
try_exec_non_system "swift" "$@"
safe_exec "/usr/bin/swift" "$@"
try_exec_non_system "${SHIM_FILE}" "$@"
safe_exec "/usr/bin/${SHIM_FILE}" "$@"

View File

@ -0,0 +1 @@
swift

View File

@ -79,6 +79,8 @@ class Cmd
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/#{Regexp.last_match(1)}"
when /\w\+\+(-\d+(\.\d)?)?$/
case ENV["HOMEBREW_CC"]
when "swift_clang"
"#{ENV["HOMEBREW_PREFIX"]}/opt/swift/libexec/bin/clang++"
when /clang/
"clang++"
when /llvm-gcc/
@ -91,6 +93,8 @@ class Cmd
# HOMEBREW_CC regardless of what name under which the tool was invoked.
if ENV["HOMEBREW_CC"] == "llvm_clang"
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/clang"
elsif ENV["HOMEBREW_CC"] == "swift_clang"
"#{ENV["HOMEBREW_PREFIX"]}/opt/swift/libexec/bin/clang"
else
ENV["HOMEBREW_CC"]
end

View File

@ -0,0 +1,15 @@
#!/bin/bash
# Ensure we use Swift's clang when performing Swift builds.
export CC="clang"
export CXX="clang++"
# swift_clang isn't a shim but is used to ensure the cc shim
# points to the compiler inside the swift keg
export HOMEBREW_CC="swift_clang"
export HOMEBREW_CXX="swift_clang++"
# HOMEBREW_OPT is set by extend/ENV/super.rb
# shellcheck disable=SC2154
exec "${HOMEBREW_OPT}/swift/bin/${0##*/}" "$@"

View File

@ -0,0 +1 @@
swift