[clang] [HIP] use offload wrapper for non-device-only non-rdc (PR #132869)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 27 11:16:52 PDT 2025
================
@@ -9348,11 +9348,22 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
// Add the linker arguments to be forwarded by the wrapper.
CmdArgs.push_back(Args.MakeArgString(Twine("--linker-path=") +
LinkCommand->getExecutable()));
- for (const char *LinkArg : LinkCommand->getArguments())
- CmdArgs.push_back(LinkArg);
- addOffloadCompressArgs(Args, CmdArgs);
+ // We use action type to differentiate two use cases of the linker wrapper.
+ // TY_Image for normal linker wrapper work.
+ // TY_Object for HIP fno-gpu-rdc embedding device binary in a relocatable
+ // object.
+ assert(JA.getType() == types::TY_Object || JA.getType() == types::TY_Image);
+ if (JA.getType() == types::TY_Object) {
+ CmdArgs.append({"-o", Output.getFilename()});
+ for (auto Input : Inputs)
----------------
yxsamliu wrote:
That would include all the arguments from the command line and the generated arguments include the system libraries, whereas we only want to link the wrapper object to the original host object through "-r". It is simpler to create the command line options from scratch and cherry-pick any relevant options from Args if necessary. So far it is working.
https://github.com/llvm/llvm-project/pull/132869
More information about the cfe-commits
mailing list