diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -36,6 +36,8 @@ "C compiler to use for testing OpenMP runtime libraries.") set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "C++ compiler to use for testing OpenMP runtime libraries.") + set(OPENMP_TEST_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING + "FORTRAN compiler to use for testing OpenMP runtime libraries.") set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.") set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") @@ -54,6 +56,11 @@ set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe) endif() + find_program(OPENMP_TEST_Fortran_COMPILER flang-new PATHS LLVM_RUNTIME_OUTPUT_INTDIR) + if (NOT OPENMP_TEST_Fortran_COMPILER) + unset(OPENMP_TEST_Fortran_COMPILER CACHE) + endif() + # If not standalone, set CMAKE_CXX_STANDARD but don't set the global cache value, # only set it locally for OpenMP. set(CMAKE_CXX_STANDARD 17) diff --git a/openmp/README.rst b/openmp/README.rst --- a/openmp/README.rst +++ b/openmp/README.rst @@ -119,6 +119,10 @@ Compiler to use for testing. Defaults to the compiler that was also used for building. +**OPENMP_TEST_Fortran_COMPILER** = ``${CMAKE_Fortran_COMPILER}`` + Compiler to use for testing. Defaults to the compiler that was also used for + building. Will default to flang if build is in-tree. + **OPENMP_LLVM_TOOLS_DIR** = ``/path/to/built/llvm/tools`` Additional path to search for LLVM tools needed by tests. @@ -165,12 +169,6 @@ **LIBOMP_FORTRAN_MODULES** = ``OFF|ON`` Create the Fortran modules (requires Fortran compiler). - .. note:: - - If libomptarget is built in-tree with both flang and openmp in - `LLVM_ENABLE_PROJECTS`, flang will be used for Fortran offloading - tests. - macOS* Fat Libraries """""""""""""""""""" On macOS* machines, it is possible to build universal (or fat) libraries which diff --git a/openmp/libomptarget/test/CMakeLists.txt b/openmp/libomptarget/test/CMakeLists.txt --- a/openmp/libomptarget/test/CMakeLists.txt +++ b/openmp/libomptarget/test/CMakeLists.txt @@ -33,13 +33,10 @@ configure_file(lit.site.cfg.in ${CURRENT_TARGET}/lit.site.cfg @ONLY) endforeach() -if ("flang" IN_LIST LLVM_ENABLE_PROJECTS) - SET(FORTRAN_TEST_DEPS flang-new) -endif() add_openmp_testsuite(check-libomptarget "Running libomptarget tests" ${LIBOMPTARGET_LIT_TESTSUITES} EXCLUDE_FROM_CHECK_ALL - DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS} ${FORTRAN_TEST_DEPS} + DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS} ARGS ${LIBOMPTARGET_LIT_ARG_LIST}) diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg --- a/openmp/libomptarget/test/lit.cfg +++ b/openmp/libomptarget/test/lit.cfg @@ -4,10 +4,6 @@ import os import lit.formats -from lit.llvm import llvm_config -from lit.llvm.subst import ToolSubst -from lit.llvm.subst import FindTool - # Tell pylint that we know config and lit_config exist somewhere. if 'PYLINT_IMPORT' in os.environ: config = object() @@ -70,8 +66,6 @@ # test_exec_root: The root object directory where output is placed config.test_exec_root = config.libomptarget_obj_root -tools = [] - # test format config.test_format = lit.formats.ShTest() @@ -100,10 +94,6 @@ config.available_features.add(config.libomptarget_current_target) -if 'flang' in config.llvm_enabled_projects: - config.available_features.add('flang') - tools.append(ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal')) - if config.libomptarget_has_libc: config.available_features.add('libc') @@ -320,6 +310,11 @@ config.substitutions.append(("%clangxx", config.test_cxx_compiler)) config.substitutions.append(("%clang", config.test_c_compiler)) + +if config.test_fortran_compiler: + config.available_features.add('flang') + config.substitutions.append(("%flang", config.test_fortran_compiler)) + config.substitutions.append(("%openmp_flags", config.test_openmp_flags)) if config.libomptarget_current_target.startswith('nvptx') and config.cuda_path: config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path)) @@ -327,4 +322,3 @@ config.substitutions.append(("%cuda_flags", "")) config.substitutions.append(("%flags", config.test_flags)) config.substitutions.append(("%not", config.libomptarget_not)) -llvm_config.add_tool_substitutions(tools, config.bin_llvm_tools_dir) diff --git a/openmp/libomptarget/test/lit.site.cfg.in b/openmp/libomptarget/test/lit.site.cfg.in --- a/openmp/libomptarget/test/lit.site.cfg.in +++ b/openmp/libomptarget/test/lit.site.cfg.in @@ -3,6 +3,7 @@ config.bin_llvm_tools_dir = "@CMAKE_BINARY_DIR@/bin" config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@" config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@" +config.test_fortran_compiler="@OPENMP_TEST_Fortran_COMPILER@" config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@ config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@" config.test_extra_flags = "@OPENMP_TEST_FLAGS@" @@ -21,11 +22,7 @@ config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@" config.libomptarget_debug = @LIBOMPTARGET_DEBUG@ config.has_libomptarget_ompt = @LIBOMPTARGET_OMPT_SUPPORT@ -config.llvm_enabled_projects = "@LLVM_ENABLE_PROJECTS@".split(";") config.libomptarget_has_libc = @LIBOMPTARGET_GPU_LIBC_SUPPORT@ -import lit.llvm -lit.llvm.initialize(lit_config, config) - # Let the main config do the real work. lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")