This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Introduce LLVM_TARGET_TRIPLE_ENV as an option to override LLVM_DEFAULT_TARGET_TRIPLE at runtime.
ClosedPublic

Authored by chapuni on May 29 2017, 5:57 PM.

Details

Summary

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

Why I make the name of an environment variable configurable? Because...

  • Let this functionality configurable.
  • I'd not like to hear "Why $CLANG_TARGET is unavailable in spite of $LLVM_TARGET there"

In the future, I am planning to implement running triple matrix in Lit.
For example, running each test for each triple {i686|x86_64}-{mingw32|win32}.
Then, some commands, like FileCheck and commands with an explicit triple, aren't required to run iteratively.

Diff Detail

Repository
rL LLVM

Event Timeline

chapuni created this revision.May 29 2017, 5:57 PM
beanz accepted this revision.Jun 16 2017, 1:19 PM

LGTM

This revision is now accepted and ready to land.Jun 16 2017, 1:19 PM
This revision was automatically updated to reflect the committed changes.