-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Use cmake to find perl executable #91275
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
Conversation
I checked
|
@llvm/pr-subscribers-clang Author: Matthias Braun (MatzeB) Changes
This adds a Ideally we would also check if dependent perl modules like Full diff: https://github.com/llvm/llvm-project/pull/91275.diff 13 Files Affected:
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index cf97e3c6e851ae..c20ce47a12abbd 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -523,6 +523,8 @@ endif()
if( CLANG_INCLUDE_TESTS )
+ find_package(Perl)
+
add_subdirectory(unittests)
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
list(APPEND CLANG_TEST_PARAMS
diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test
index 483762d619d178..789f7e0ac197c6 100644
--- a/clang/test/Analysis/scan-build/cxx-name.test
+++ b/clang/test/Analysis/scan-build/cxx-name.test
@@ -1,4 +1,4 @@
-REQUIRES: shell
+REQUIRES: perl
RUN: %scan-build sh -c 'echo "CLANG_CXX=/$(basename "$CLANG_CXX")/"' | FileCheck %s
diff --git a/clang/test/Analysis/scan-build/deduplication.test b/clang/test/Analysis/scan-build/deduplication.test
index 56d888e5fc12a2..62375d9aadfa85 100644
--- a/clang/test/Analysis/scan-build/deduplication.test
+++ b/clang/test/Analysis/scan-build/deduplication.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir \
diff --git a/clang/test/Analysis/scan-build/exclude_directories.test b/clang/test/Analysis/scan-build/exclude_directories.test
index c161e51b6d26c5..c15568f0b6bb9e 100644
--- a/clang/test/Analysis/scan-build/exclude_directories.test
+++ b/clang/test/Analysis/scan-build/exclude_directories.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir %clang -S \
diff --git a/clang/test/Analysis/scan-build/help.test b/clang/test/Analysis/scan-build/help.test
index 61915d32609439..2966507b6080cd 100644
--- a/clang/test/Analysis/scan-build/help.test
+++ b/clang/test/Analysis/scan-build/help.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: %scan-build -h | FileCheck %s
RUN: %scan-build --help | FileCheck %s
diff --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test
index add35d83b95887..2d5c001e83960d 100644
--- a/clang/test/Analysis/scan-build/html_output.test
+++ b/clang/test/Analysis/scan-build/html_output.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
diff --git a/clang/test/Analysis/scan-build/lit.local.cfg b/clang/test/Analysis/scan-build/lit.local.cfg
index fab52b1c7bd679..e606243ea73a48 100644
--- a/clang/test/Analysis/scan-build/lit.local.cfg
+++ b/clang/test/Analysis/scan-build/lit.local.cfg
@@ -12,8 +12,9 @@ clang_path = config.clang if config.have_llvm_driver else os.path.realpath(confi
config.substitutions.append(
(
"%scan-build",
- "'%s' --use-analyzer=%s "
+ "'%s' '%s' --use-analyzer=%s "
% (
+ config.perl_executable,
lit.util.which(
"scan-build",
os.path.join(config.clang_src_dir, "tools", "scan-build", "bin"),
diff --git a/clang/test/Analysis/scan-build/plist_html_output.test b/clang/test/Analysis/scan-build/plist_html_output.test
index c07891e35fbf33..811bca22b07643 100644
--- a/clang/test/Analysis/scan-build/plist_html_output.test
+++ b/clang/test/Analysis/scan-build/plist_html_output.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
diff --git a/clang/test/Analysis/scan-build/plist_output.test b/clang/test/Analysis/scan-build/plist_output.test
index 0112e84630eda2..45c9dd0a5aa2e7 100644
--- a/clang/test/Analysis/scan-build/plist_output.test
+++ b/clang/test/Analysis/scan-build/plist_output.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
diff --git a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
index ab70435c60542f..5ce04e132f9fbc 100644
--- a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
+++ b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: cp %S/report-1.html %t.output_dir
diff --git a/clang/test/Analysis/scan-build/silence-core-checkers.test b/clang/test/Analysis/scan-build/silence-core-checkers.test
index 6d9a3017fcd612..dae54cbfb6579c 100644
--- a/clang/test/Analysis/scan-build/silence-core-checkers.test
+++ b/clang/test/Analysis/scan-build/silence-core-checkers.test
@@ -1,5 +1,4 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
+REQUIRES: perl
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir \
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index e5630a07424c7c..f82981a0880f08 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -181,6 +181,9 @@ def have_host_clang_repl_cuda():
)
)
+if config.perl_executable:
+ config.available_features.add("perl")
+
llvm_config.add_tool_substitutions(tools, tool_dirs)
config.substitutions.append(
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 6641811c588395..24d9a64bcbf6a6 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -35,6 +35,7 @@ config.enable_threads = @LLVM_ENABLE_THREADS@
config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
config.host_arch = "@HOST_ARCH@"
config.python_executable = "@Python3_EXECUTABLE@"
+config.perl_executable = "@PERL_EXECUTABLE@"
config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
config.has_plugins = @CLANG_PLUGIN_SUPPORT@
config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks a lot!!
I can confirm that it works for me on a mac too.
@jroelofs's comment is on point.
…r use lit.util.which so we don't pick up scan-build.bat on windows
Explicitly disabling the I think they weren't previously running there because of |
clang/tools/scan-build
is implemented inperl
. However givenperl
is not mentioned as a required dependency inGettingStarted.rst
we should make this optional.This adds a
find_package(Perl)
check to cmake and disables thescan-build
tests when no perl executable is found.Ideally we would also check if dependent perl modules like
Hash::Util
are present on the system, but I don't see any pre-existing cmake macros to easily test this. So for now I go with a plain check for theperl
package, at least this allows to usecmake -DCMAKE_DISABLE_FIND_PACKAGE_Perl=ON
to manually disableperl
and the tests.