From db63e4b595d0f67abc37d9fb3889745d4f192bef Mon Sep 17 00:00:00 2001 From: npmiller Date: Thu, 15 Jul 2021 10:34:08 +0100 Subject: [PATCH] [SYCL] Fix passing extra clang flags to lit tests `CFLAGS` is a `make` environment variable so its contents were not used by the lit tests which call `clang` directly. Adding them to the `additional_flags` of `use_clang`, adds them to the `%clangxx` substitutions and ensures they are passed around everywhere. In addition these extra flags were only set on Linux because they were used for Linux C++ library assertions, but now they will be set on both Linux and Windows, however the Linux C++ library assertions defines will only be set on Linux. This also allows users to add custom clang parameters to the lit tests through the `SYCL_CLANG_EXTRA_FLAGS` CMake parameter. Which will be a requirement for the ROCm AMD lit tests as for AMD the target needs to be specified with `-mcpu`. --- sycl/CMakeLists.txt | 2 +- sycl/test/lit.cfg.py | 4 +--- sycl/test/on-device/lit.cfg.py | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 13af2ce042ffe..ecf2db32ec5a5 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -147,7 +147,7 @@ function( add_common_options LIB_NAME) endif() endfunction(add_common_options) -if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS) +if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS AND NOT WIN32) if(SYCL_USE_LIBCXX) add_definitions(-D_LIBCPP_DEBUG=1) set(SYCL_CLANG_EXTRA_FLAGS "${SYCL_CLANG_EXTRA_FLAGS} -D_LIBCPP_DEBUG=1") diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 70b09741b2df5..e2134956e9ceb 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -35,7 +35,7 @@ # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.sycl_obj_root, 'test') -llvm_config.use_clang() +llvm_config.use_clang(additional_flags=config.sycl_clang_extra_flags.split(' ')) # Propagate some variables from the host environment. llvm_config.with_system_environment(['PATH', 'OCL_ICD_FILENAMES', 'SYCL_DEVICE_ALLOWLIST', 'SYCL_CONFIG_FILE_NAME']) @@ -62,8 +62,6 @@ config.available_features.add('libcxx') llvm_config.with_system_environment('LD_LIBRARY_PATH') llvm_config.with_environment('LD_LIBRARY_PATH', config.sycl_libs_dir, append_path=True) - llvm_config.with_system_environment('CFLAGS') - llvm_config.with_environment('CFLAGS', config.sycl_clang_extra_flags) elif platform.system() == "Windows": config.available_features.add('windows') diff --git a/sycl/test/on-device/lit.cfg.py b/sycl/test/on-device/lit.cfg.py index 78a14ff78f846..f42d713ea57eb 100644 --- a/sycl/test/on-device/lit.cfg.py +++ b/sycl/test/on-device/lit.cfg.py @@ -35,7 +35,8 @@ # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.sycl_obj_root, 'test') -llvm_config.use_clang(use_installed=True) +llvm_config.use_clang(use_installed=True, + additional_flags=config.sycl_clang_extra_flags.split(' ')) # Propagate some variables from the host environment. llvm_config.with_system_environment(['PATH', 'OCL_ICD_FILENAMES', 'SYCL_DEVICE_ALLOWLIST', 'SYCL_CONFIG_FILE_NAME']) @@ -57,8 +58,6 @@ config.available_features.add('linux') llvm_config.with_system_environment(['LD_LIBRARY_PATH','LIBRARY_PATH','CPATH']) llvm_config.with_environment('LD_LIBRARY_PATH', config.sycl_libs_dir, append_path=True) - llvm_config.with_system_environment('CFLAGS') - llvm_config.with_environment('CFLAGS', config.sycl_clang_extra_flags) elif platform.system() == "Windows": config.available_features.add('windows')