Skip to content

Commit d83ceb8

Browse files
committed
Use consistent clang through build
The just-built Swift driver was picking up the system clang, which would try to use the bfd linker instead of gold or lld. bfd doesn't like how Swift handles protected symbols and fails with the following error: ``` error: link command failed with exit code 1 (use -v to see invocation) /usr/bin/ld: /home/build-user/build/buildbot_linux/libdispatch-linux-x86_64/src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.o: relocation R_X86_64_PC32 against protected symbol `$s8Dispatch0A13WorkItemFlagsVSYAAMc' can not be used when making a shared object /usr/bin/ld: final link failed: bad value ``` This patch tells the Swift-Driver where it should find its clang, and makes it match the clang that is in use through the rest of the build.
1 parent a45e370 commit d83ceb8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

utils/build-script-impl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,8 @@ for host in "${ALL_HOSTS[@]}"; do
16651665
else
16661666
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
16671667
fi
1668+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
1669+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
16681670

16691671
if [[ "${NATIVE_SWIFT_TOOLS_PATH}" ]] ; then
16701672
SWIFTC_BIN="${NATIVE_SWIFT_TOOLS_PATH}/swiftc"
@@ -2734,6 +2736,8 @@ for host in "${ALL_HOSTS[@]}"; do
27342736
else
27352737
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
27362738
fi
2739+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
2740+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
27372741

27382742
if [[ "${NATIVE_SWIFT_TOOLS_PATH}" ]] ; then
27392743
SWIFTC_BIN="${NATIVE_SWIFT_TOOLS_PATH}/swiftc"
@@ -3081,6 +3085,20 @@ for host in "${ALL_HOSTS[@]}"; do
30813085
continue
30823086
fi
30833087

3088+
# Have to set the clang path or the driver will try to link with the wrong
3089+
# clang
3090+
if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
3091+
CLANG_BIN="${NATIVE_CLANG_TOOLS_PATH}"
3092+
if [[ ! -f "${CLANG_BIN}/clang" ]] ; then
3093+
echo "error: clang does not exist at the specified native tools path: ${CLANG_BIN}/clang"
3094+
exit 1
3095+
fi
3096+
else
3097+
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
3098+
fi
3099+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
3100+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
3101+
30843102
# Set the build options for this host
30853103
set_build_options_for_host $host
30863104

0 commit comments

Comments
 (0)