Skip to content

Commit f487cf3

Browse files
vtjnashKristofferC
authored andcommitted
llvm: fix target triple (#30554)
broken by their move to cmake causing a switch away from the standard --host/--build autoconf fix #28046 (cherry picked from commit 041c214)
1 parent da5d637 commit f487cf3

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

deps/llvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ LLVM_CXXFLAGS += $(CXXFLAGS)
6565
LLVM_CPPFLAGS += $(CPPFLAGS)
6666
LLVM_LDFLAGS += $(LDFLAGS)
6767
LLVM_CMAKE += -DLLVM_TARGETS_TO_BUILD:STRING="$(LLVM_TARGETS)" -DCMAKE_BUILD_TYPE="$(LLVM_CMAKE_BUILDTYPE)"
68-
LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF
68+
LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_HOST_TRIPLE="$(or $(XC_HOST),$(BUILD_MACHINE))"
6969
ifeq ($(USE_POLLY_ACC),1)
7070
LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON
7171
endif

src/disasm.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,24 +628,23 @@ static void jl_dump_asm_internal(
628628
{
629629
// GC safe
630630
// Get the host information
631-
std::string TripleName = sys::getDefaultTargetTriple();
632-
Triple TheTriple(Triple::normalize(TripleName));
631+
Triple TheTriple(sys::getProcessTriple());
633632

634633
const auto &target = jl_get_llvm_disasm_target();
635634
const auto &cpu = target.first;
636635
const auto &features = target.second;
637636

638637
std::string err;
639-
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, err);
638+
const Target *TheTarget = TargetRegistry::lookupTarget(TheTriple.str(), err);
640639

641640
// Set up required helpers and streamer
642641
std::unique_ptr<MCStreamer> Streamer;
643642
SourceMgr SrcMgr;
644643

645-
std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TripleName),TripleName));
644+
std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TheTriple.str()), TheTriple.str()));
646645
assert(MAI && "Unable to create target asm info!");
647646

648-
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
647+
std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TheTriple.str()));
649648
assert(MRI && "Unable to create target register info!");
650649

651650
std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
@@ -659,16 +658,15 @@ static void jl_dump_asm_internal(
659658

660659
// Set up Subtarget and Disassembler
661660
std::unique_ptr<MCSubtargetInfo>
662-
STI(TheTarget->createMCSubtargetInfo(TripleName, cpu, features));
661+
STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
663662
std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
664663
if (!DisAsm) {
665-
jl_printf(JL_STDERR, "ERROR: no disassembler for target %s\n",
666-
TripleName.c_str());
664+
rstream << "ERROR: no disassembler for target " << TheTriple.str();
667665
return;
668666
}
669667
unsigned OutputAsmVariant = 0; // ATT or Intel-style assembly
670668

671-
if (strcmp(asm_variant, "intel")==0) {
669+
if (strcmp(asm_variant, "intel") == 0) {
672670
OutputAsmVariant = 1;
673671
}
674672
bool ShowEncoding = false;

0 commit comments

Comments
 (0)