Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm: fix target triple #30554

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))"
Copy link
Member

@nalimilan nalimilan May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates problems on Fedora armv7hl. Indeed, there BUILD_MACHINE=armv7hl-redhat-linux-gnueabi by default since that's what gcc -dumpmachine returns. Before this PR, LLVM used armv7l-unknown-linux-gnueabihf by default instead (as computed by deps/srccache/llvm-6.0.1/cmake/config.guess).

I don't really understand why Fedora arm uses gnueabi instead of gnueabihf, since it uses hard float (which is specified e.g. in CFLAGS via -mfloat-abi=hard), but it seems to be a conscious choice. I couldn't find official GCC/LLVM docs about what these mean. What I can see at least is that LLVM's config.guess script branches on __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null | grep -q __ARM_PCS_VFP to decide whether to return gnueabi or gnueabihf. I guess we should do the same to make this more reliable? EDIT: or just avoid passing -DLLVM_HOST_TRIPLE when XC_HOST is unset.

ifeq ($(USE_POLLY_ACC),1)
LLVM_CMAKE += -DPOLLY_ENABLE_GPGPU_CODEGEN=ON
endif
Expand Down
16 changes: 7 additions & 9 deletions src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MCStreamer> Streamer;
SourceMgr SrcMgr;

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

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

std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
Expand All @@ -773,16 +772,15 @@ static void jl_dump_asm_internal(

// Set up Subtarget and Disassembler
std::unique_ptr<MCSubtargetInfo>
STI(TheTarget->createMCSubtargetInfo(TripleName, cpu, features));
STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
std::unique_ptr<MCDisassembler> 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;
Expand Down