Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate compiler flags down to libcu++ LIT tests #2420

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libcudacxx/test/libcudacxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ else() # NOT LIBCUDACXX_TEST_WITH_NVRTC
set(LIBCUDACXX_FORCE_INCLUDE "-include ${libcudacxx_SOURCE_DIR}/test/libcudacxx/force_include.h")
set(LIBCUDACXX_CUDA_COMPILER "${CMAKE_CUDA_COMPILER}")
set(LIBCUDACXX_CUDA_TEST_WITH_NVRTC "False")
set(LIBCUDACXX_TEST_COMPILER_FLAGS "-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE")
set(LIBCUDACXX_TEST_COMPILER_FLAGS "${CMAKE_CUDA_FLAGS} -DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE")
set(LIBCUDACXX_TEST_LINKER_FLAGS "${CMAKE_CUDA_FLAGS}")
endif()

if (NOT MSVC AND NOT ${CMAKE_CUDA_COMPILER_ID} STREQUAL "Clang")
Expand Down
1 change: 1 addition & 0 deletions libcudacxx/test/libcudacxx/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ config.test_compiler_flags = "@LIBCUDACXX_TEST_COMPILER_FLAGS@"

config.compute_archs = "@LIBCUDACXX_COMPUTE_ARCHS_STRING@"
config.nvcc_host_compiler = "@CMAKE_CUDA_HOST_COMPILER@"
config.cuda_path = "@CMAKE_CUDA_COMPILER_TOOLKIT_ROOT@"

config.executor = "@LIBCUDACXX_EXECUTOR@"
config.llvm_unwinder = False
Expand Down
8 changes: 7 additions & 1 deletion libcudacxx/test/utils/libcudacxx/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, path, first_arg,
verify_flags=None, use_verify=False,
modules_flags=None, use_modules=False,
use_ccache=False, use_warnings=False, compile_env=None,
cxx_type=None, cxx_version=None):
cxx_type=None, cxx_version=None, cuda_path=None):
self.source_lang = 'c++'
self.path = path
self.first_arg = first_arg or ''
Expand All @@ -48,6 +48,7 @@ def __init__(self, path, first_arg,
self.compile_env = None
self.type = cxx_type
self.version = cxx_version
self.cuda_path = cuda_path
if self.type is None or self.version is None:
self._initTypeAndVersion()

Expand Down Expand Up @@ -225,6 +226,8 @@ def _basicCmd(self, source_files, out, mode=CM_Default, flags=[],
cmd += ['-o', out]
if input_is_cxx:
cmd += ['-x', self.source_lang]
if self.type == "clang" and self.source_lang == 'cu' and self.cuda_path is not None:
cmd += ['--cuda-path=' + self.cuda_path]
if isinstance(source_files, list):
cmd += source_files
elif isinstance(source_files, str):
Expand Down Expand Up @@ -395,6 +398,9 @@ def hasCompileFlag(self, flag):
# exit code. -Werror is supported on all known non-nvcc compiler types.
if self.type is not None and self.type != 'nvcc' and self.type != 'msvc':
flags += ['-Werror', '-fsyntax-only']
if self.type == 'clang' and self.source_lang == 'cu':
flags += ['-Wno-unused-command-line-argument']

empty_cpp = os.path.join(os.path.dirname(os.path.abspath(__file__)), "empty.cpp")
cmd, out, err, rc = self.checkCompileFlag(empty_cpp, out=os.devnull, flags=flags)
if out.find('flag is not supported with the configured host compiler') != -1:
Expand Down
11 changes: 9 additions & 2 deletions libcudacxx/test/utils/libcudacxx/test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,15 @@ def configure_cxx(self):
if not cxx:
self.lit_config.fatal('must specify user parameter cxx_under_test '
'(e.g., --param=cxx_under_test=clang++)')
self.cxx = CXXCompiler(cxx, cxx_first_arg) if not self.cxx_is_clang_cl else \
self._configure_clang_cl(cxx)
if self.cxx_is_clang_cl:
self.cxx = self._configure_clang_cl(cxx)
else:
self.cxx = CXXCompiler(
cxx,
cxx_first_arg,
compile_flags=self.get_lit_conf("cmake_cxx_flags"),
cuda_path= self.get_lit_conf('cuda_path'),
)
cxx_type = self.cxx.type
if cxx_type is not None:
assert self.cxx.version is not None
Expand Down
Loading