diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 12eaf1fb8b514..d0808d061c827 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -572,6 +572,14 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, } CmdArgs.push_back("-lm"); } + + // If we are linking for the device all symbols should be bound locally. The + // symbols are already protected which makes this redundant. This is only + // necessary to work around a problem in bfd. + // TODO: Remove this once 'lld' becomes the only linker for offloading. + 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);