[PATCH] D100148: [Driver] Fix compiler-rt lookup for x32
Harald van Dijk via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 8 15:46:51 PDT 2021
hvdijk created this revision.
hvdijk added a reviewer: glaubitz.
hvdijk added a project: clang.
Herald added subscribers: pengfei, dberris.
hvdijk requested review of this revision.
Herald added a subscriber: cfe-commits.
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.
This is a prerequisite for @glaubitz's D99988 <https://reviews.llvm.org/D99988> and is not useful on its own. It should be submitted together with that when that is ready.
The arch name used here is "x32" to match D99988 <https://reviews.llvm.org/D99988>. If that should turn out to not be specific enough, it could be changed to something like "x86_64_x32".
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100148
Files:
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/sanitizer-ld.c
Index: clang/test/Driver/sanitizer-ld.c
===================================================================
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -283,25 +283,25 @@
// 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: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
+// 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: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
+// 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: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -target x86_64-unknown-linux-gnux32 -fuse-ld=ld \
+// 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++"
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -383,6 +383,10 @@
if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid())
return "i686";
+ if (TC.getArch() == llvm::Triple::x86_64 &&
+ Triple.getEnvironment() == llvm::Triple::GNUX32)
+ return "x32";
+
return llvm::Triple::getArchTypeName(TC.getArch());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100148.336245.patch
Type: text/x-patch
Size: 2328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210408/b8d804dd/attachment.bin>
More information about the cfe-commits
mailing list