Allow host triple to be correctly overridden in CMake builds

The intended semantics mirror autoconf, where the user is able to
specify a host triple, but if it's left to the build system then
"config.guess" is invoked for the default.

This also renames the LLVM_HOSTTRIPLE define to LLVM_HOST_TRIPLE to
fit in with the style of the surrounding defines.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181112 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover 2013-05-04 07:36:23 +00:00
parent c1685b3a50
commit d66ad6c571
10 changed files with 14 additions and 13 deletions

View File

@ -1777,7 +1777,7 @@ AC_DEFINE_UNQUOTED(LLVM_MANDIR, "$LLVM_MANDIR",
[Installation directory for man pages])
AC_DEFINE_UNQUOTED(LLVM_CONFIGTIME, "$LLVM_CONFIGTIME",
[Time at which LLVM was configured])
AC_DEFINE_UNQUOTED(LLVM_HOSTTRIPLE, "$host",
AC_DEFINE_UNQUOTED(LLVM_HOST_TRIPLE, "$host",
[Host triple LLVM will be executed on])
AC_DEFINE_UNQUOTED(LLVM_DEFAULT_TARGET_TRIPLE, "$target",
[Target triple LLVM will generate code for by default])

View File

@ -340,12 +340,13 @@ if (CMAKE_COMPILER_IS_GNUCXX)
endif()
endif()
include(GetHostTriple)
get_host_triple(LLVM_HOST_TRIPLE)
# By default, we target the host, but this can be overridden at CMake
# invocation time.
set(LLVM_HOSTTRIPLE "${LLVM_HOST_TRIPLE}")
include(GetHostTriple)
get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING
"Host on which LLVM binaries will run")
# Determine the native architecture.
string(TOLOWER "${LLVM_TARGET_ARCH}" LLVM_NATIVE_ARCH)

2
configure vendored
View File

@ -22375,7 +22375,7 @@ _ACEOF
cat >>confdefs.h <<_ACEOF
#define LLVM_HOSTTRIPLE "$host"
#define LLVM_HOST_TRIPLE "$host"
_ACEOF

View File

@ -589,7 +589,7 @@
#cmakedefine01 LLVM_HAS_ATOMICS
/* Host triple LLVM will be executed on */
#cmakedefine LLVM_HOSTTRIPLE "${LLVM_HOSTTRIPLE}"
#cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}"
/* Installation directory for include files */
#cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"

View File

@ -594,7 +594,7 @@
#undef LLVM_HAS_ATOMICS
/* Host triple LLVM will be executed on */
#undef LLVM_HOSTTRIPLE
#undef LLVM_HOST_TRIPLE
/* Installation directory for include files */
#undef LLVM_INCLUDEDIR

View File

@ -41,7 +41,7 @@
#cmakedefine01 LLVM_HAS_ATOMICS
/* Host triple LLVM will be executed on */
#cmakedefine LLVM_HOSTTRIPLE "${LLVM_HOSTTRIPLE}"
#cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}"
/* Installation directory for include files */
#cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}"

View File

@ -41,7 +41,7 @@
#undef LLVM_HAS_ATOMICS
/* Host triple LLVM will be executed on */
#undef LLVM_HOSTTRIPLE
#undef LLVM_HOST_TRIPLE
/* Installation directory for include files */
#undef LLVM_INCLUDEDIR

View File

@ -613,7 +613,7 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features){
#endif
std::string sys::getProcessTriple() {
Triple PT(LLVM_HOSTTRIPLE);
Triple PT(LLVM_HOST_TRIPLE);
if (sizeof(void *) == 8 && PT.isArch32Bit())
PT = PT.get64BitArchVariant();

View File

@ -125,7 +125,7 @@ endif
lit.site.cfg: FORCE
@echo "Making LLVM 'lit.site.cfg' file..."
@$(ECHOPATH) s=@LLVM_HOSTTRIPLE@=$(HOST_TRIPLE)=g > lit.tmp
@$(ECHOPATH) s=@LLVM_HOST_TRIPLE@=$(HOST_TRIPLE)=g > lit.tmp
@$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
@$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g >> lit.tmp
@$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp

View File

@ -1,6 +1,6 @@
## Autogenerated by LLVM/Clang configuration.
# Do not edit!
config.host_triple = "@LLVM_HOSTTRIPLE@"
config.host_triple = "@LLVM_HOST_TRIPLE@"
config.target_triple = "@TARGET_TRIPLE@"
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"