Skip to content

Commit 3ae7054

Browse files
authored
Tweaks and fixes to clang build and test configs (#4832)
* Tweaks and fixes to clang build and test configs * Setup dependencies for check-clang. * Proprely adjust shlibdir for multi-configuraiton builds. * Move TAEF platform verification earlier to avoid issues on Linux. * Adjust TAEF suite config to handle build_mode specialization. * Remove another DXC_BUILD_ARCH that snuck in. * Add the intermediate library path as an rpath for unit tests. * Make ClangUnitTests depend on ClangHLSLTests so taef tests build. * Add clang-test-depends and test-depends targets. * Fix spelling error. Thanks @hekota!
1 parent 5b2201d commit 3ae7054

8 files changed

Lines changed: 36 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ if( LLVM_INCLUDE_TESTS )
739739
DEPENDS ${LLVM_LIT_DEPENDS}
740740
ARGS ${LLVM_LIT_EXTRA_ARGS}
741741
)
742+
add_custom_target(test-depends DEPENDS ${LLVM_LIT_DEPENDS}) # HLSL Change
742743
endif()
743744

744745
if (LLVM_INCLUDE_DOCS)

tools/clang/test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ endif()
6969

7070
# HLSL Change Begin
7171
# Explicitly overriding check-clang dependencies for HLSL
72-
set(CLANG_TEST_DEPS clang opt FileCheck count not)
72+
set(CLANG_TEST_DEPS dxc dxcompiler clang-tblgen llvm-config opt FileCheck count not ClangUnitTests)
73+
add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
74+
set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
7375
# HLSL Change End
7476

7577

tools/clang/test/Unit/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ try:
1919
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
2020
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
2121
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
22+
config.shlibdir = config.shlibdir % lit_config.params
2223
except KeyError:
2324
e = sys.exc_info()[1]
2425
key, = e.args

tools/clang/test/taef/lit.cfg

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ if llvm_obj_root is None:
2525
lit_config.load_config(config, site_cfg)
2626
raise SystemExit
2727

28-
29-
te = os.path.join(config.llvm_obj_root, "TAEF", config.arch, 'te.exe')
30-
31-
test_dll = os.path.join(config.llvm_obj_root, config.build_mode, 'bin', 'ClangHLSLTests.dll')
32-
33-
hlsl_data_dir = os.path.join(config.llvm_src_root, 'tools', 'clang', 'test', 'hlsl')
34-
35-
test_dir = os.path.join(config.llvm_obj_root, config.build_mode, 'test')
36-
#projects\dxilconv\test
37-
config.test_format = lit.formats.TaefTest(te, test_dll, hlsl_data_dir, test_dir)
38-
3928
# TAEF only runs on Windows
4029
if platform.system() != 'Windows':
4130
config.unsupported = True
31+
else:
32+
te = os.path.join(config.llvm_obj_root, "TAEF", config.arch, 'te.exe')
33+
34+
test_dll = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'bin', 'ClangHLSLTests.dll')
35+
36+
hlsl_data_dir = os.path.join(config.llvm_src_root, 'tools', 'clang', 'test', 'HLSL')
37+
38+
test_dir = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'test')
39+
config.test_format = lit.formats.TaefTest(te, test_dll, hlsl_data_dir, test_dir)

tools/clang/test/taef/lit.site.cfg.in

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ import sys
44
# Do not edit!
55
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
66
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
7-
config.build_mode = lit_config.params["build_mode"]
8-
config.arch = "@DXC_BUILD_ARCH@"
7+
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
8+
config.arch = "@CMAKE_C_COMPILER_ARCHITECTURE_ID@"
9+
10+
# Support substitution of the tools_dir, libs_dirs, and build_mode with user
11+
# parameters. This is used when we can't determine the tool dir at
12+
# configuration time.
13+
try:
14+
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
15+
except KeyError:
16+
e = sys.exc_info()[1]
17+
key, = e.args
18+
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
919

1020
# Let the main config do the real work.
1121
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/taef/lit.cfg")

tools/clang/unittests/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
add_custom_target(ClangUnitTests)
22
set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
33

4+
# HLSL Change - rpath
5+
# Add LLVM_LIBRARY_OUTPUT_INTDIR to install rpath for unit tests. This allows
6+
# unit test binaries on Unix to be run directly even if they dlopen or
7+
# dynamically link against dxcompiler.
8+
set(CMAKE_INSTALL_RPATH "${LLVM_LIBRARY_OUTPUT_INTDIR};${CMAKE_INSTALL_RPATH}")
9+
# HLSL Change End - rpath
10+
411
# add_clang_unittest(test_dirname file1.cpp file2.cpp)
512
#
613
# Will compile the list of files together and link against the clang

tools/clang/unittests/HLSL/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ add_clang_library(ClangHLSLTests SHARED
5151
VerifierTest.cpp
5252
clang-hlsl-tests.rc
5353
)
54+
55+
add_dependencies(ClangUnitTests ClangHLSLTests)
5456
else (WIN32)
5557
set(HLSL_IGNORE_SOURCES
5658
ExecutionTest.cpp

utils/lit/lit/formats/taef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def getTaefTests(self, dll_path, litConfig, localConfig):
4242
lines = lines.replace('\r', '')
4343
lines = lines.split('\n')
4444
except:
45-
litConfig.error("unable to discover taef in %r" % path)
45+
litConfig.error("unable to discover taef in %r" % dll_path)
4646
raise StopIteration
4747

4848
for ln in lines:

0 commit comments

Comments
 (0)