[PATCH] D105447: [analyzer] Allow cmake options to be passed to satest container

Manas Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 5 15:37:55 PDT 2021


manas created this revision.
Herald added subscribers: steakhal, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: teemperor.
manas requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch selects all cmake options and passes them to global cmake
command while building LLVM inside satest docker container.

Prior to this, the cmake command was hard-coded and this would consume
a huge amount of memory while building. There was no support to pass
extra cmake options for the build, except for changing the command
manually. This patch allows testers to pass all "-D*" cmake options to
the build.

It also removes -DLLVM_BUILD_RUNTIME cmake option from the hard-coded
cmake command as it was allowing the build to hog up a lot of memory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105447

Files:
  clang/utils/analyzer/entrypoint.py


Index: clang/utils/analyzer/entrypoint.py
===================================================================
--- clang/utils/analyzer/entrypoint.py
+++ clang/utils/analyzer/entrypoint.py
@@ -9,10 +9,11 @@
 
 def main():
     settings, rest = parse_arguments()
+    cmake_opts = list(filter(lambda cmd: cmd[:2]=='-D', rest))
     if settings.wait:
         wait()
     if settings.build_llvm or settings.build_llvm_only:
-        build_llvm()
+        build_llvm(cmake_opts)
     if settings.build_llvm_only:
         return
     sys.exit(test(rest))
@@ -33,11 +34,11 @@
     return parser.parse_known_args()
 
 
-def build_llvm():
+def build_llvm(cmake_options):
     os.chdir('/build')
     try:
         if is_cmake_needed():
-            cmake()
+            cmake(cmake_options)
         ninja()
     except CalledProcessError:
         print("Build failed!")
@@ -50,13 +51,14 @@
 
 CMAKE_COMMAND = "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release " \
     "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 " \
-    "-DLLVM_ENABLE_PROJECTS=\"clang;openmp\" -DLLVM_BUILD_RUNTIME=OFF " \
+    "-DLLVM_ENABLE_PROJECTS=\"clang;openmp\" " \
     "-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF " \
     "-DCLANG_ENABLE_STATIC_ANALYZER=ON"
 
 
-def cmake():
-    check_call(CMAKE_COMMAND + ' /llvm-project/llvm', shell=True)
+def cmake(cmake_options):
+    check_call(CMAKE_COMMAND + ' '.join(cmake_options) + ' /llvm-project/llvm',
+            shell=True)
 
 
 def ninja():


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105447.356571.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210705/590e507d/attachment.bin>


More information about the cfe-commits mailing list