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:
--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";
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") {