diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -465,6 +465,8 @@ option(CLANG_ENABLE_STATIC_ANALYZER "Include static analyzer in clang binary." ON) +option(CLANG_BUILD_CLANG_REPL_DEFAULT "Build clang-repl by default." OFF) + option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF) option(CLANG_ROUND_TRIP_CC1_ARGS diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -13,6 +13,7 @@ CLANG_BUILD_EXAMPLES CLANG_ENABLE_ARCMT CLANG_ENABLE_STATIC_ANALYZER + CLANG_BUILD_CLANG_REPL_DEFAULT CLANG_SPAWN_CC1 ENABLE_BACKTRACES LLVM_ENABLE_NEW_PASS_MANAGER @@ -70,13 +71,16 @@ clang-import-test clang-rename clang-refactor - clang-repl clang-diff clang-scan-deps diagtool hmaptool ) - + +if(CLANG_BUILD_CLANG_REPL_DEFAULT) + list(APPEND CLANG_TEST_DEPS clang-repl) +endif() + if(CLANG_ENABLE_STATIC_ANALYZER) list(APPEND CLANG_TEST_DEPS clang-check diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp --- a/clang/test/Interpreter/execute.cpp +++ b/clang/test/Interpreter/execute.cpp @@ -1,3 +1,5 @@ +// REQUIRES: clang-repl + // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \ // RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s // REQUIRES: host-supports-jit diff --git a/clang/test/Interpreter/sanity.c b/clang/test/Interpreter/sanity.c --- a/clang/test/Interpreter/sanity.c +++ b/clang/test/Interpreter/sanity.c @@ -1,3 +1,5 @@ +// REQUIRES: clang-repl + // RUN: cat %s | \ // RUN: clang-repl -Xcc -fno-color-diagnostics -Xcc -Xclang -Xcc -ast-dump \ // RUN: -Xcc -Xclang -Xcc -ast-dump-filter -Xcc -Xclang -Xcc Test 2>&1| \ diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -63,7 +63,7 @@ tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir] tools = [ - 'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format', 'clang-repl', + 'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'clang-scan-deps', 'opt', 'llvm-ifs', 'yaml2obj', ToolSubst('%clang_extdef_map', command=FindTool( 'clang-extdef-mapping'), unresolved='ignore'), @@ -73,9 +73,20 @@ config.available_features.add('examples') tools.append('clang-interpreter') -def have_host_jit_support(): +def get_clang_repl(): clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir) + if not clang_repl_exe: + return None + + return clang_repl_exe + +clang_repl_exe = get_clang_repl() +if clang_repl_exe is not None: + tools.append('clang-repl') + config.available_features.add('clang-repl') + +def have_host_jit_support(): if not clang_repl_exe: print('clang-repl not found') return False diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -26,6 +26,7 @@ config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = "@LLVM_WITH_Z3@" config.clang_examples = @CLANG_BUILD_EXAMPLES@ +config.clang_repl = @CLANG_BUILD_CLANG_REPL_DEFAULT@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ config.enable_experimental_new_pass_manager = @LLVM_ENABLE_NEW_PASS_MANAGER@