Skip to content

Commit 8e20860

Browse files
jhuber6lamb-j
authored andcommitted
[HIP] Hack around CMake incorrectly parsing OpenMP support in HIP mode (llvm#164482)
Summary: The new driver uses an embedded clang job to handle the device compilation. This correctly returns the linker as being `ld.lld`. The CMake parser to detect things like OpenMP support in the linker will parse the output of `-v` for the linker job. If the user is also using LLD for their linker, it will think this job is the linker and then fail as it does not see the required libraries. For these special HIP compilations, just print the linker wrapper invocation and nothing else. This will still show users the steps used to generate the binary but it will hack around this issue.
1 parent ea371ec commit 8e20860

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9263,6 +9263,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
92639263
};
92649264
auto ShouldForward = [&](const llvm::DenseSet<unsigned> &Set, Arg *A,
92659265
const ToolChain &TC) {
9266+
// CMake hack to avoid printing verbose informatoin for HIP non-RDC mode.
9267+
if (A->getOption().matches(OPT_v) && JA.getType() == types::TY_Object)
9268+
return false;
92669269
return (Set.contains(A->getOption().getID()) ||
92679270
(A->getOption().getGroup().isValid() &&
92689271
Set.contains(A->getOption().getGroup().getID()))) &&
@@ -9360,7 +9363,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
93609363

93619364
CmdArgs.push_back(
93629365
Args.MakeArgString("--host-triple=" + getToolChain().getTripleString()));
9363-
if (Args.hasArg(options::OPT_v))
9366+
9367+
// CMake hack, suppress passing verbose arguments for the special-case HIP
9368+
// non-RDC mode compilation. This confuses default CMake implicit linker
9369+
// argument parsing when the language is set to HIP and the system linker is
9370+
// also `ld.lld`.
9371+
if (Args.hasArg(options::OPT_v) && JA.getType() != types::TY_Object)
93649372
CmdArgs.push_back("--wrapper-verbose");
93659373
if (Arg *A = Args.getLastArg(options::OPT_cuda_path_EQ))
93669374
CmdArgs.push_back(

0 commit comments

Comments
 (0)