Author: Wenju He
Date: 2026-03-21T09:01:44+08:00
New Revision: 8eccc21e47fbd2a81b10d3f5041c685d273d0e97

URL: 
https://github.com/llvm/llvm-project/commit/8eccc21e47fbd2a81b10d3f5041c685d273d0e97
DIFF: 
https://github.com/llvm/llvm-project/commit/8eccc21e47fbd2a81b10d3f5041c685d273d0e97.diff

LOG: [libclc] Replace llvm-dis with llvm-nm in check-external-funcs.test 
(#187190)

llvm-nm is covered by extra_deps in runtime build when
LLVM_INCLUDE_TESTS is true.

Added: 
    

Modified: 
    libclc/CMakeLists.txt
    libclc/test/CMakeLists.txt
    libclc/test/lit.cfg.py
    libclc/test/lit.site.cfg.py.in
    llvm/runtimes/CMakeLists.txt

Removed: 
    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/CMakeLists.txt b/libclc/test/CMakeLists.txt
index 3b16b5ab3f651..4d8bb60b52b0d 100644
--- a/libclc/test/CMakeLists.txt
+++ b/libclc/test/CMakeLists.txt
@@ -1,50 +1,42 @@
-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()
+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
+  set(target_file "$<TARGET_PROPERTY:libclc-${t},TARGET_FILE>")
+
+  set(LIBCLC_TARGET_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/${t})
+  file(MAKE_DIRECTORY ${LIBCLC_TARGET_TEST_DIR})
+  file(GENERATE OUTPUT ${LIBCLC_TARGET_TEST_DIR}/check-external-funcs.test
+    CONTENT "; RUN: llvm-nm -u \"${target_file}\" | FileCheck %s 
--allow-empty\n\n; CHECK-NOT: {{.+}}\n"
+  )
+
+  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_TEST_DEPS}
+  )
+  set_target_properties(check-libclc-external-funcs-${t} PROPERTIES FOLDER 
"libclc tests")
+endforeach()
 
 umbrella_lit_testsuite_end(check-libclc)

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..de1865c2ab3b6 100644
--- a/libclc/test/lit.cfg.py
+++ b/libclc/test/lit.cfg.py
@@ -34,13 +34,3 @@
     )
 else:
     config.environment["PATH"] = config.llvm_tools_dir
-
-# 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 d43d6111f4ae9..ca6ed0144ea9c 100644
--- a/libclc/test/lit.site.cfg.py.in
+++ b/libclc/test/lit.site.cfg.py.in
@@ -4,8 +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_LIBRARY_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()


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to