================
@@ -9909,9 +9909,15 @@ void LinkerWrapper::ConstructJob(Compilation &C, const
JobAction &JA,
}
// If the user explicitly requested it via `--offload-arch` we should
- // extract it from any static libraries if present.
- for (StringRef Arg : ToolChainArgs.getAllArgValues(OPT_offload_arch_EQ))
- CmdArgs.emplace_back(Args.MakeArgString("--should-extract=" + Arg));
+ // extract it from any static libraries if present. Use the arch names
+ // from getOffloadArchs so target-ID features are sorted to match the
+ // image labels and --no-offload-arch is applied.
+ if (ToolChainArgs.hasArg(OPT_offload_arch_EQ))
+ for (const BoundArch &BA :
+ C.getDriver().getOffloadArchs(C, ToolChainArgs, Kind, *TC))
----------------
srividya-sundaram wrote:
There isn't one to reuse. The toolchains don't store target IDs
([Compilation.h#L58-L62](https://github.com/llvm/llvm-project/blob/46de45e347aeec0c33d6b00fc328f945d69cbbb9/clang/include/clang/Driver/Compilation.h#L58-L62)),
and the bound arch only exists on device compile actions
([Clang.cpp#L9724-L9731](https://github.com/llvm/llvm-project/blob/46de45e347aeec0c33d6b00fc328f945d69cbbb9/clang/lib/Driver/ToolChains/Clang.cpp#L9724-L9731)).
A link-only build like clang `-fgpu-rdc --hip-link --offload-arch=gfx906
a.bundle.bc` has none, and that's the case `--should-extract` is for.
I've added a cache instead: `getOffloadArchs` now stores its result on
`Compilation` per (toolchain, offload kind), next to `TCArgs`
([Compilation.h#L101-L105](https://github.com/srividya-sundaram/llvm-project/blob/b1215f36e52315bce7f98ee1bb8286d5b7acf26d/clang/include/clang/Driver/Compilation.h#L101-L105),
[Driver.cpp#L4112-L4127](https://github.com/srividya-sundaram/llvm-project/blob/b1215f36e52315bce7f98ee1bb8286d5b7acf26d/clang/lib/Driver/Driver.cpp#L4112-L4127)).
The list is computed on the first call, usually when the device actions are
built, and the `linker wrapper` reuses it.
With `--offload-targets and --offload-arch=native`, this also runs
`amdgpu-arch` once and reports its errors once
([amdgpu-hip-system-arch.c#L36-L56](https://github.com/srividya-sundaram/llvm-project/blob/b1215f36e52315bce7f98ee1bb8286d5b7acf26d/clang/test/Driver/amdgpu-hip-system-arch.c#L36-L56)).
https://github.com/llvm/llvm-project/pull/232148
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits