Skip to content

Commit 2e591fb

Browse files
authored
[SYCL] Fix passing extra clang flags to lit tests (#4110)
`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`.
1 parent e239fdf commit 2e591fb

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function( add_common_options LIB_NAME)
147147
endif()
148148
endfunction(add_common_options)
149149

150-
if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS)
150+
if (LLVM_ENABLE_ASSERTIONS AND NOT SYCL_DISABLE_STL_ASSERTIONS AND NOT WIN32)
151151
if(SYCL_USE_LIBCXX)
152152
add_definitions(-D_LIBCPP_DEBUG=1)
153153
set(SYCL_CLANG_EXTRA_FLAGS "${SYCL_CLANG_EXTRA_FLAGS} -D_LIBCPP_DEBUG=1")

sycl/test/lit.cfg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# test_exec_root: The root path where tests should be run.
3636
config.test_exec_root = os.path.join(config.sycl_obj_root, 'test')
3737

38-
llvm_config.use_clang()
38+
llvm_config.use_clang(additional_flags=config.sycl_clang_extra_flags.split(' '))
3939

4040
# Propagate some variables from the host environment.
4141
llvm_config.with_system_environment(['PATH', 'OCL_ICD_FILENAMES', 'SYCL_DEVICE_ALLOWLIST', 'SYCL_CONFIG_FILE_NAME'])
@@ -62,8 +62,6 @@
6262
config.available_features.add('libcxx')
6363
llvm_config.with_system_environment('LD_LIBRARY_PATH')
6464
llvm_config.with_environment('LD_LIBRARY_PATH', config.sycl_libs_dir, append_path=True)
65-
llvm_config.with_system_environment('CFLAGS')
66-
llvm_config.with_environment('CFLAGS', config.sycl_clang_extra_flags)
6765

6866
elif platform.system() == "Windows":
6967
config.available_features.add('windows')

sycl/test/on-device/lit.cfg.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
# test_exec_root: The root path where tests should be run.
3636
config.test_exec_root = os.path.join(config.sycl_obj_root, 'test')
3737

38-
llvm_config.use_clang(use_installed=True)
38+
llvm_config.use_clang(use_installed=True,
39+
additional_flags=config.sycl_clang_extra_flags.split(' '))
3940

4041
# Propagate some variables from the host environment.
4142
llvm_config.with_system_environment(['PATH', 'OCL_ICD_FILENAMES', 'SYCL_DEVICE_ALLOWLIST', 'SYCL_CONFIG_FILE_NAME'])
@@ -57,8 +58,6 @@
5758
config.available_features.add('linux')
5859
llvm_config.with_system_environment(['LD_LIBRARY_PATH','LIBRARY_PATH','CPATH'])
5960
llvm_config.with_environment('LD_LIBRARY_PATH', config.sycl_libs_dir, append_path=True)
60-
llvm_config.with_system_environment('CFLAGS')
61-
llvm_config.with_environment('CFLAGS', config.sycl_clang_extra_flags)
6261

6362
elif platform.system() == "Windows":
6463
config.available_features.add('windows')

0 commit comments

Comments
 (0)