[Driver] Fix compiler-rt lookup for x32

x86_64-linux-gnu and x86_64-linux-gnux32 use different ABIs and objects
built for one cannot be used for the other. In order to build and use
compiler-rt for x32, we need to treat x32 as a new arch there. This
updates the driver to search using the new arch name.

Reviewed By: glaubitz

Differential Revision: https://reviews.llvm.org/D100148
This commit is contained in:
Harald van Dijk 2021-07-15 20:52:25 +01:00
parent afc760ef35
commit 66ab8568c4
No known key found for this signature in database
GPG Key ID: 7D71BB318A5BD56D
2 changed files with 10 additions and 7 deletions

View File

@ -383,6 +383,9 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid())
return "i686";
if (TC.getArch() == llvm::Triple::x86_64 && Triple.isX32())
return "x32";
return llvm::Triple::getArchTypeName(TC.getArch());
}

View File

@ -284,28 +284,28 @@
// CHECK-MSAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.msan
// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
// RUN: -target i386-unknown-linux -fuse-ld=ld \
// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
// RUN: %clang -fsanitize=float-divide-by-zero %s -### -o %t.o 2>&1 \
// RUN: -target i386-unknown-linux -fuse-ld=ld \
// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
// RUN: -target i386-unknown-linux -fuse-ld=ld \
// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
// RUN: -resource-dir=%S/Inputs/resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
// RUN: -static-libsan \
// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
// CHECK-UBSAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.ubsan_standalone-i386.a" "--no-whole-archive"
// CHECK-UBSAN-LINUX: "--whole-archive" "{{.*}}libclang_rt.ubsan_standalone-x32.a" "--no-whole-archive"
// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
// CHECK-UBSAN-LINUX-NOT: "-lstdc++"