llvm.org GIT mirror llvm / 8a86887
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 Sebastian Pop 7 years ago
14 changed file(s) with 59 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
14831483 [Installation directory for man pages])
14841484 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
14851485 [Time at which LLVM was configured])
1486 AC_DEFINE_UNQUOTED(LLVM_HOST_TRIPLE, "$host",
1487 [Host triple LLVM will run on])
14861488 AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
14871489 [Target triple LLVM will generate code for by default])
14881490
287287 check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
288288
289289 include(GetTargetTriple)
290 get_target_triple(LLVM_HOST_TRIPLE)
290291 get_target_triple(LLVM_DEFAULT_TARGET_TRIPLE)
291292
293 set(HOST_TRIPLE "${LLVM_HOST_TRIPLE}")
292294 set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
293295
294296 # Determine the native architecture.
295297 string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)
296298 if( LLVM_NATIVE_ARCH STREQUAL "host" )
299 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
297300 string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_DEFAULT_TARGET_TRIPLE})
298301 endif ()
299302
2091220912
2091320913
2091420914 cat >>confdefs.h <<_ACEOF
20915 #define LLVM_HOST_TRIPLE "$host"
20916 _ACEOF
20917
20918
20919 cat >>confdefs.h <<_ACEOF
2091520920 #define LLVM_DEFAULT_TARGET_TRIPLE "$target"
2091620921 _ACEOF
2091720922
559559 /* Has gcc/MSVC atomic intrinsics */
560560 #cmakedefine01 LLVM_HAS_ATOMICS
561561
562 /* Host triple LLVM will run on */
563 #cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}"
564
562565 /* Installation directory for include files */
563566 #cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"
564567
557557 /* Has gcc/MSVC atomic intrinsics */
558558 #undef LLVM_HAS_ATOMICS
559559
560 /* Host triple LLVM will run on */
561 #undef LLVM_HOST_TRIPLE
562
560563 /* Installation directory for include files */
561564 #undef LLVM_INCLUDEDIR
562565
3838
3939 /* Has gcc/MSVC atomic intrinsics */
4040 #cmakedefine01 LLVM_HAS_ATOMICS
41
42 /* Host triple LLVM will run on */
43 #cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}"
4144
4245 /* Installation directory for include files */
4346 #cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"
3838
3939 /* Has gcc/MSVC atomic intrinsics */
4040 #undef LLVM_HAS_ATOMICS
41
42 /* Host triple LLVM will run on */
43 #undef LLVM_HOST_TRIPLE
4144
4245 /* Installation directory for include files */
4346 #undef LLVM_INCLUDEDIR
3232 return !isLittleEndianHost();
3333 }
3434
35 /// getHostTriple() - Return the host where the compiler will be running.
36 ///
37 /// The host triple is a string in the format of:
38 /// CPU_TYPE-VENDOR-OPERATING_SYSTEM
39 /// or
40 /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
41 std::string getHostTriple();
42
3543 /// getDefaultTargetTriple() - Return the default target triple the compiler
3644 /// has been configured to produce code for.
3745 ///
13721372 << " Built " << __DATE__ << " (" << __TIME__ << ").\n"
13731373 #endif
13741374 << " Default target: " << sys::getDefaultTargetTriple() << '\n'
1375 << " Host: " << sys::getHostTriple() << '\n'
13751376 << " Host CPU: " << CPU << '\n';
13761377 }
13771378 void operator=(bool OptionWasSpecified) {
8383 }
8484
8585 const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) {
86 const Target *TheTarget = lookupTarget(sys::getDefaultTargetTriple(), Error);
86 const Target *TheTarget = lookupTarget(sys::getHostTriple(), Error);
8787
8888 if (TheTarget && !TheTarget->hasJIT()) {
8989 Error = "No JIT compatible target available for this host";
3434 return info.release;
3535 }
3636
37 std::string sys::getDefaultTargetTriple() {
38 StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE);
39 std::pair ArchSplit = TargetTripleString.split('-');
40
41 // Normalize the arch, since the target triple may not actually match the target.
37 std::string getTriple(StringRef &TripleString) {
38 std::pair ArchSplit = TripleString.split('-');
4239 std::string Arch = ArchSplit.first;
43
4440 std::string Triple(Arch);
4541 Triple += '-';
4642 Triple += ArchSplit.second;
6056
6157 return Triple;
6258 }
59
60 std::string sys::getDefaultTargetTriple() {
61 StringRef TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE);
62 return getTriple(TargetTripleString);
63 }
64
65 std::string sys::getHostTriple() {
66 StringRef HostTripleString(LLVM_HOST_TRIPLE);
67 return getTriple(HostTripleString);
68 }
1919 std::string sys::getDefaultTargetTriple() {
2020 return LLVM_DEFAULT_TARGET_TRIPLE;
2121 }
22
23 std::string sys::getHostTriple() {
24 return LLVM_HOST_TRIPLE;
25 }
13891389 [Installation directory for man pages])
13901390 AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
13911391 [Time at which LLVM was configured])
1392 AC_DEFINE_UNQUOTED(LLVM_HOST_TRIPLE, "$host",
1393 [Host triple LLVM will run on])
13921394 AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
13931395 [Target triple LLVM will generate code for by default])
13941396
88538853 shlibpath_var=LD_LIBRARY_PATH
88548854 ;;
88558855
8856 freebsd1*)
8856 freebsd1.*)
88578857 dynamic_linker=no
88588858 ;;
88598859
88768876 objformat=`/usr/bin/objformat`
88778877 else
88788878 case $host_os in
8879 freebsd[123]*) objformat=aout ;;
8879 freebsd[123].*) objformat=aout ;;
88808880 *) objformat=elf ;;
88818881 esac
88828882 fi
88948894 esac
88958895 shlibpath_var=LD_LIBRARY_PATH
88968896 case $host_os in
8897 freebsd2*)
8897 freebsd2.*)
88988898 shlibpath_overrides_runpath=yes
88998899 ;;
89008900 freebsd3.[01]* | freebsdelf3.[01]*)
1040810408 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1040910409 lt_status=$lt_dlunknown
1041010410 cat > conftest.$ac_ext <
10411 #line 10423 "configure"
10411 #line 10412 "configure"
1041210412 #include "confdefs.h"
1041310413
1041410414 #if HAVE_DLFCN_H
2081420814
2081520815 cat >>confdefs.h <<_ACEOF
2081620816 #define LLVM_CONFIGTIME "$LLVM_CONFIGTIME"
20817 _ACEOF
20818
20819
20820 cat >>confdefs.h <<_ACEOF
20821 #define LLVM_HOST_TRIPLE "$host"
2081720822 _ACEOF
2081820823
2081920824