From 8a86887ba3dcf59ddfd1d26bd2af1ac9c6bed76a Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Wed, 4 Jan 2012 19:47:22 +0000 Subject: use getHostTriple instead of getDefaultTargetTriple in getClosestTargetForJIT Get back getHostTriple. For JIT compilation, use the host triple instead of the default target: this fixes some JIT testcases that used to fail when the compiler has been configured as a cross compiler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147542 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 1 + lib/Support/TargetRegistry.cpp | 2 +- lib/Support/Unix/Host.inc | 18 ++++++++++++------ lib/Support/Windows/Host.inc | 4 ++++ 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'lib/Support') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index ce93449..9e8207b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -1373,6 +1373,7 @@ public: << " Built " << __DATE__ << " (" << __TIME__ << ").\n" #endif << " Default target: " << sys::getDefaultTargetTriple() << '\n' + << " Host: " << sys::getHostTriple() << '\n' << " Host CPU: " << CPU << '\n'; } void operator=(bool OptionWasSpecified) { diff --git a/lib/Support/TargetRegistry.cpp b/lib/Support/TargetRegistry.cpp index 53c8d84..7497bfe 100644 --- a/lib/Support/TargetRegistry.cpp +++ b/lib/Support/TargetRegistry.cpp @@ -84,7 +84,7 @@ void TargetRegistry::RegisterTarget(Target &T, } const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) { - const Target *TheTarget = lookupTarget(sys::getDefaultTargetTriple(), Error); + const Target *TheTarget = lookupTarget(sys::getHostTriple(), Error); if (TheTarget && !TheTarget->hasJIT()) { Error = "No JIT compatible target available for this host"; diff --git a/lib/Support/Unix/Host.inc b/lib/Support/Unix/Host.inc index 726e2fb..82f717f 100644 --- a/lib/Support/Unix/Host.inc +++ b/lib/Support/Unix/Host.inc @@ -35,13 +35,9 @@ static std::string getOSVersion() { return info.release; } -std::string sys::getDefaultTargetTriple() { - StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); - std::pair ArchSplit = TargetTripleString.split('-'); - - // Normalize the arch, since the target triple may not actually match the target. +std::string getTriple(StringRef &TripleString) { + std::pair ArchSplit = TripleString.split('-'); std::string Arch = ArchSplit.first; - std::string Triple(Arch); Triple += '-'; Triple += ArchSplit.second; @@ -61,3 +57,13 @@ std::string sys::getDefaultTargetTriple() { return Triple; } + +std::string sys::getDefaultTargetTriple() { + StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE); + return getTriple(TargetTripleString); +} + +std::string sys::getHostTriple() { + StringRef HostTripleString(LLVM_HOST_TRIPLE); + return getTriple(HostTripleString); +} diff --git a/lib/Support/Windows/Host.inc b/lib/Support/Windows/Host.inc index 2e6d6f1..cce8234 100644 --- a/lib/Support/Windows/Host.inc +++ b/lib/Support/Windows/Host.inc @@ -20,3 +20,7 @@ using namespace llvm; std::string sys::getDefaultTargetTriple() { return LLVM_DEFAULT_TARGET_TRIPLE; } + +std::string sys::getHostTriple() { + return LLVM_HOST_TRIPLE; +} -- cgit v1.1