[flang-commits] [flang] 54dc764 - [Flang][Test] Add support to change the default target triple for tests
Usman Nadeem via flang-commits
flang-commits at lists.llvm.org
Mon Nov 28 16:02:59 PST 2022
Author: Usman Nadeem
Date: 2022-11-28T16:02:22-08:00
New Revision: 54dc764db7ff31057aa09451b63737a74da1cf65
URL: https://github.com/llvm/llvm-project/commit/54dc764db7ff31057aa09451b63737a74da1cf65
DIFF: https://github.com/llvm/llvm-project/commit/54dc764db7ff31057aa09451b63737a74da1cf65.diff
LOG: [Flang][Test] Add support to change the default target triple for tests
In this patch I added support to change the default target triple used
by flang tests using the cmake variable: FLANG_TEST_TARGET_TRIPLE.
This functionality is implemented using the LLVM_TARGET_TRIPLE_ENV
variable, so that must be defined as well.
An example use:
`-DLLVM_TARGET_TRIPLE_ENV="LLVM_TARGET_TRIPLE_ENV" -DFLANG_TEST_TARGET_TRIPLE="aarch64-linux-gnu"`
Differential revision: https://reviews.llvm.org/D138530
Change-Id: I38e4a46a65109d415a9b72c8a0bf8a955e937280
Added:
Modified:
flang/README.md
flang/test/CMakeLists.txt
flang/test/Unit/lit.cfg.py
flang/test/Unit/lit.site.cfg.py.in
flang/test/lit.cfg.py
flang/test/lit.site.cfg.py.in
Removed:
################################################################################
diff --git a/flang/README.md b/flang/README.md
index 5e664626d3e11..2c32528a73a6a 100644
--- a/flang/README.md
+++ b/flang/README.md
@@ -109,6 +109,12 @@ cmake \
ninja
```
+By default flang tests that do not specify an explicit `--target` flag use
+LLVM's default target triple. For these tests, if there is a need to test on a
+
diff erent triple by overriding the default, the following needs to be added to
+the cmake command above:
+`-DLLVM_TARGET_TRIPLE_ENV="<some string>" -DFLANG_TEST_TARGET_TRIPLE="<your triple>"`.
+
To run the flang tests on this build, execute the command in the "build"
directory:
```bash
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index d3b20caa35311..3252ff37bd21e 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -100,3 +100,11 @@ else()
PARAMS ${FLANG_TEST_PARAMS}
DEPENDS ${FLANG_TEST_DEPENDS})
endif()
+
+# To modify the default target triple for flang tests.
+if (DEFINED FLANG_TEST_TARGET_TRIPLE)
+ if (NOT DEFINED LLVM_TARGET_TRIPLE_ENV OR LLVM_TARGET_TRIPLE_ENV STREQUAL "")
+ message(FATAL_ERROR "LLVM_TARGET_TRIPLE_ENV must also be defined in order "
+ "to use FLANG_TEST_TARGET_TRIPLE.")
+ endif()
+endif()
diff --git a/flang/test/Unit/lit.cfg.py b/flang/test/Unit/lit.cfg.py
index b3103012de73e..406018c3f89c2 100644
--- a/flang/test/Unit/lit.cfg.py
+++ b/flang/test/Unit/lit.cfg.py
@@ -30,3 +30,8 @@
# Propagate PYTHON_EXECUTABLE into the environment
#config.environment['PYTHON_EXECUTABLE'] = sys.executable
+
+# To modify the default target triple for flang tests.
+if config.flang_test_triple:
+ config.target_triple = config.flang_test_triple
+ config.environment[config.llvm_target_triple_env] = config.flang_test_triple
diff --git a/flang/test/Unit/lit.site.cfg.py.in b/flang/test/Unit/lit.site.cfg.py.in
index 07d3ca344c97b..1c922df267e06 100644
--- a/flang/test/Unit/lit.site.cfg.py.in
+++ b/flang/test/Unit/lit.site.cfg.py.in
@@ -2,6 +2,7 @@
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_target_triple_env = "@LLVM_TARGET_TRIPLE_ENV@"
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
@@ -9,6 +10,7 @@ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.flang_obj_root = "@FLANG_BINARY_DIR@"
config.flang_src_root = "@FLANG_SOURCE_DIR@"
config.flang_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
+config.flang_test_triple = "@FLANG_TEST_TARGET_TRIPLE@"
config.flang_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.python_executable = "@Python3_EXECUTABLE@"
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 1d353a6e2dde2..bd1449e7ff0b7 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -45,6 +45,11 @@
for arch in config.targets_to_build.split():
config.available_features.add(arch.lower() + '-registered-target')
+# To modify the default target triple for flang tests.
+if config.flang_test_triple:
+ config.target_triple = config.flang_test_triple
+ config.environment[config.llvm_target_triple_env] = config.flang_test_triple
+
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index ce8e02a061f94..11fb00644fa92 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -5,6 +5,7 @@ import sys
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
+config.llvm_target_triple_env = "@LLVM_TARGET_TRIPLE_ENV@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
config.flang_obj_root = "@FLANG_BINARY_DIR@"
@@ -13,6 +14,7 @@ config.flang_tools_dir = lit_config.substitute("@FLANG_TOOLS_DIR@")
config.flang_intrinsic_modules_dir = "@FLANG_INTRINSIC_MODULES_DIR@"
config.flang_llvm_tools_dir = "@CMAKE_BINARY_DIR@/bin"
config.flang_lib_dir = "@CMAKE_BINARY_DIR@/lib"
+config.flang_test_triple = "@FLANG_TEST_TARGET_TRIPLE@"
config.flang_examples = @FLANG_BUILD_EXAMPLES@
config.python_executable = "@PYTHON_EXECUTABLE@"
config.flang_standalone_build = @FLANG_STANDALONE_BUILD@
More information about the flang-commits
mailing list