Previously, for linking in amdgpu contexts, the --no-undefined was appended to the options passed to lld,
overriding any user-supplied options via "-Wl," or "-Xlinker". We now prepend --no-undefined so that
the user options are respected.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Remember to clang format.
clang/lib/Driver/ToolChains/AMDGPU.cpp | ||
---|---|---|
566–577 | A little more concisely. |
The -Wl and -Xlinker options are intended for the host linker and we intentionally do not pass them to the device linker.
If users want to pass options to the device linker, they need to use -Xoffload-linker.
There are multiple options affecting the handling of unresolved symbols. I think the proper way is to use --no-undefined as the default, which is always passed before those options from -Xoffload-linker so that the latter can override the former.
I believe the driver already passes -Xoffload-linker options to amdgpu::Linker::ConstructJob by Args. I think we probably only need to move all the default options (line 563-566) to 554 so that they can be overridden.
Yeah, the original problem was not being able to overload the defaults. This fundamentally is just because the -Wl options are being added in AddLinkerInputs before the defaults. Surprised I didn't catch that, thanks.
Is void amdgpu::Linker::ConstructJob() constructing a job for the host linker or the device linker? Or both?
The -Wl and -Xlinker options are intended for the host linker and we intentionally do not pass them to the device linker.
In the example I'm testing, both -Wl and -Xlinker result in a forwarded option to the lld invocation (as shown in the behavior of the lit tests). However, when testing with -Xoffload-linker , I just get the following:
warning: argument unused during compilation: '-Xoffload-linker --unresolved-symbols=ignore-all' [-Wunused-command-line-argument]
clang/test/Driver/amdgpu-toolchain-opencl.cl | ||
---|---|---|
34 | we need to make sure "--unresolved-symbols=ignore-all" is after "--no-undefined" . same as below |
A little more concisely.