Skip to content

Commit 64b7bce

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 6df0de5 commit 64b7bce

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
@@ -1653,6 +1653,8 @@ for host in "${ALL_HOSTS[@]}"; do
16531653
else
16541654
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
16551655
fi
1656+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
1657+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
16561658

16571659
if [[ "${NATIVE_SWIFT_TOOLS_PATH}" ]] ; then
16581660
SWIFTC_BIN="${NATIVE_SWIFT_TOOLS_PATH}/swiftc"
@@ -2720,6 +2722,8 @@ for host in "${ALL_HOSTS[@]}"; do
27202722
else
27212723
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
27222724
fi
2725+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
2726+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
27232727

27242728
if [[ "${NATIVE_SWIFT_TOOLS_PATH}" ]] ; then
27252729
SWIFTC_BIN="${NATIVE_SWIFT_TOOLS_PATH}/swiftc"
@@ -3067,6 +3071,20 @@ for host in "${ALL_HOSTS[@]}"; do
30673071
continue
30683072
fi
30693073

3074+
# Have to set the clang path or the driver will try to link with the wrong
3075+
# clang
3076+
if [[ "${NATIVE_CLANG_TOOLS_PATH}" ]] ; then
3077+
CLANG_BIN="${NATIVE_CLANG_TOOLS_PATH}"
3078+
if [[ ! -f "${CLANG_BIN}/clang" ]] ; then
3079+
echo "error: clang does not exist at the specified native tools path: ${CLANG_BIN}/clang"
3080+
exit 1
3081+
fi
3082+
else
3083+
CLANG_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
3084+
fi
3085+
export SWIFT_DRIVER_CLANG_EXEC="${CLANG_BIN}/clang"
3086+
export SWIFT_DRIVER_CLANGXX_EXEC="${CLANG_BIN}/clang++"
3087+
30703088
# Set the build options for this host
30713089
set_build_options_for_host $host
30723090

0 commit comments

Comments
 (0)