diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-06-17 03:19:08 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-06-17 03:19:08 +0000 |
commit | fc7f3b7514147cb6fc0ea67a5b0ee61e59d1ef6e (patch) | |
tree | 02d849c2b42c9f3203ad764d16d71dd3e1e1a5eb /llvm/lib/Support/Windows | |
parent | 9e19d790a683e30b6ae7319b0bc6fb296730cbc5 (diff) | |
download | bcm5719-llvm-fc7f3b7514147cb6fc0ea67a5b0ee61e59d1ef6e.tar.gz bcm5719-llvm-fc7f3b7514147cb6fc0ea67a5b0ee61e59d1ef6e.zip |
[CMake] Introduce LLVM_TARGET_TRIPLE_ENV as an option to override LLVM_DEFAULT_TARGET_TRIPLE at runtime.
No behavior is changed if LLVM_TARGET_TRIPLE_ENV is blank or undefined.
If LLVM_TARGET_TRIPLE_ENV is "TEST_TARGET_TRIPLE" and $TEST_TARGET_TRIPLE is not blank,
llvm::sys::getDefaultTargetTriple() returns $TEST_TARGET_TRIPLE.
Lit resets config.target_triple and config.environment[LLVM_TARGET_TRIPLE_ENV] to change the default target.
Without changing LLVM_DEFAULT_TARGET_TRIPLE nor rebuilding, lit can be run;
TEST_TARGET_TRIPLE=i686-pc-win32 bin/llvm-lit -sv path/to/test/
TEST_TARGET_TRIPLE=i686-pc-win32 ninja check-clang-tools
Differential Revision: https://reviews.llvm.org/D33662
llvm-svn: 305632
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/Host.inc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Support/Windows/Host.inc b/llvm/lib/Support/Windows/Host.inc index fe89fe0aad8..7e196cf0ce1 100644 --- a/llvm/lib/Support/Windows/Host.inc +++ b/llvm/lib/Support/Windows/Host.inc @@ -18,5 +18,13 @@ using namespace llvm; std::string sys::getDefaultTargetTriple() { - return Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE); + const char *Triple = LLVM_DEFAULT_TARGET_TRIPLE; + + // Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV. +#if defined(LLVM_TARGET_TRIPLE_ENV) + if (const char *EnvTriple = std::getenv(LLVM_TARGET_TRIPLE_ENV)) + Triple = EnvTriple; +#endif + + return Triple::normalize(Triple); } |