Fix TranslateOpenMPTargetArgs dropping -mlinker-version (#186208)
TranslateOpenMPTargetArgs drops OPT_m_Group options, including
`-mlinker-version`, when the device triple differs from the host triple.
This can cause an assertion failure in MachO::getLinkerVersion when
running `offload-Xarch.c` and `openmp-offload-gpu.c` on Darwin as it
expects the linker version obtained via `-mlinker-version` and the
version cached during a previous invocation to match.
Fix this by preserving `-mlinker-version` when filtering OPT_m_Group
options.
The tests currently pass because 6758becb8f ("[ObjC] Support emission
of selector stubs calls instead of objc_msgSend."), which triggered the
assertion, was reverted. This fix is a prerequisite for reapplying that
commit.
This commit is contained in:
@@ -1762,10 +1762,15 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
|
||||
// matches the current toolchain triple. If it is not present
|
||||
// at all, target and host share a toolchain.
|
||||
if (A->getOption().matches(options::OPT_m_Group)) {
|
||||
// Pass code object version to device toolchain
|
||||
// to correctly set metadata in intermediate files.
|
||||
// Pass certain options to the device toolchain even when the triple
|
||||
// differs from the host: code object version must be passed to correctly
|
||||
// set metadata in intermediate files; linker version must be passed
|
||||
// because the Darwin toolchain requires the host and device linker
|
||||
// versions to match (the host version is cached in
|
||||
// MachO::getLinkerVersion).
|
||||
if (SameTripleAsHost ||
|
||||
A->getOption().matches(options::OPT_mcode_object_version_EQ))
|
||||
A->getOption().matches(options::OPT_mcode_object_version_EQ) ||
|
||||
A->getOption().matches(options::OPT_mlinker_version_EQ))
|
||||
DAL->append(A);
|
||||
else
|
||||
Modified = true;
|
||||
|
||||
Reference in New Issue
Block a user