Skip to content

Commit 2868e26

Browse files
authored
Use cmake to find perl executable (#91275)
`clang/tools/scan-build` is implemented in `perl`. However given `perl` is not mentioned as a required dependency in `GettingStarted.rst` we should make this optional. This adds a `find_package(Perl)` check to cmake and disables the `scan-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 the `perl` package, at least this allows to use `cmake -DCMAKE_DISABLE_FIND_PACKAGE_Perl=ON` to manually disable `perl` and the tests.
1 parent 2475efa commit 2868e26

File tree

11 files changed

+11
-21
lines changed

11 files changed

+11
-21
lines changed

clang/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ endif()
523523

524524

525525
if( CLANG_INCLUDE_TESTS )
526+
find_package(Perl)
527+
526528
add_subdirectory(unittests)
527529
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
528530
list(APPEND CLANG_TEST_PARAMS

clang/test/Analysis/scan-build/deduplication.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// FIXME: Actually, "perl".
21
REQUIRES: shell
32

43
RUN: rm -rf %t.output_dir && mkdir %t.output_dir

clang/test/Analysis/scan-build/exclude_directories.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// FIXME: Actually, "perl".
2-
REQUIRES: shell
3-
41
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
52
RUN: %scan-build -o %t.output_dir %clang -S \
63
RUN: %S/Inputs/multidirectory_project/directory1/file1.c \

clang/test/Analysis/scan-build/help.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// FIXME: Actually, "perl".
2-
REQUIRES: shell
3-
41
RUN: %scan-build -h | FileCheck %s
52
RUN: %scan-build --help | FileCheck %s
63

clang/test/Analysis/scan-build/html_output.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// FIXME: Actually, "perl".
21
REQUIRES: shell
32

43
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- Python -*-
22

3-
import lit.util
43
import lit.formats
54
import os
5+
import platform
66

77
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
88
config.test_format = lit.formats.ShTest(use_lit_shell == "0")
@@ -12,13 +12,16 @@ clang_path = config.clang if config.have_llvm_driver else os.path.realpath(confi
1212
config.substitutions.append(
1313
(
1414
"%scan-build",
15-
"'%s' --use-analyzer=%s "
15+
"'%s' '%s' --use-analyzer=%s "
1616
% (
17-
lit.util.which(
18-
"scan-build",
19-
os.path.join(config.clang_src_dir, "tools", "scan-build", "bin"),
17+
config.perl_executable,
18+
os.path.join(
19+
config.clang_src_dir, "tools", "scan-build", "bin", "scan-build"
2020
),
2121
clang_path,
2222
),
2323
)
2424
)
25+
26+
if not config.perl_executable or platform.system() == "Windows":
27+
config.unsupported = True

clang/test/Analysis/scan-build/plist_html_output.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// FIXME: Actually, "perl".
21
REQUIRES: shell
32

43
RUN: rm -rf %t.output_dir && mkdir %t.output_dir

clang/test/Analysis/scan-build/plist_output.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// FIXME: Actually, "perl".
21
REQUIRES: shell
32

43
RUN: rm -rf %t.output_dir && mkdir %t.output_dir

clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// FIXME: Actually, "perl".
2-
REQUIRES: shell
3-
41
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
52
RUN: cp %S/report-1.html %t.output_dir
63
RUN: cp %S/report-2.html %t.output_dir

clang/test/Analysis/scan-build/silence-core-checkers.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// FIXME: Actually, "perl".
2-
REQUIRES: shell
3-
41
RUN: rm -rf %t.output_dir && mkdir %t.output_dir
52
RUN: %scan-build -o %t.output_dir \
63
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \

clang/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config.enable_backtrace = @ENABLE_BACKTRACES@
3434
config.enable_threads = @LLVM_ENABLE_THREADS@
3535
config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
3636
config.host_arch = "@HOST_ARCH@"
37+
config.perl_executable = "@PERL_EXECUTABLE@"
3738
config.python_executable = "@Python3_EXECUTABLE@"
3839
config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
3940
config.has_plugins = @CLANG_PLUGIN_SUPPORT@

0 commit comments

Comments
 (0)