[PATCH] check-llvm: Ask llvm-config about assertion mode, instead of llc.
Reid Kleckner
rnk at google.com
Tue Dec 3 08:58:43 PST 2013
LGTM! It always bugged me that we had to build llc to run the clang test
suite. 'ninja clang && llvm-lit blah' should be enough for clang.
On Tue, Dec 3, 2013 at 8:52 AM, NAKAMURA Takumi <geek4civic at gmail.com>wrote:
> Hi ddunbar,
>
> Add --assertion-mode to llvm-config. It emits ON of OFF according to
> NDEBUG.
>
> Consider if I wanted to execute one test (w/o llc) from clean build tree.
>
> $ make FileCheck && make opt && make llc && bin/llvm-lit
> /path/to/Transforms/test.ll
>
> It would spend time to build llc, only to know assertion mode.
> Instead of llc, we can use light-weight llvm-config.
>
> $ make FileCheck && make opt && make llvm-config && bin/llvm-lit
> /path/to/Transforms/test.ll
>
> Although it is trivial to avoid llc in check-llvm, llvm-config could be
> applicable to check-clang, too.
> (Then llvm-config provides also targets_to_build.)
>
> This would be helpful if we implemented "Lit Ninja Runner" in future.
>
> http://llvm-reviews.chandlerc.com/D2320
>
> Files:
> llvm/test/CMakeLists.txt
> llvm/test/lit.cfg
> llvm/tools/llvm-config/llvm-config.cpp
>
> Index: llvm/test/CMakeLists.txt
> ===================================================================
> --- llvm/test/CMakeLists.txt
> +++ llvm/test/CMakeLists.txt
> @@ -15,6 +15,7 @@
> # Set the depends list as a variable so that it can grow conditionally.
> # NOTE: Sync the substitutions in test/lit.cfg when adding to this list.
> set(LLVM_TEST_DEPENDS
> + llvm-config
> UnitTests
> BugpointPasses
> LLVMHello
> Index: llvm/test/lit.cfg
> ===================================================================
> --- llvm/test/lit.cfg
> +++ llvm/test/lit.cfg
> @@ -305,18 +305,19 @@
> if config.host_triple == config.target_triple:
> config.available_features.add("native")
>
> -# llc knows whether he is compiled with -DNDEBUG.
> +# Ask llvm-config about assertion mode.
> import subprocess
> try:
> - llc_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'llc'),
> '-version'],
> - stdout = subprocess.PIPE)
> + llvm_config_cmd = subprocess.Popen(
> + [os.path.join(llvm_tools_dir, 'llvm-config'), '--assertion-mode'],
> + stdout = subprocess.PIPE)
> except OSError:
> - print("Could not find llc in " + llvm_tools_dir)
> + print("Could not find llvm-config in " + llvm_tools_dir)
> exit(42)
>
> -if re.search(r'with assertions', llc_cmd.stdout.read().decode('ascii')):
> +if re.search(r'ON', llvm_config_cmd.stdout.read().decode('ascii')):
> config.available_features.add('asserts')
> -llc_cmd.wait()
> +llvm_config_cmd.wait()
>
> if 'darwin' == sys.platform:
> try:
> Index: llvm/tools/llvm-config/llvm-config.cpp
> ===================================================================
> --- llvm/tools/llvm-config/llvm-config.cpp
> +++ llvm/tools/llvm-config/llvm-config.cpp
> @@ -154,6 +154,7 @@
> --targets-built List of all targets currently built.\n\
> --host-target Target triple used to configure LLVM.\n\
> --build-mode Print build mode of LLVM tree (e.g. Debug or
> Release).\n\
> + --assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
> Typical components:\n\
> all All LLVM libraries (default).\n\
> engine Either a native JIT or a bitcode interpreter.\n";
> @@ -306,6 +307,12 @@
> build_mode = CMAKE_CFG_INTDIR;
> #endif
> OS << build_mode << '\n';
> + } else if (Arg == "--assertion-mode") {
> +#if defined(NDEBUG)
> + OS << "OFF\n";
> +#else
> + OS << "ON\n";
> +#endif
> } else if (Arg == "--obj-root") {
> OS << LLVM_OBJ_ROOT << '\n';
> } else if (Arg == "--src-root") {
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131203/454896a0/attachment.html>
More information about the llvm-commits
mailing list