[libclc] [llvm] [libclc] Replace llvm-dis with llvm-nm in check-external-funcs.test (PR #187190)
Wenju He via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 19 05:27:01 PDT 2026
https://github.com/wenju-he updated https://github.com/llvm/llvm-project/pull/187190
>From 6fbdd1f8d262b35b40bd29c2ed9952f6524a9f36 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Wed, 18 Mar 2026 05:26:02 +0100
Subject: [PATCH 1/7] [libclc] Replace shell-based external symbol check with
lit test using llvm-nm
Move check_external_funcs.test into libclc/test/AMDGPU folder.
Each target can add it own check_external_funcs.test if desired.
FileCheck and llvm-nm are are covered by extra_deps in runtime build
when LLVM_INCLUDE_TESTS is true.
---
libclc/CMakeLists.txt | 3 +-
libclc/test/AMDGPU/check-external-funcs.test | 3 ++
libclc/test/CMakeLists.txt | 56 +++++---------------
libclc/test/check_external_funcs.sh | 30 -----------
libclc/test/lit.cfg.py | 15 +++---
libclc/test/lit.site.cfg.py.in | 5 +-
llvm/runtimes/CMakeLists.txt | 2 +-
7 files changed, 25 insertions(+), 89 deletions(-)
create mode 100644 libclc/test/AMDGPU/check-external-funcs.test
delete mode 100755 libclc/test/check_external_funcs.sh
diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 77979e1b92add..1103711298ce3 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -48,7 +48,7 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DI
message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" )
- foreach( tool IN ITEMS llvm-link llvm-dis opt )
+ foreach( tool IN ITEMS llvm-link opt )
find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH )
set( ${tool}_exe ${LLVM_TOOL_${tool}} )
set( ${tool}_target )
@@ -73,7 +73,6 @@ else()
endif()
get_host_tool_path( llvm-link LLVM_LINK llvm-link_exe llvm-link_target )
- get_host_tool_path( llvm-dis LLVM_DIS llvm-dis_exe llvm-dis_target )
get_host_tool_path( opt OPT opt_exe opt_target )
# Setup the paths where libclc runtimes should be stored. By default, in an
diff --git a/libclc/test/AMDGPU/check-external-funcs.test b/libclc/test/AMDGPU/check-external-funcs.test
new file mode 100644
index 0000000000000..478480ea1c002
--- /dev/null
+++ b/libclc/test/AMDGPU/check-external-funcs.test
@@ -0,0 +1,3 @@
+; RUN: llvm-nm -u "%libclc_library_dir/amdgcn-amd-amdhsa-llvm/libclc.bc" | FileCheck %s --allow-empty
+
+; CHECK-NOT: {{.+}}
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 3b16b5ab3f651..7a6b99de0e80e 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -1,50 +1,18 @@
-set(LIBCLC_LIBRARY_DIR ${LIBCLC_OUTPUT_LIBRARY_DIR})
set(LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
set(LIBCLC_TEST_DEPS
- ${llvm-dis_target}
+ libclc-opencl-builtins
)
-umbrella_lit_testsuite_begin(check-libclc)
-
-# Testing unresolved symbols.
-# check_external_funcs.sh does not work on Windows
-if(NOT WIN32)
- foreach(t ${LIBCLC_TARGETS_TO_BUILD})
- string(REPLACE "-" ";" TRIPLE ${t})
- list(GET TRIPLE 0 ARCH)
-
- # Skip nvptx, clspv, spirv targets
- if(ARCH MATCHES "^(nvptx|clspv)(64)?$" OR ARCH MATCHES "^spirv(64)?$")
- continue()
- endif()
-
- # Get the output file from the target property
- get_target_property(target_file libclc-${t} TARGET_FILE)
- get_filename_component(output_file ${target_file} NAME)
-
- set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
- file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
- file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
-"// RUN: %check_external_funcs %libclc_library_dir/${t}/${output_file} %llvm_tools_dir
-
-// This test verifies that the libclc library for ${t} has no
-// unresolved external functions (except LLVM intrinsics).
-")
-
- configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
- ${LIBCLC_TARGET_TEST_DIR}/lit.site.cfg.py
- MAIN_CONFIG
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
- )
-
- add_lit_testsuite(check-libclc-external-funcs-${t} "Running ${t} tests"
- ${LIBCLC_TARGET_TEST_DIR}
- DEPENDS libclc-${t} ${LIBCLC_TEST_DEPS}
- )
- set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER "libclc tests")
- endforeach()
-endif()
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+)
-umbrella_lit_testsuite_end(check-libclc)
+add_lit_testsuite(check-libclc
+ "Running the libclc regression tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${LIBCLC_TEST_DEPS}
+)
diff --git a/libclc/test/check_external_funcs.sh b/libclc/test/check_external_funcs.sh
deleted file mode 100755
index 7de1488fc895c..0000000000000
--- a/libclc/test/check_external_funcs.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-FILE=$1
-BIN_DIR=$2
-if [ ! -f $FILE ]; then
- echo "ERROR: Not a file: $FILE"
- exit 3
-fi
-ret=0
-
-DIS="$BIN_DIR/llvm-dis"
-if [ ! -x $DIS ]; then
- echo "ERROR: Disassembler '$DIS' is not executable"
- exit 3
-fi
-
-TMP_FILE=$(mktemp)
-
-# Check for external functions. Calls to llvm intrinsics are OK
-$DIS < $FILE | grep '^[[:space:]]*declare ' | grep -v '@llvm' > "$TMP_FILE"
-COUNT=$(wc -l < "$TMP_FILE")
-
-if [ "$COUNT" -ne "0" ]; then
- echo "ERROR: $COUNT unresolved external functions detected in $FILE"
- cat $TMP_FILE
- ret=1
-else
- echo "File $FILE is OK"
-fi
-exit $ret
diff --git a/libclc/test/lit.cfg.py b/libclc/test/lit.cfg.py
index d5a9b5e366e37..ab16c080c32e7 100644
--- a/libclc/test/lit.cfg.py
+++ b/libclc/test/lit.cfg.py
@@ -6,6 +6,8 @@
import lit.formats
+from lit.llvm import llvm_config
+
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
@@ -21,8 +23,7 @@
config.excludes = ["CMakeLists.txt"]
# test_source_root: The root path where tests are located.
-# For per-target tests, this is the target's test directory.
-config.test_source_root = config.libclc_obj_root
+config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.libclc_obj_root
@@ -37,10 +38,6 @@
# Define substitutions for the test files
config.substitutions.append(("%libclc_library_dir", config.libclc_library_dir))
-config.substitutions.append(("%llvm_tools_dir", config.llvm_tools_dir))
-config.substitutions.append(
- (
- "%check_external_funcs",
- os.path.join(config.libclc_test_root, "check_external_funcs.sh"),
- )
-)
+
+tools = ["llvm-nm"]
+llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
diff --git a/libclc/test/lit.site.cfg.py.in b/libclc/test/lit.site.cfg.py.in
index d43d6111f4ae9..e0f5087ba4587 100644
--- a/libclc/test/lit.site.cfg.py.in
+++ b/libclc/test/lit.site.cfg.py.in
@@ -3,9 +3,8 @@
import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.libclc_obj_root = "@LIBCLC_TARGET_TEST_DIR@"
-config.libclc_test_root = "@CMAKE_CURRENT_SOURCE_DIR@"
-config.libclc_library_dir = "@LIBCLC_LIBRARY_DIR@"
+config.libclc_library_dir = "@LIBCLC_OUTPUT_LIBRARY_DIR@"
+config.libclc_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
import lit.llvm
lit.llvm.initialize(lit_config, config)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 3ba32e415d712..5c71944856f6f 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -554,7 +554,7 @@ if(build_runtimes)
# TODO: We need to consider passing it as '-DRUNTIMES_x86_64_LLVM_ENABLE_RUNTIMES'.
if("libclc" IN_LIST LLVM_ENABLE_RUNTIMES)
- foreach(dep clang llvm-as llvm-dis llvm-link opt llvm-ar llvm-ranlib)
+ foreach(dep clang llvm-link opt llvm-ar llvm-ranlib)
if(TARGET ${dep})
list(APPEND extra_deps ${dep})
endif()
>From 959116d6b56b2f5da1c59b79fb7968f36d6d178e Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Wed, 18 Mar 2026 06:38:07 +0100
Subject: [PATCH 2/7] address copilot comments
---
libclc/test/AMDGPU/check-external-funcs.test | 2 +-
libclc/test/AMDGPU/lit.local.cfg | 2 ++
libclc/test/CMakeLists.txt | 1 +
libclc/test/lit.cfg.py | 15 +++++++++------
libclc/test/lit.site.cfg.py.in | 1 +
5 files changed, 14 insertions(+), 7 deletions(-)
create mode 100644 libclc/test/AMDGPU/lit.local.cfg
diff --git a/libclc/test/AMDGPU/check-external-funcs.test b/libclc/test/AMDGPU/check-external-funcs.test
index 478480ea1c002..45d5aadce25d5 100644
--- a/libclc/test/AMDGPU/check-external-funcs.test
+++ b/libclc/test/AMDGPU/check-external-funcs.test
@@ -1,3 +1,3 @@
-; RUN: llvm-nm -u "%libclc_library_dir/amdgcn-amd-amdhsa-llvm/libclc.bc" | FileCheck %s --allow-empty
+; RUN: llvm-nm -u "%libclc_library_dir/amdgcn-amd-amdhsa-llvm/libclc.bc" 2>&1 | FileCheck %s --allow-empty
; CHECK-NOT: {{.+}}
diff --git a/libclc/test/AMDGPU/lit.local.cfg b/libclc/test/AMDGPU/lit.local.cfg
new file mode 100644
index 0000000000000..c853e3fdf09b8
--- /dev/null
+++ b/libclc/test/AMDGPU/lit.local.cfg
@@ -0,0 +1,2 @@
+if "amdgcn" not in config.available_features:
+ config.unsupported = True
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 7a6b99de0e80e..1576f8d373917 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -1,4 +1,5 @@
set(LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
+string(REPLACE ";" " " LIBCLC_TARGETS_TO_BUILD "${LIBCLC_TARGETS_TO_BUILD}")
set(LIBCLC_TEST_DEPS
libclc-opencl-builtins
diff --git a/libclc/test/lit.cfg.py b/libclc/test/lit.cfg.py
index ab16c080c32e7..b9c424543b0ea 100644
--- a/libclc/test/lit.cfg.py
+++ b/libclc/test/lit.cfg.py
@@ -5,7 +5,6 @@
import os
import lit.formats
-
from lit.llvm import llvm_config
# Configuration file for the 'lit' test runner.
@@ -13,8 +12,8 @@
# name: The name of this test suite.
config.name = "libclc"
-# testFormat: The test format to use to interpret tests.
-config.test_format = lit.formats.ShTest(True)
+# test format
+config.test_format = lit.formats.ShTest()
# suffixes: A list of file extensions to treat as test files.
config.suffixes = [".test"]
@@ -36,8 +35,12 @@
else:
config.environment["PATH"] = config.llvm_tools_dir
+for target in config.libclc_targets_to_build.split():
+ if target:
+ arch = target.split("-")[0]
+ config.available_features.add(arch)
+
+llvm_config.use_default_substitutions()
+
# Define substitutions for the test files
config.substitutions.append(("%libclc_library_dir", config.libclc_library_dir))
-
-tools = ["llvm-nm"]
-llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
diff --git a/libclc/test/lit.site.cfg.py.in b/libclc/test/lit.site.cfg.py.in
index e0f5087ba4587..b7feebc72f7c1 100644
--- a/libclc/test/lit.site.cfg.py.in
+++ b/libclc/test/lit.site.cfg.py.in
@@ -5,6 +5,7 @@ import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.libclc_library_dir = "@LIBCLC_OUTPUT_LIBRARY_DIR@"
config.libclc_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
+config.libclc_targets_to_build = "@LIBCLC_TARGETS_TO_BUILD@"
import lit.llvm
lit.llvm.initialize(lit_config, config)
>From 69c85d18d031de79f8f5e8139e390187f24c14cd Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 19 Mar 2026 09:40:23 +0100
Subject: [PATCH 3/7] restore check_external_funcs.sh
---
libclc/test/AMDGPU/check-external-funcs.test | 3 --
libclc/test/AMDGPU/lit.local.cfg | 2 -
libclc/test/CMakeLists.txt | 54 +++++++++++++++-----
libclc/test/check_external_funcs.sh | 30 +++++++++++
libclc/test/lit.cfg.py | 22 ++++----
libclc/test/lit.site.cfg.py.in | 4 +-
6 files changed, 85 insertions(+), 30 deletions(-)
delete mode 100644 libclc/test/AMDGPU/check-external-funcs.test
delete mode 100644 libclc/test/AMDGPU/lit.local.cfg
create mode 100755 libclc/test/check_external_funcs.sh
diff --git a/libclc/test/AMDGPU/check-external-funcs.test b/libclc/test/AMDGPU/check-external-funcs.test
deleted file mode 100644
index 45d5aadce25d5..0000000000000
--- a/libclc/test/AMDGPU/check-external-funcs.test
+++ /dev/null
@@ -1,3 +0,0 @@
-; RUN: llvm-nm -u "%libclc_library_dir/amdgcn-amd-amdhsa-llvm/libclc.bc" 2>&1 | FileCheck %s --allow-empty
-
-; CHECK-NOT: {{.+}}
diff --git a/libclc/test/AMDGPU/lit.local.cfg b/libclc/test/AMDGPU/lit.local.cfg
deleted file mode 100644
index c853e3fdf09b8..0000000000000
--- a/libclc/test/AMDGPU/lit.local.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-if "amdgcn" not in config.available_features:
- config.unsupported = True
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 1576f8d373917..dd8dfa8346722 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -1,19 +1,49 @@
set(LLVM_TOOLS_DIR ${LLVM_TOOLS_BINARY_DIR})
-string(REPLACE ";" " " LIBCLC_TARGETS_TO_BUILD "${LIBCLC_TARGETS_TO_BUILD}")
set(LIBCLC_TEST_DEPS
libclc-opencl-builtins
)
-configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
- ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
- MAIN_CONFIG
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
-)
+umbrella_lit_testsuite_begin(check-libclc)
-add_lit_testsuite(check-libclc
- "Running the libclc regression tests"
- ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS ${LIBCLC_TEST_DEPS}
-)
+# Testing unresolved symbols.
+# check_external_funcs.sh does not work on Windows
+if(NOT WIN32)
+ foreach(t ${LIBCLC_TARGETS_TO_BUILD})
+ string(REPLACE "-" ";" TRIPLE ${t})
+ list(GET TRIPLE 0 ARCH)
+
+ # Skip nvptx, clspv, spirv targets
+ if(ARCH MATCHES "^(nvptx|clspv)(64)?$" OR ARCH MATCHES "^spirv(64)?$")
+ continue()
+ endif()
+
+ # Get the output file from the target property
+ get_target_property(target_file libclc-${t} TARGET_FILE)
+ get_filename_component(output_file ${target_file} NAME)
+
+ set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
+ file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
+ file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
+"// RUN: %check_external_funcs %libclc_library_dir/${t}/${output_file} %llvm_tools_dir
+
+// This test verifies that the libclc library for ${t} has no
+// unresolved external functions (except LLVM intrinsics).
+")
+
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${LIBCLC_TARGET_TEST_DIR}/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+ )
+
+ add_lit_testsuite(check-libclc-external-funcs-${t} "Running ${t} tests"
+ ${LIBCLC_TARGET_TEST_DIR}
+ DEPENDS libclc-${t} ${LIBCLC_TEST_DEPS}
+ )
+ set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER "libclc tests")
+ endforeach()
+endif()
+
+umbrella_lit_testsuite_end(check-libclc)
diff --git a/libclc/test/check_external_funcs.sh b/libclc/test/check_external_funcs.sh
new file mode 100755
index 0000000000000..57261ede09979
--- /dev/null
+++ b/libclc/test/check_external_funcs.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+FILE=$1
+BIN_DIR=$2
+if [ ! -f $FILE ]; then
+ echo "ERROR: Not a file: $FILE"
+ exit 3
+fi
+ret=0
+
+LLVM_NM="$BIN_DIR/llvm-nm"
+if [ ! -x $LLVM_NM ]; then
+ echo "ERROR: Disassembler '$LLVM_NM' is not executable"
+ exit 3
+fi
+
+TMP_FILE=$(mktemp)
+
+# Check for external functions
+"$LLVM_NM" -u "$FILE" > "$TMP_FILE"
+COUNT=$(wc -l < "$TMP_FILE")
+
+if [ "$COUNT" -ne "0" ]; then
+ echo "ERROR: $COUNT unresolved external functions detected in $FILE"
+ cat $TMP_FILE
+ ret=1
+else
+ echo "File $FILE is OK"
+fi
+exit $ret
diff --git a/libclc/test/lit.cfg.py b/libclc/test/lit.cfg.py
index b9c424543b0ea..d5a9b5e366e37 100644
--- a/libclc/test/lit.cfg.py
+++ b/libclc/test/lit.cfg.py
@@ -5,15 +5,14 @@
import os
import lit.formats
-from lit.llvm import llvm_config
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
config.name = "libclc"
-# test format
-config.test_format = lit.formats.ShTest()
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.ShTest(True)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = [".test"]
@@ -22,7 +21,8 @@
config.excludes = ["CMakeLists.txt"]
# test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
+# For per-target tests, this is the target's test directory.
+config.test_source_root = config.libclc_obj_root
# test_exec_root: The root path where tests should be run.
config.test_exec_root = config.libclc_obj_root
@@ -35,12 +35,12 @@
else:
config.environment["PATH"] = config.llvm_tools_dir
-for target in config.libclc_targets_to_build.split():
- if target:
- arch = target.split("-")[0]
- config.available_features.add(arch)
-
-llvm_config.use_default_substitutions()
-
# Define substitutions for the test files
config.substitutions.append(("%libclc_library_dir", config.libclc_library_dir))
+config.substitutions.append(("%llvm_tools_dir", config.llvm_tools_dir))
+config.substitutions.append(
+ (
+ "%check_external_funcs",
+ os.path.join(config.libclc_test_root, "check_external_funcs.sh"),
+ )
+)
diff --git a/libclc/test/lit.site.cfg.py.in b/libclc/test/lit.site.cfg.py.in
index b7feebc72f7c1..56212e6c9d533 100644
--- a/libclc/test/lit.site.cfg.py.in
+++ b/libclc/test/lit.site.cfg.py.in
@@ -3,9 +3,9 @@
import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.libclc_obj_root = "@LIBCLC_TARGET_TEST_DIR@"
+config.libclc_test_root = "@CMAKE_CURRENT_SOURCE_DIR@"
config.libclc_library_dir = "@LIBCLC_OUTPUT_LIBRARY_DIR@"
-config.libclc_obj_root = "@CMAKE_CURRENT_BINARY_DIR@"
-config.libclc_targets_to_build = "@LIBCLC_TARGETS_TO_BUILD@"
import lit.llvm
lit.llvm.initialize(lit_config, config)
>From 18bccfd43790a8d257ae389bc12d84b8d6008bbe Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 19 Mar 2026 09:57:38 +0100
Subject: [PATCH 4/7] delete check_external_funcs.sh
---
libclc/test/CMakeLists.txt | 6 ++----
libclc/test/check_external_funcs.sh | 30 -----------------------------
libclc/test/lit.cfg.py | 7 -------
libclc/test/lit.site.cfg.py.in | 1 -
4 files changed, 2 insertions(+), 42 deletions(-)
delete mode 100755 libclc/test/check_external_funcs.sh
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index dd8dfa8346722..b9e447833c1cf 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -7,7 +7,6 @@ set(LIBCLC_TEST_DEPS
umbrella_lit_testsuite_begin(check-libclc)
# Testing unresolved symbols.
-# check_external_funcs.sh does not work on Windows
if(NOT WIN32)
foreach(t ${LIBCLC_TARGETS_TO_BUILD})
string(REPLACE "-" ";" TRIPLE ${t})
@@ -25,10 +24,9 @@ if(NOT WIN32)
set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
-"// RUN: %check_external_funcs %libclc_library_dir/${t}/${output_file} %llvm_tools_dir
+"; RUN: llvm-nm -u \"%libclc_library_dir/${t}/${output_file}\" | FileCheck %s --allow-empty
-// This test verifies that the libclc library for ${t} has no
-// unresolved external functions (except LLVM intrinsics).
+; CHECK-NOT: {{.+}}
")
configure_lit_site_cfg(
diff --git a/libclc/test/check_external_funcs.sh b/libclc/test/check_external_funcs.sh
deleted file mode 100755
index 57261ede09979..0000000000000
--- a/libclc/test/check_external_funcs.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-FILE=$1
-BIN_DIR=$2
-if [ ! -f $FILE ]; then
- echo "ERROR: Not a file: $FILE"
- exit 3
-fi
-ret=0
-
-LLVM_NM="$BIN_DIR/llvm-nm"
-if [ ! -x $LLVM_NM ]; then
- echo "ERROR: Disassembler '$LLVM_NM' is not executable"
- exit 3
-fi
-
-TMP_FILE=$(mktemp)
-
-# Check for external functions
-"$LLVM_NM" -u "$FILE" > "$TMP_FILE"
-COUNT=$(wc -l < "$TMP_FILE")
-
-if [ "$COUNT" -ne "0" ]; then
- echo "ERROR: $COUNT unresolved external functions detected in $FILE"
- cat $TMP_FILE
- ret=1
-else
- echo "File $FILE is OK"
-fi
-exit $ret
diff --git a/libclc/test/lit.cfg.py b/libclc/test/lit.cfg.py
index d5a9b5e366e37..5b824aa4df872 100644
--- a/libclc/test/lit.cfg.py
+++ b/libclc/test/lit.cfg.py
@@ -37,10 +37,3 @@
# Define substitutions for the test files
config.substitutions.append(("%libclc_library_dir", config.libclc_library_dir))
-config.substitutions.append(("%llvm_tools_dir", config.llvm_tools_dir))
-config.substitutions.append(
- (
- "%check_external_funcs",
- os.path.join(config.libclc_test_root, "check_external_funcs.sh"),
- )
-)
diff --git a/libclc/test/lit.site.cfg.py.in b/libclc/test/lit.site.cfg.py.in
index 56212e6c9d533..c03943bebd267 100644
--- a/libclc/test/lit.site.cfg.py.in
+++ b/libclc/test/lit.site.cfg.py.in
@@ -4,7 +4,6 @@ import sys
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.libclc_obj_root = "@LIBCLC_TARGET_TEST_DIR@"
-config.libclc_test_root = "@CMAKE_CURRENT_SOURCE_DIR@"
config.libclc_library_dir = "@LIBCLC_OUTPUT_LIBRARY_DIR@"
import lit.llvm
>From 345b90c4c67ecd5e0037c3a15c64b7edc6439ad0 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 19 Mar 2026 10:00:46 +0100
Subject: [PATCH 5/7] test on windows
---
libclc/test/CMakeLists.txt | 60 ++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index b9e447833c1cf..88fbc30e5b124 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -7,41 +7,39 @@ set(LIBCLC_TEST_DEPS
umbrella_lit_testsuite_begin(check-libclc)
# Testing unresolved symbols.
-if(NOT WIN32)
- foreach(t ${LIBCLC_TARGETS_TO_BUILD})
- string(REPLACE "-" ";" TRIPLE ${t})
- list(GET TRIPLE 0 ARCH)
-
- # Skip nvptx, clspv, spirv targets
- if(ARCH MATCHES "^(nvptx|clspv)(64)?$" OR ARCH MATCHES "^spirv(64)?$")
- continue()
- endif()
-
- # Get the output file from the target property
- get_target_property(target_file libclc-${t} TARGET_FILE)
- get_filename_component(output_file ${target_file} NAME)
-
- set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
- file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
- file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
+foreach(t ${LIBCLC_TARGETS_TO_BUILD})
+ string(REPLACE "-" ";" TRIPLE ${t})
+ list(GET TRIPLE 0 ARCH)
+
+ # Skip nvptx, clspv, spirv targets
+ if(ARCH MATCHES "^(nvptx|clspv)(64)?$" OR ARCH MATCHES "^spirv(64)?$")
+ continue()
+ endif()
+
+ # Get the output file from the target property
+ get_target_property(target_file libclc-${t} TARGET_FILE)
+ get_filename_component(output_file ${target_file} NAME)
+
+ set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
+ file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
+ file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
"; RUN: llvm-nm -u \"%libclc_library_dir/${t}/${output_file}\" | FileCheck %s --allow-empty
; CHECK-NOT: {{.+}}
")
- configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
- ${LIBCLC_TARGET_TEST_DIR}/lit.site.cfg.py
- MAIN_CONFIG
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
- )
-
- add_lit_testsuite(check-libclc-external-funcs-${t} "Running ${t} tests"
- ${LIBCLC_TARGET_TEST_DIR}
- DEPENDS libclc-${t} ${LIBCLC_TEST_DEPS}
- )
- set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER "libclc tests")
- endforeach()
-endif()
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${LIBCLC_TARGET_TEST_DIR}/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+ )
+
+ add_lit_testsuite(check-libclc-external-funcs-${t} "Running ${t} tests"
+ ${LIBCLC_TARGET_TEST_DIR}
+ DEPENDS libclc-${t} ${LIBCLC_TEST_DEPS}
+ )
+ set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER "libclc tests")
+endforeach()
umbrella_lit_testsuite_end(check-libclc)
>From 16615ab68af81b483114b0854bd846c19d6f6277 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 19 Mar 2026 13:07:33 +0100
Subject: [PATCH 6/7] remove redundant dependency: libclc-${t} is already
covered by LIBCLC_TEST_DEPS
---
libclc/test/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 88fbc30e5b124..6fbe276cf6f04 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -37,7 +37,7 @@ foreach(t ${LIBCLC_TARGETS_TO_BUILD})
add_lit_testsuite(check-libclc-external-funcs-${t} "Running ${t} tests"
${LIBCLC_TARGET_TEST_DIR}
- DEPENDS libclc-${t} ${LIBCLC_TEST_DEPS}
+ DEPENDS ${LIBCLC_TEST_DEPS}
)
set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER "libclc tests")
endforeach()
>From e40357c698c27d5e61389d8151245a854f1bef3a Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Thu, 19 Mar 2026 13:26:02 +0100
Subject: [PATCH 7/7] use TARGET_PROPERTY, GET_FILENAME, GENERATE OUTPUT
---
libclc/test/CMakeLists.txt | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/libclc/test/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 6fbe276cf6f04..4fb984056577c 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -17,16 +17,14 @@ foreach(t ${LIBCLC_TARGETS_TO_BUILD})
endif()
# Get the output file from the target property
- get_target_property(target_file libclc-${t} TARGET_FILE)
- get_filename_component(output_file ${target_file} NAME)
+ set(target_file "$<TARGET_PROPERTY:libclc-${t},TARGET_FILE>")
+ set(output_file "$<PATH:GET_FILENAME,${target_file}>")
set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
- file(WRITE ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
-"; RUN: llvm-nm -u \"%libclc_library_dir/${t}/${output_file}\" | FileCheck %s --allow-empty
-
-; CHECK-NOT: {{.+}}
-")
+ file(GENERATE OUTPUT ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
+ CONTENT "; RUN: llvm-nm -u \"%libclc_library_dir/${t}/${output_file}\" | FileCheck %s --allow-empty\n\n; CHECK-NOT: {{.+}}\n"
+ )
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
More information about the cfe-commits
mailing list