================
@@ -574,6 +574,9 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, 
const ArgList &Args,
   if (Args.hasArg(OPT_embed_bitcode))
     CmdArgs.push_back("-Wl,--lto-emit-llvm");
 
+  if (Args.hasArg(OPT_allow_multiple_definition))
+    CmdArgs.push_back("-Wl,--allow-multiple-definition");
+
----------------
jhuber6 wrote:

Fixing it this way by default would degrade diagnostics for every user. The 
user should use this option as a work-around and we should find an intelligent 
way to correctly respect static linking semantics. This would fix other 
problems as well, like the need for `--extract=gfx1030` or similar.

Right now we just force `--whole-archive` behavior for the GPU portion because 
there is not an easy way to determine if a symbol is used from the host. For 
example, `device.a` contains a kernel, this kernel has no references in any 
device code, but it's used by the host. We would need some way to inform the 
linker that these symbols are needed.

The canonical way to do this would likely be through a linker script. We 
already have the `__llvm_offload_entry` section which contains string 
descriptions of every used device global. We could collect those into a linker 
script to mark all of them as needed so they would be extracted. At some point 
I had a prototype for this but gave up because there's no cross-platform way to 
do it thanks to the heavily proprietary nature of GPU linkers that aren't AMD.

https://github.com/llvm/llvm-project/pull/182282
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to