From 041c21498df49d39d0447372705f9dec4bdd17e7 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 3 Jan 2019 13:12:50 -0500 Subject: [PATCH] llvm: fix target triple (#30554) broken by their move to cmake causing a switch away from the standard --host/--build autoconf fix #28046 --- deps/llvm.mk | 2 +- src/disasm.cpp | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/deps/llvm.mk b/deps/llvm.mk index c516b577f6269..ed3342f397bfd 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -66,7 +66,7 @@ LLVM_CXXFLAGS += $(CXXFLAGS) LLVM_CPPFLAGS += $(CPPFLAGS) LLVM_LDFLAGS += $(LDFLAGS) LLVM_CMAKE += -DLLVM_TARGETS_TO_BUILD:STRING="$(LLVM_TARGETS)" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="$(LLVM_EXPERIMENTAL_TARGETS)" -DCMAKE_BUILD_TYPE="$(LLVM_CMAKE_BUILDTYPE)" -LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF +LLVM_CMAKE += -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_HOST_TRIPLE="$(or $(XC_HOST),$(BUILD_MACHINE))" ifeq ($(USE_POLLY_ACC),1) LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON endif diff --git a/src/disasm.cpp b/src/disasm.cpp index 418643d56874c..27ba5b8aa093a 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -747,24 +747,23 @@ static void jl_dump_asm_internal( { // GC safe // Get the host information - std::string TripleName = sys::getDefaultTargetTriple(); - Triple TheTriple(Triple::normalize(TripleName)); + Triple TheTriple(sys::getProcessTriple()); const auto &target = jl_get_llvm_disasm_target(); const auto &cpu = target.first; const auto &features = target.second; std::string err; - const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, err); + const Target *TheTarget = TargetRegistry::lookupTarget(TheTriple.str(), err); // Set up required helpers and streamer std::unique_ptr Streamer; SourceMgr SrcMgr; - std::unique_ptr MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TripleName),TripleName)); + std::unique_ptr MAI(TheTarget->createMCAsmInfo(*TheTarget->createMCRegInfo(TheTriple.str()), TheTriple.str())); assert(MAI && "Unable to create target asm info!"); - std::unique_ptr MRI(TheTarget->createMCRegInfo(TripleName)); + std::unique_ptr MRI(TheTarget->createMCRegInfo(TheTriple.str())); assert(MRI && "Unable to create target register info!"); std::unique_ptr MOFI(new MCObjectFileInfo()); @@ -773,16 +772,15 @@ static void jl_dump_asm_internal( // Set up Subtarget and Disassembler std::unique_ptr - STI(TheTarget->createMCSubtargetInfo(TripleName, cpu, features)); + STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features)); std::unique_ptr DisAsm(TheTarget->createMCDisassembler(*STI, Ctx)); if (!DisAsm) { - jl_printf(JL_STDERR, "ERROR: no disassembler for target %s\n", - TripleName.c_str()); + rstream << "ERROR: no disassembler for target " << TheTriple.str(); return; } unsigned OutputAsmVariant = 0; // ATT or Intel-style assembly - if (strcmp(asm_variant, "intel")==0) { + if (strcmp(asm_variant, "intel") == 0) { OutputAsmVariant = 1; } bool ShowEncoding = false;