[llvm] c81d449 - [LLVM][CMake] Build examples for llvm-test-depends

via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 13 00:05:52 PST 2025


Author: Alexis Engelke
Date: 2025-12-13T09:05:47+01:00
New Revision: c81d44942e56be809179f954454878cd207b132f

URL: https://github.com/llvm/llvm-project/commit/c81d44942e56be809179f954454878cd207b132f
DIFF: https://github.com/llvm/llvm-project/commit/c81d44942e56be809179f954454878cd207b132f.diff

LOG: [LLVM][CMake] Build examples for llvm-test-depends

Build examples and example plug-ins by default when running tests. If
examples are unwanted, they can still be disabled completely using
LLVM_INCLUDE_EXAMPLES=OFF. Plugin tests depend on examples and it is
beneficial to test them by default. By default, Examples will still not
be included in the default target or be installed, this remains
controlled by LLVM_BUILD_EXAMPLES (which defaults to OFF).

The additional cost for building examples for tests is 17 compilation
units (12 C++, 5 C), which should be tolerable.

I don't know how broken the examples currently are in the various build
configurations, but if we find breakage, it would be good to fix it.

Pull Request: https://github.com/llvm/llvm-project/pull/171998

Added: 
    

Modified: 
    llvm/docs/CMake.rst
    llvm/test/CMakeLists.txt
    llvm/test/Examples/lit.local.cfg
    llvm/test/lit.cfg.py
    llvm/test/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index de8be0ad2dded..ec181999aec57 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -366,9 +366,10 @@ its enabled sub-projects. Nearly all of these variable names begin with
   ``LLVM_ENABLE_SPHINX`` and ``LLVM_ENABLE_DOXYGEN``.
 
 **LLVM_BUILD_EXAMPLES**:BOOL
-  Build LLVM examples. Defaults to OFF. Targets for building each example are
-  generated in any case. See documentation for *LLVM_BUILD_TOOLS* above for more
-  details.
+  Include LLVM examples in the 'all' build target and install them as part of
+  the ``install`` target. Defaults to OFF. Targets for building examples are
+  still generated, this is controlled by *LLVM_INCLUDE_EXAMPLES*. Note that some
+  examples might still be built as dependencies for tests.
 
 **LLVM_BUILD_INSTRUMENTED_COVERAGE**:BOOL
   If enabled, `source-based code coverage

diff  --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index e547c3429058b..1a17c97d119bf 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -13,7 +13,7 @@ llvm_canonicalize_cmake_booleans(
   LLVM_LINK_LLVM_DYLIB
   LLVM_TOOL_LTO_BUILD
   LLVM_USE_INTEL_JITEVENTS
-  LLVM_BUILD_EXAMPLES
+  LLVM_INCLUDE_EXAMPLES
   LLVM_ENABLE_PLUGINS
   LLVM_BYE_LINK_INTO_TOOLS
   LLVM_EXAMPLEIRTRANSFORMS_LINK_INTO_TOOLS
@@ -186,7 +186,7 @@ if (TARGET llvm-mt)
   list(APPEND LLVM_TEST_DEPENDS llvm-mt)
 endif ()
 
-if(LLVM_BUILD_EXAMPLES)
+if(LLVM_INCLUDE_EXAMPLES)
   list(APPEND LLVM_TEST_DEPENDS
     Kaleidoscope-Ch3
     Kaleidoscope-Ch4

diff  --git a/llvm/test/Examples/lit.local.cfg b/llvm/test/Examples/lit.local.cfg
index f9127daf813cb..3e19c6cbb0cec 100644
--- a/llvm/test/Examples/lit.local.cfg
+++ b/llvm/test/Examples/lit.local.cfg
@@ -1,4 +1,4 @@
-if not config.build_examples or sys.platform in ["win32"]:
+if not config.include_examples or sys.platform in ["win32"]:
     config.unsupported = True
 
 # Test discovery should ignore subdirectories that contain test inputs.

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 1dfa280e6b82a..26fa8078a1e9b 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -511,7 +511,7 @@ def enable_ptxas(ptxas_executable):
 if config.has_plugins:
     config.available_features.add("plugins")
 
-if config.build_examples:
+if config.include_examples:
     config.available_features.add("examples")
 
 if config.linked_bye_extension:

diff  --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in
index c5cb7160a3d40..193f351ef52ef 100644
--- a/llvm/test/lit.site.cfg.py.in
+++ b/llvm/test/lit.site.cfg.py.in
@@ -40,7 +40,7 @@ config.have_curl = @LLVM_ENABLE_CURL@
 config.have_httplib = @LLVM_ENABLE_HTTPLIB@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
-config.build_examples = @LLVM_BUILD_EXAMPLES@
+config.include_examples = @LLVM_INCLUDE_EXAMPLES@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.enable_threads = @LLVM_ENABLE_THREADS@
 config.build_shared_libs = @BUILD_SHARED_LIBS@


        


More information about the llvm-commits mailing list