Skip to content

Commit ead486c

Browse files
authored
[ClangLinkerWrapper] Fix intermediate file naming for multi-arch compilation (#99325)
When save-temps is enabled and the given offload-archs differ only in target features with the same arch, the intermediate postlink.bc and postopt.bc files were getting overwritten. This fix, suffixes the intermediate file names with the complete TargetID. E.g. `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postlink.bc` and `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postopt.bc`
1 parent 093f0a4 commit ead486c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//===---------------------------------------------------------------------===//
1616

17+
#include "clang/Basic/TargetID.h"
1718
#include "clang/Basic/Version.h"
1819
#include "llvm/ADT/MapVector.h"
1920
#include "llvm/BinaryFormat/Magic.h"
@@ -668,7 +669,8 @@ std::unique_ptr<lto::LTO> createLTO(
668669
ModuleHook Hook = [](size_t, const Module &) { return true; }) {
669670
const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ));
670671
// We need to remove AMD's target-id from the processor if present.
671-
StringRef Arch = Args.getLastArgValue(OPT_arch_EQ).split(":").first;
672+
StringRef TargetID = Args.getLastArgValue(OPT_arch_EQ);
673+
StringRef Arch = clang::getProcessorFromTargetID(Triple, TargetID);
672674
lto::Config Conf;
673675
lto::ThinBackend Backend;
674676
// TODO: Handle index-only thin-LTO
@@ -712,7 +714,7 @@ std::unique_ptr<lto::LTO> createLTO(
712714

713715
if (SaveTemps) {
714716
std::string TempName = (sys::path::filename(ExecutableName) + "." +
715-
Triple.getTriple() + "." + Arch)
717+
Triple.getTriple() + "." + TargetID)
716718
.str();
717719
Conf.PostInternalizeModuleHook = [=](size_t Task, const Module &M) {
718720
std::string File =

0 commit comments

Comments
 (0)