[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker
Joseph Huber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 4 10:00:34 PST 2022
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.
This patch adds the '-Bsymbolic' flag when we perform linking for the
offloading device. We already pass '-fvisibility=protected' but this is
not properly handled when using the bfd linker as is described in
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic.
Previously this caused linker errors when creating the shared library.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119018
Files:
clang/lib/Driver/ToolChains/Gnu.cpp
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,11 @@
}
CmdArgs.push_back("-lm");
}
+
+ // If we are linking for the device all symbols should be bound locally.
+ if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+ CmdArgs.push_back("-Bsymbolic");
+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119018.406020.patch
Type: text/x-patch
Size: 547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220204/aced5f5c/attachment.bin>
More information about the cfe-commits
mailing list