[clang] 119a131 - [Driver] Pass -X to ld for riscv64-openbsd
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 18 14:59:29 PDT 2022
Author: Brad Smith
Date: 2022-06-18T17:58:58-04:00
New Revision: 119a13199a91abd43818412c34b9308db3c9270d
URL: https://github.com/llvm/llvm-project/commit/119a13199a91abd43818412c34b9308db3c9270d
DIFF: https://github.com/llvm/llvm-project/commit/119a13199a91abd43818412c34b9308db3c9270d.diff
LOG: [Driver] Pass -X to ld for riscv64-openbsd
Noticing D127826, add support for OpenBSD which uses lld on riscv64.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D128109
Added:
Modified:
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index 249a00ebb003a..92b91ed9d7f4e 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -156,6 +156,9 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
CmdArgs.push_back("-nopie");
+ if (ToolChain.getArch() == llvm::Triple::riscv64)
+ CmdArgs.push_back("-X");
+
if (Output.isFilename()) {
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index e3acd2c0569cc..d57234ae0134a 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -126,3 +126,8 @@
// RUN: FileCheck -check-prefix=UNWIND-TABLES %s
// UNWIND-TABLES: "-funwind-tables=2"
// NO-UNWIND-TABLES-NOT: "-funwind-tables=2"
+
+// Check that the -X flag is passed to the linker on riscv64
+// RUN: %clang --target=riscv64-unknown-openbsd -### %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-RISCV64-FLAGS %s
+// CHECK-RISCV64-FLAGS: "-X"
More information about the cfe-commits
mailing list