leonardchan created this revision.
leonardchan added a project: clang.
Herald added a subscriber: mgorny.
leonardchan requested review of this revision.

Not all downstream users may want to build all tools shipped with clang. 
`clang-repl` for us in particular can sometimes lead to flaky builds when 
testing a toolchain built with LTO.

This is a WIP patch that demonstrates:

- Allowing `clang-repl` to be built (by default) as part of `check-all`. Note 
that this doesn't remove it as a build target. It just makes it so that it's 
not built by default.
- Only running tests that require `clang-repl` via a `REQUIRES` line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108173

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/sanity.c
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===================================================================
--- clang/test/lit.site.cfg.py.in
+++ 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@
Index: clang/test/lit.cfg.py
===================================================================
--- clang/test/lit.cfg.py
+++ 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
Index: clang/test/Interpreter/sanity.c
===================================================================
--- clang/test/Interpreter/sanity.c
+++ 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| \
Index: clang/test/Interpreter/execute.cpp
===================================================================
--- clang/test/Interpreter/execute.cpp
+++ 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
Index: clang/test/CMakeLists.txt
===================================================================
--- clang/test/CMakeLists.txt
+++ 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
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ 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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to