assert(defined(invoker.values), "must set 'values' in $target_name")
action(target_name) {
- script = "//llvm/utils/gn/build/write_cmake_config.py"
+ script = "//llvm/utils/write_cmake_config.py"
sources = [ invoker.input ]
outputs = [ invoker.output ]
r"""Emulates the bits of CMake's configure_file() function needed in LLVM.
The CMake build uses configure_file() for several things. This emulates that
-function for the GN build. In the GN build, this runs at build time instead
-of at generator time.
+function for alternative build systems such as GN and Bazel. In both GN and
+Bazel, config file generation happens during the build rather than before it.
Takes a list of KEY=VALUE pairs (where VALUE can be empty).
#define FOO [...]
/* #undef FOO */
-Fails if any of the KEY=VALUE arguments aren't needed for processing the
-input file, or if the input file references keys that weren't passed in.
+To ensure that config file changes do not go unnoticed, this script fails if
+any of the KEY=VALUE arguments aren't needed for processing the input file, or
+if the input file references keys that weren't passed in.
"""
import argparse
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-load(":template_rule.bzl", "template_rule")
+load(":write_cmake_config.bzl", "write_cmake_config")
load(":tblgen.bzl", "gentbl")
-load(":config.bzl", "llvm_config_defines")
+load(":config.bzl", "config_h_values", "llvm_config_h_values", "llvm_global_defines")
load(":targets.bzl", "llvm_targets")
load(":enum_targets_gen.bzl", "enum_targets_gen")
load(":binary_alias.bzl", "binary_alias")
cmd = "echo '#define LLVM_VERSION_INFO \"git\"' > $@",
)
-template_rule(
+write_cmake_config(
name = "abi_breaking_h_gen",
src = "include/llvm/Config/abi-breaking.h.cmake",
out = "include/llvm/Config/abi-breaking.h",
- substitutions = {
- # Define to enable checks that alter the LLVM C++ ABI
- "#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0",
+ # Currently, in the Bazel build, we opt out of ABI breaking checks and
+ # reverse iteration.
+ values = [
+ "LLVM_ENABLE_ABI_BREAKING_CHECKS=",
+ "LLVM_ENABLE_REVERSE_ITERATION=",
+ ],
+)
- # Define to enable reverse iteration of unordered llvm containers
- "#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0",
- },
+write_cmake_config(
+ name = "config_h_gen",
+ src = "include/llvm/Config/config.h.cmake",
+ out = "include/llvm/Config/config.h",
+ values = config_h_values,
+)
+
+write_cmake_config(
+ name = "llvm_config_h_gen",
+ src = "include/llvm/Config/llvm-config.h.cmake",
+ out = "include/llvm/Config/llvm-config.h",
+ values = llvm_config_h_values,
)
# To enable diff testing out of tree
"include/llvm/Config/llvm-config.h",
],
copts = llvm_copts,
- defines = llvm_config_defines,
+ defines = llvm_global_defines,
includes = ["include"],
textual_hdrs = [
"include/llvm/Config/AsmParsers.def",
copts = llvm_copts,
stamp = 0,
deps = [
- ":Symbolize",
":BitReader",
":Core",
- ":Support",
":Debuginfod",
+ ":Support",
+ ":Symbolize",
],
)
":Support",
],
)
+
+py_binary(
+ name = "write_cmake_config",
+ srcs = ["utils/write_cmake_config.py"],
+)
"""Defines variables that use selects to configure LLVM based on platform."""
-def native_arch_defines(arch, triple):
+def maybe_one(b):
+ """Return "1" if b is True, else empty string"""
+ return "1" if b else ""
+
+def maybe_value(b, val):
+ """Return val if b is True, else empty string"""
+ return val if b else ""
+
+def get_config_values(host_os, arch, triple):
+ """Return CMake variables for config.h
+
+ The variables for config.h are mostly LLVM-internal portability defines.
+ """
+ is_win = host_os == "win"
+ is_posix = not is_win
+ is_mac = host_os == "mac"
+ is_linux = host_os == "linux"
+
+ one_if_linux = maybe_one(is_linux)
+ one_if_posix = maybe_one(is_posix)
+ one_if_mac = maybe_one(is_mac)
+ one_if_win = maybe_one(is_win)
+
+ if is_win:
+ shlib_ext = ".dll"
+ elif is_mac:
+ shlib_ext = ".dylib"
+ else:
+ shlib_ext = ".so"
+
+ # Common variables.
return [
- r'LLVM_NATIVE_ARCH=\"{}\"'.format(arch),
+ "BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/",
+ "ENABLE_BACKTRACES=1",
+ "ENABLE_CRASH_OVERRIDES=1",
+ "HAVE_CRASHREPORTERCLIENT_H=",
+ "HAVE_DECL_FE_ALL_EXCEPT=1",
+ "HAVE_DECL_FE_INEXACT=1",
+ "LLVM_ENABLE_CRASH_DUMPS=",
+ "HAVE_ERRNO_H=1",
+ "HAVE_FCNTL_H=1",
+ "HAVE_FENV_H=1",
+ "HAVE_FFI_CALL=",
+ "HAVE_FFI_FFI_H=",
+ "HAVE_FFI_H=",
+ "HAVE_LIBPFM=",
+ "HAVE_LIBPSAPI=",
+ "HAVE_MALLCTL=",
+ "HAVE_SIGNAL_H=1",
+ "HAVE_STD_IS_TRIVIALLY_COPYABLE=1",
+ "HAVE_STRERROR=1",
+ "HAVE_SYS_STAT_H=1",
+ "HAVE_SYS_TYPES_H=1",
+ "HAVE_VALGRIND_VALGRIND_H=",
+ "HAVE__ALLOCA=",
+ "HAVE___ALLOCA=",
+ "HAVE___ASHLDI3=",
+ "HAVE___ASHRDI3=",
+ "HAVE___CHKSTK=",
+ "HAVE___CHKSTK_MS=",
+ "HAVE___CMPDI2=",
+ "HAVE___DIVDI3=",
+ "HAVE___FIXDFDI=",
+ "HAVE___FIXSFDI=",
+ "HAVE___FLOATDIDF=",
+ "HAVE___LSHRDI3=",
+ "HAVE___MAIN=",
+ "HAVE___MODDI3=",
+ "HAVE___UDIVDI3=",
+ "HAVE___UMODDI3=",
+ "HAVE____CHKSTK=",
+ "HAVE____CHKSTK_MS=",
+ "HOST_LINK_VERSION=",
+ "LIBPFM_HAS_FIELD_CYCLES=",
+ "LLVM_TARGET_TRIPLE_ENV=",
+ "LLVM_VERSION_INFO=",
+ "LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO=1",
+ "LLVM_WINDOWS_PREFER_FORWARD_SLASH=",
+ "PACKAGE_BUGREPORT=https://github.com/llvm/llvm-project/issues/",
+ "PACKAGE_NAME=LLVM",
+ "PACKAGE_STRING=LLVM git",
+ "PACKAGE_VERSION=git",
+ "PACKAGE_VENDOR=",
+ "RETSIGTYPE=void",
+ "LLVM_GISEL_COV_ENABLED=",
+ "LLVM_GISEL_COV_PREFIX=",
+
+ # TODO: These are configurable in gn, which means people might actually
+ # want other values here.
+ "HAVE_LIBEDIT=",
+ "LLVM_ENABLE_TERMINFO=",
+ "LLVM_ENABLE_LIBXML2=",
+ "HAVE_MALLINFO2=",
+
+ # Various Linux-only APIs.
+ "HAVE_FUTIMENS=" + one_if_linux,
+ "HAVE_LINK_H=" + one_if_linux,
+ "HAVE_LSEEK64=" + one_if_linux,
+ "HAVE_MALLINFO=" + one_if_linux,
+ "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=" + one_if_linux,
+
+ # Various Mac-only APIs.
+ "HAVE_CRASHREPORTER_INFO=" + one_if_mac,
+ "HAVE_DECL_ARC4RANDOM=" + one_if_mac,
+ "HAVE_DLADDR=" + one_if_mac,
+ "HAVE_MACH_MACH_H=" + one_if_mac,
+ "HAVE_MALLOC_MALLOC_H=" + one_if_mac,
+ "HAVE_MALLOC_ZONE_STATISTICS=" + one_if_mac,
+ "HAVE_PROC_PID_RUSAGE=" + one_if_mac,
+ "HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC=" + one_if_mac,
+ "HAVE_UNW_ADD_DYNAMIC_FDE=" + one_if_mac,
+
+ # Win-only APIs.
+ "HAVE_DECL_STRERROR_S=" + one_if_win,
+ "HAVE__CHSIZE_S=" + one_if_win,
+
+ # General Posix defines.
+ "HAVE_BACKTRACE=" + one_if_posix,
+ "HAVE_POSIX_SPAWN=" + one_if_posix,
+ "HAVE_PTHREAD_GETNAME_NP=" + one_if_posix,
+ "HAVE_DEREGISTER_FRAME=" + one_if_posix,
+ "HAVE_REGISTER_FRAME=" + one_if_posix,
+ "HAVE_DLFCN_H=" + one_if_posix,
+ "HAVE_DLOPEN=" + one_if_posix,
+ "HAVE_FUTIMES=" + one_if_posix,
+ "HAVE_GETPAGESIZE=" + one_if_posix,
+ "HAVE_GETRLIMIT=" + one_if_posix,
+ "HAVE_GETRUSAGE=" + one_if_posix,
+ "HAVE_ISATTY=" + one_if_posix,
+ "HAVE_LIBPTHREAD=" + one_if_posix,
+ "HAVE_PTHREAD_SETNAME_NP=" + one_if_posix,
+ "HAVE_PREAD=" + one_if_posix,
+ "HAVE_PTHREAD_H=" + one_if_posix,
+ "HAVE_PTHREAD_MUTEX_LOCK=" + one_if_posix,
+ "HAVE_PTHREAD_RWLOCK_INIT=" + one_if_posix,
+ "HAVE_SBRK=" + one_if_posix,
+ "HAVE_SETENV=" + one_if_posix,
+ "HAVE_SETRLIMIT=" + one_if_posix,
+ "HAVE_SIGALTSTACK=" + one_if_posix,
+ "HAVE_STRERROR_R=" + one_if_posix,
+ "HAVE_SYSCONF=" + one_if_posix,
+ "HAVE_SYS_IOCTL_H=" + one_if_posix,
+ "HAVE_SYS_MMAN_H=" + one_if_posix,
+ "HAVE_SYS_PARAM_H=" + one_if_posix,
+ "HAVE_SYS_RESOURCE_H=" + one_if_posix,
+ "HAVE_SYS_TIME_H=" + one_if_posix,
+ "HAVE_TERMIOS_H=" + one_if_posix,
+ "HAVE_UNISTD_H=" + one_if_posix,
+ "HAVE__UNWIND_BACKTRACE=" + one_if_posix,
+
+ # Miscellaneous corner case variables.
+ "stricmp=" + maybe_value(is_win, "_stricmp"),
+ "strdup=" + maybe_value(is_win, "_strdup"),
+ "LTDL_SHLIB_EXT=" + shlib_ext,
+ "LLVM_PLUGIN_EXT=" + shlib_ext,
+ "BACKTRACE_HEADER=" + maybe_value(is_posix, "execinfo.h"),
+
+ # This is oddly duplicated with llvm-config.h.
+ "LLVM_DEFAULT_TARGET_TRIPLE=" + triple,
+ "LLVM_SUPPORT_XCODE_SIGNPOSTS=",
+ ]
+
+def get_llvm_config_values(host_os, arch, triple):
+ is_win = host_os == "win"
+ is_posix = not is_win
+ return [
+ "LLVM_BUILD_LLVM_DYLIB=",
+ "LLVM_BUILD_SHARED_LIBS=",
+ "LLVM_DEFAULT_TARGET_TRIPLE=" + triple,
+ "LLVM_ENABLE_DUMP=",
+ "LLVM_FORCE_ENABLE_STATS=",
+ "LLVM_FORCE_USE_OLD_TOOLCHAIN=",
+ "LLVM_HAS_ATOMICS=1",
+ "LLVM_HAVE_TF_API=",
+ "LLVM_HOST_TRIPLE=" + triple,
+ "LLVM_NATIVE_ARCH=" + arch,
+ "LLVM_UNREACHABLE_OPTIMIZE=1",
+ "LLVM_USE_INTEL_JITEVENTS=",
+ "LLVM_USE_OPROFILE=",
+ "LLVM_USE_PERF=",
+ "LLVM_WITH_Z3=",
+
+ # TODO: Define this properly.
+ "LLVM_VERSION_MAJOR=15",
+ "LLVM_VERSION_MINOR=0",
+ "LLVM_VERSION_PATCH=0",
+ "PACKAGE_VERSION=15.0.0git",
+ "LLVM_ON_UNIX=" + maybe_one(is_posix),
+ "HAVE_SYSEXITS_H=" + maybe_one(is_posix),
"LLVM_NATIVE_ASMPARSER=LLVMInitialize{}AsmParser".format(arch),
"LLVM_NATIVE_ASMPRINTER=LLVMInitialize{}AsmPrinter".format(arch),
"LLVM_NATIVE_DISASSEMBLER=LLVMInitialize{}Disassembler".format(arch),
"LLVM_NATIVE_TARGETINFO=LLVMInitialize{}TargetInfo".format(arch),
"LLVM_NATIVE_TARGETMC=LLVMInitialize{}TargetMC".format(arch),
"LLVM_NATIVE_TARGETMCA=LLVMInitialize{}TargetMCA".format(arch),
- r'LLVM_HOST_TRIPLE=\"{}\"'.format(triple),
- r'LLVM_DEFAULT_TARGET_TRIPLE=\"{}\"'.format(triple),
+
+ # TODO: These are configurable in gn, which means people might actually
+ # want other values here.
+ "LLVM_ENABLE_THREADS=1",
+ "LLVM_HAVE_LIBXAR=",
+ "LLVM_ENABLE_ZLIB=",
+ "LLVM_ENABLE_CURL=",
+ "LLVM_ENABLE_DIA_SDK=",
]
-posix_defines = [
- "LLVM_ON_UNIX=1",
- "HAVE_BACKTRACE=1",
- "BACKTRACE_HEADER=<execinfo.h>",
- r'LTDL_SHLIB_EXT=\".so\"',
- r'LLVM_PLUGIN_EXT=\".so\"',
- "LLVM_ENABLE_THREADS=1",
- "HAVE_DEREGISTER_FRAME=1",
- "HAVE_LIBPTHREAD=1",
- "HAVE_PTHREAD_GETNAME_NP=1",
- "HAVE_PTHREAD_H=1",
- "HAVE_PTHREAD_SETNAME_NP=1",
- "HAVE_REGISTER_FRAME=1",
- "HAVE_SETENV_R=1",
- "HAVE_STRERROR_R=1",
- "HAVE_SYSEXITS_H=1",
- "HAVE_UNISTD_H=1",
-]
+# TODO: We should split out host vs. target here.
+# TODO: Figure out how to use select so that we can share this translation from
+# Bazel platform configuration to LLVM host and target selection.
+config_h_values = select({
+ "@bazel_tools//src/conditions:windows": get_config_values("win", "X86", "x86_64-pc-win32"),
+ "@bazel_tools//src/conditions:darwin_arm64": get_config_values("mac", "AArch64", "arm64-apple-darwin"),
+ "@bazel_tools//src/conditions:darwin_x86_64": get_config_values("mac", "X86", "x86_64-unknown-darwin"),
+ "@bazel_tools//src/conditions:linux_aarch64": get_config_values("linux", "AArch64", "aarch64-unknown-linux-gnu"),
+ "@bazel_tools//src/conditions:linux_ppc64le": get_config_values("linux", "PowerPC", "powerpc64le-unknown-linux-gnu"),
+ "@bazel_tools//src/conditions:linux_s390x": get_config_values("linux", "SystemZ", "systemz-unknown-linux_gnu"),
+ "//conditions:default": get_config_values("linux", "X86", "x86_64-unknown-linux-gnu"),
+})
-linux_defines = posix_defines + [
- "_GNU_SOURCE",
- "HAVE_LINK_H=1",
- "HAVE_LSEEK64=1",
- "HAVE_MALLINFO=1",
- "HAVE_SBRK=1",
- "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1",
-]
+llvm_config_h_values = select({
+ "@bazel_tools//src/conditions:windows": get_llvm_config_values("win", "X86", "x86_64-pc-win32"),
+ "@bazel_tools//src/conditions:darwin_arm64": get_llvm_config_values("mac", "AArch64", "arm64-apple-darwin"),
+ "@bazel_tools//src/conditions:darwin_x86_64": get_llvm_config_values("mac", "X86", "x86_64-unknown-darwin"),
+ "@bazel_tools//src/conditions:linux_aarch64": get_llvm_config_values("linux", "AArch64", "aarch64-unknown-linux-gnu"),
+ "@bazel_tools//src/conditions:linux_ppc64le": get_llvm_config_values("linux", "PowerPC", "powerpc64le-unknown-linux-gnu"),
+ "@bazel_tools//src/conditions:linux_s390x": get_llvm_config_values("linux", "SystemZ", "systemz-unknown-linux_gnu"),
+ "//conditions:default": get_llvm_config_values("linux", "X86", "x86_64-unknown-linux-gnu"),
+})
-macos_defines = posix_defines + [
- "HAVE_MACH_MACH_H=1",
- "HAVE_MALLOC_MALLOC_H=1",
- "HAVE_MALLOC_ZONE_STATISTICS=1",
- "HAVE_PROC_PID_RUSAGE=1",
- "HAVE_UNW_ADD_DYNAMIC_FDE=1",
+linux_defines = [
+ "_GNU_SOURCE",
]
win32_defines = [
"_SCL_SECURE_NO_WARNINGS",
"UNICODE",
"_UNICODE",
-
- # LLVM features
- r'LTDL_SHLIB_EXT=\".dll\"',
- r'LLVM_PLUGIN_EXT=\".dll\"',
]
# TODO: We should switch to platforms-based config settings to make this easier
# to express.
os_defines = select({
"@bazel_tools//src/conditions:windows": win32_defines,
- "@bazel_tools//src/conditions:darwin": macos_defines,
- "@bazel_tools//src/conditions:freebsd": posix_defines,
+ "@bazel_tools//src/conditions:darwin": [],
+ "@bazel_tools//src/conditions:freebsd": [],
"//conditions:default": linux_defines,
})
-# TODO: We should split out host vs. target here.
-llvm_config_defines = os_defines + select({
- "@bazel_tools//src/conditions:windows": native_arch_defines("X86", "x86_64-pc-win32"),
- "@bazel_tools//src/conditions:darwin_arm64": native_arch_defines("AArch64", "arm64-apple-darwin"),
- "@bazel_tools//src/conditions:darwin_x86_64": native_arch_defines("X86", "x86_64-unknown-darwin"),
- "@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"),
- "@bazel_tools//src/conditions:linux_ppc64le": native_arch_defines("PowerPC", "powerpc64le-unknown-linux-gnu"),
- "@bazel_tools//src/conditions:linux_s390x": native_arch_defines("SystemZ", "systemz-unknown-linux_gnu"),
- "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"),
-}) + [
- # These shouldn't be needed by the C++11 standard, but are for some
- # platforms (e.g. glibc < 2.18. See
- # https://sourceware.org/bugzilla/show_bug.cgi?id=15366). These are also
- # included unconditionally in the CMake build:
- # https://github.com/llvm/llvm-project/blob/cd0dd8ece8e/llvm/cmake/modules/HandleLLVMOptions.cmake#L907-L909
+# These shouldn't be needed by the C++11 standard, but are for some
+# platforms (e.g. glibc < 2.18. See
+# https://sourceware.org/bugzilla/show_bug.cgi?id=15366). These are also
+# included unconditionally in the CMake build:
+# https://github.com/llvm/llvm-project/blob/cd0dd8ece8e/llvm/cmake/modules/HandleLLVMOptions.cmake#L907-L909
+llvm_global_defines = os_defines + [
"__STDC_LIMIT_MACROS",
"__STDC_CONSTANT_MACROS",
"__STDC_FORMAT_MACROS",
+++ /dev/null
-/*===------- llvm/Config/config.h - llvm configuration ------------*- C -*-===*/
-/* */
-/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */
-/* Exceptions. */
-/* See https://llvm.org/LICENSE.txt for license information. */
-/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
-/* */
-/*===----------------------------------------------------------------------===*/
-
-/* This is a manual port of config.h.cmake for the symbols that do not change
- based on platform. Those that do change should not be defined here and
- instead use Bazel cc_library defines. Some attempt has been made to extract
- such symbols that do vary based on platform (for the platforms we care about)
- into Bazel defines, but it is by no means complete, so if you see something
- that looks wrong, it probably is. */
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-// Include this header only under the llvm source tree.
-// This is a private header.
-
-/* Exported configuration */
-#include "llvm/Config/llvm-config.h"
-
-/* Bug report URL. */
-#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/"
-
-/* Define to 1 to enable backtraces, and to 0 otherwise. */
-#define ENABLE_BACKTRACES 1
-
-/* Define to 1 to enable crash overrides, and to 0 otherwise. */
-#define ENABLE_CRASH_OVERRIDES 1
-
-/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */
-#define LLVM_ENABLE_CRASH_DUMPS 0
-
-/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer
- backslashes. */
-#define LLVM_WINDOWS_PREFER_FORWARD_SLASH 0
-
-/* Define to 1 if you have the `backtrace' function. */
-/* HAVE_BACKTRACE defined in Bazel */
-
-/* BACKTRACE_HEADER defined in Bazel */
-
-/* Define to 1 if you have the <CrashReporterClient.h> header file. */
-/* HAVE_CRASHREPORTERCLIENT_H defined in Bazel */
-
-/* can use __crashreporter_info__ */
-/* HAVE_CRASHREPORTER_INFO defined in Bazel */
-
-/* Define to 1 if you have the declaration of `arc4random', and to 0 if you
- don't. */
-#define HAVE_DECL_ARC4RANDOM 0
-
-/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you
- don't. */
-#define HAVE_DECL_FE_ALL_EXCEPT 1
-
-/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you
- don't. */
-#define HAVE_DECL_FE_INEXACT 1
-
-/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
- don't. */
-#define HAVE_DECL_STRERROR_S 0
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define if dlopen() is available on this platform. */
-#define HAVE_DLOPEN 1
-
-/* Define if dladdr() is available on this platform. */
-/* #undef HAVE_DLADDR */
-
-/* Define to 1 if we can register EH frames on this platform. */
-/* HAVE_REGISTER_FRAME defined in Bazel*/
-
-/* Define to 1 if we can deregister EH frames on this platform. */
-/* HAVE_DEREGISTER_FRAME defined in Bazel*/
-
-/* Define if __unw_add_dynamic_fde() is available on this platform. */
-/* HAVE_UNW_ADD_DYNAMIC_FDE defined in Bazel */
-
-/* Define to 1 if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the <fenv.h> header file. */
-#define HAVE_FENV_H 1
-
-/* Define if libffi is available on this platform. */
-/* #undef HAVE_FFI_CALL */
-
-/* Define to 1 if you have the <ffi/ffi.h> header file. */
-/* #undef HAVE_FFI_FFI_H */
-
-/* Define to 1 if you have the <ffi.h> header file. */
-/* #undef HAVE_FFI_H */
-
-/* Define to 1 if you have the `futimens' function. */
-#define HAVE_FUTIMENS 1
-
-/* Define to 1 if you have the `futimes' function. */
-#define HAVE_FUTIMES 1
-
-/* Define to 1 if you have the `getpagesize' function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define to 1 if you have the `getrlimit' function. */
-#define HAVE_GETRLIMIT 1
-
-/* Define to 1 if you have the `getrusage' function. */
-#define HAVE_GETRUSAGE 1
-
-/* Define to 1 if you have the `isatty' function. */
-#define HAVE_ISATTY 1
-
-/* Define to 1 if you have the `edit' library (-ledit). */
-/* #undef HAVE_LIBEDIT */
-
-/* Define to 1 if you have the `pfm' library (-lpfm). */
-/* #undef HAVE_LIBPFM */
-
-/* Define to 1 if the `perf_branch_entry' struct has field cycles. */
-/* #undef LIBPFM_HAS_FIELD_CYCLES */
-
-/* Define to 1 if you have the `psapi' library (-lpsapi). */
-/* #undef HAVE_LIBPSAPI */
-
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#define HAVE_LIBPTHREAD 1
-
-/* Define to 1 if you have the `pthread_getname_np' function. */
-#define HAVE_PTHREAD_GETNAME_NP 1
-
-/* Define to 1 if you have the `pthread_setname_np' function. */
-#define HAVE_PTHREAD_SETNAME_NP 1
-
-/* Define to 1 if you have the <link.h> header file. */
-/* HAVE_LINK_H defined in Bazel */
-
-/* Define to 1 if you have the `lseek64' function. */
-/* HAVE_LSEEK64 defined in Bazel */
-
-/* Define to 1 if you have the <mach/mach.h> header file. */
-/* HAVE_MACH_MACH_H defined in Bazel */
-
-/* Define to 1 if you have the `mallctl' function. */
-/* #undef HAVE_MALLCTL */
-
-/* Define to 1 if you have the `mallinfo' function. */
-/* HAVE_MALLINFO defined in Bazel */
-
-/* Define to 1 if you have the <malloc/malloc.h> header file. */
-/* HAVE_MALLOC_MALLOC_H defined in Bazel */
-
-/* Define to 1 if you have the `malloc_zone_statistics' function. */
-/* HAVE_MALLOC_ZONE_STATISTICS defined in Bazel */
-
-/* Define to 1 if you have the `posix_spawn' function. */
-#define HAVE_POSIX_SPAWN 1
-
-/* Define to 1 if you have the `pread' function. */
-#define HAVE_PREAD 1
-
-/* Define to 1 if you have the <pthread.h> header file. */
-/* HAVE_PTHREAD_H defined in Bazel */
-
-/* Have pthread_mutex_lock */
-#define HAVE_PTHREAD_MUTEX_LOCK 1
-
-/* Have pthread_rwlock_init */
-#define HAVE_PTHREAD_RWLOCK_INIT 1
-
-/* Define to 1 if you have the `sbrk' function. */
-/* HAVE_SBRK defined in Bazel */
-
-/* Define to 1 if you have the `setenv' function. */
-/* HAVE_SETENV defined in Bazel */
-
-/* Define to 1 if you have the `setrlimit' function. */
-#define HAVE_SETRLIMIT 1
-
-/* Define to 1 if you have the `sigaltstack' function. */
-#define HAVE_SIGALTSTACK 1
-
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the `strerror_r' function. */
-/* HAVE_STRERROR_R defined in Bazel */
-
-/* Define to 1 if you have the `sysconf' function. */
-#define HAVE_SYSCONF 1
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define to 1 if you have the <sys/mman.h> header file. */
-#define HAVE_SYS_MMAN_H 1
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if stat struct has st_mtimespec member .*/
-/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */
-
-/* Define to 1 if stat struct has st_mtim member. */
-/* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC defined in Bazel */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define if the setupterm() function is supported this platform. */
-/* LLVM_ENABLE_TERMINFO defined in Bazel */
-
-/* Define to 1 if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* HAVE_UNISTD_H defined in Bazel */
-
-/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
-/* #undef HAVE_VALGRIND_VALGRIND_H */
-
-/* Have host's _alloca */
-/* #undef HAVE__ALLOCA */
-
-/* Define to 1 if you have the `_chsize_s' function. */
-/* #undef HAVE__CHSIZE_S */
-
-/* Define to 1 if you have the `_Unwind_Backtrace' function. */
-#define HAVE__UNWIND_BACKTRACE 1
-
-/* Have host's __alloca */
-/* #undef HAVE___ALLOCA */
-
-/* Have host's __ashldi3 */
-/* #undef HAVE___ASHLDI3 */
-
-/* Have host's __ashrdi3 */
-/* #undef HAVE___ASHRDI3 */
-
-/* Have host's __chkstk */
-/* #undef HAVE___CHKSTK */
-
-/* Have host's __chkstk_ms */
-/* #undef HAVE___CHKSTK_MS */
-
-/* Have host's __cmpdi2 */
-/* #undef HAVE___CMPDI2 */
-
-/* Have host's __divdi3 */
-/* #undef HAVE___DIVDI3 */
-
-/* Have host's __fixdfdi */
-/* #undef HAVE___FIXDFDI */
-
-/* Have host's __fixsfdi */
-/* #undef HAVE___FIXSFDI */
-
-/* Have host's __floatdidf */
-/* #undef HAVE___FLOATDIDF */
-
-/* Have host's __lshrdi3 */
-/* #undef HAVE___LSHRDI3 */
-
-/* Have host's __main */
-/* #undef HAVE___MAIN */
-
-/* Have host's __moddi3 */
-/* #undef HAVE___MODDI3 */
-
-/* Have host's __udivdi3 */
-/* #undef HAVE___UDIVDI3 */
-
-/* Have host's __umoddi3 */
-/* #undef HAVE___UMODDI3 */
-
-/* Have host's ___chkstk */
-/* #undef HAVE____CHKSTK */
-
-/* Have host's ___chkstk_ms */
-/* #undef HAVE____CHKSTK_MS */
-
-/* Linker version detected at compile time. */
-/* #undef HOST_LINK_VERSION */
-
-/* Target triple LLVM will generate code for by default */
-/* Doesn't use `cmakedefine` because it is allowed to be empty. */
-/* LLVM_DEFAULT_TARGET_TRIPLE defined in Bazel */
-
-/* Define if zlib compression is available */
-/* LLVM_ENABLE_ZLIB defined in Bazel */
-
-/* Define if overriding target triple is enabled */
-/* #undef LLVM_TARGET_TRIPLE_ENV */
-
-/* LLVM version information */
-/* #undef LLVM_VERSION_INFO */
-
-/* Whether tools show host and target info when invoked with --version */
-#define LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO 1
-
-/* Define if libxml2 is supported on this platform. */
-/* #undef LLVM_ENABLE_LIBXML2 */
-
-/* Define to the extension used for shared libraries, say, ".so". */
-/* LTDL_SHLIB_EXT defined in Bazel */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "LLVM"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING PACKAGE_NAME " " LLVM_VERSION_STRING
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION LLVM_VERSION_STRING
-
-/* Define to the vendor of this package. */
-/* #undef PACKAGE_VENDOR */
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* Define if std::is_trivially_copyable is supported */
-#define HAVE_STD_IS_TRIVIALLY_COPYABLE 1
-
-/* Define to a function implementing stricmp */
-/* stricmp defined conditionally below. */
-
-/* Define to a function implementing strdup */
-/* strdup defined conditionally below. */
-
-/* Whether GlobalISel rule coverage is being collected */
-#define LLVM_GISEL_COV_ENABLED 0
-
-/* Define to the default GlobalISel coverage file prefix */
-/* #undef LLVM_GISEL_COV_PREFIX */
-
-/* Whether Timers signpost passes in Xcode Instruments */
-#define LLVM_SUPPORT_XCODE_SIGNPOSTS 0
-
-/* HAVE_PROC_PID_RUSAGE defined in Bazel */
-
-/* Directly provide definitions here behind platform preprocessor definitions.
- * The preprocessor conditions are sufficient to handle all of the configuration
- * on platforms targeted by Bazel, and defining these here more faithfully
- * matches how the users of this header expect things to work with CMake.
- * FIXME: We should consider moving other platform defines to use this technique
- * as well.
- */
-
-#ifdef _WIN32
-#define stricmp _stricmp
-#define strdup _strdup
-#endif
-
-#endif
+++ /dev/null
-/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/
-/* */
-/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */
-/* Exceptions. */
-/* See https://llvm.org/LICENSE.txt for license information. */
-/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
-/* */
-/*===----------------------------------------------------------------------===*/
-
-/* This is a manual port of config.h.cmake for the symbols that do not change
- based on platform. Those that do change should not be defined here and
- instead use Bazel cc_library defines. Some attempt has been made to extract
- such symbols that do vary based on platform (for the platforms we care about)
- into Bazel defines, but it is by no means complete, so if you see something
- that looks wrong, it probably is. */
-
-
-/* This file enumerates variables from the LLVM configuration so that they
- can be in exported headers and won't override package specific directives.
- This is a C header that can be included in the llvm-c headers. */
-
-#ifndef LLVM_CONFIG_H
-#define LLVM_CONFIG_H
-
-/* Define if LLVM_ENABLE_DUMP is enabled */
-/* #undef LLVM_ENABLE_DUMP */
-
-/* Target triple LLVM will generate code for by default */
-/* LLVM_DEFAULT_TARGET_TRIPLE defined in Bazel */
-
-/* Define if threads enabled */
-#define LLVM_ENABLE_THREADS 1
-
-/* Has gcc/MSVC atomic intrinsics */
-#define LLVM_HAS_ATOMICS 1
-
-/* Host triple LLVM will be executed on */
-/* LLVM_HOST_TRIPLE defined in Bazel */
-
-/* LLVM architecture name for the native architecture, if available */
-/* LLVM_NATIVE_ARCH defined in Bazel */
-
-/* LLVM name for the native AsmParser init function, if available */
-/* LLVM_NATIVE_ASMPARSER defined in Bazel */
-
-/* LLVM name for the native AsmPrinter init function, if available */
-/* LLVM_NATIVE_ASMPRINTER defined in Bazel */
-
-/* LLVM name for the native Disassembler init function, if available */
-/* LLVM_NATIVE_DISASSEMBLER defined in Bazel */
-
-/* LLVM name for the native Target init function, if available */
-/* LLVM_NATIVE_TARGET defined in Bazel */
-
-/* LLVM name for the native TargetInfo init function, if available */
-/* LLVM_NATIVE_TARGETINFO defined in Bazel */
-
-/* LLVM name for the native target MC init function, if available */
-/* LLVM_NATIVE_TARGETMC defined in Bazel */
-
-/* LLVM name for the native target MCA init function, if available */
-/* LLVM_NATIVE_TARGETMCA defined in Bazel */
-
-/* Define if this is Unixish platform */
-/* LLVM_ON_UNIX defined in Bazel */
-
-/* Define if we have the Intel JIT API runtime support library */
-#define LLVM_USE_INTEL_JITEVENTS 0
-
-/* Define if we have the oprofile JIT-support library */
-#define LLVM_USE_OPROFILE 0
-
-/* Define if we have the perf JIT-support library */
-#define LLVM_USE_PERF 0
-
-/* Major version of the LLVM API */
-#define LLVM_VERSION_MAJOR 15
-
-/* Minor version of the LLVM API */
-#define LLVM_VERSION_MINOR 0
-
-/* Patch version of the LLVM API */
-#define LLVM_VERSION_PATCH 0
-
-/* LLVM version string */
-#define LLVM_VERSION_STRING "15.0.0git"
-
-/* Whether LLVM records statistics for use with GetStatistics(),
- * PrintStatistics() or PrintStatisticsJSON()
- */
-#define LLVM_FORCE_ENABLE_STATS 0
-
-/* Define if we have z3 and want to build it */
-/* #undef LLVM_WITH_Z3 */
-
-/* Define if we have curl and want to use it */
-/* #undef LLVM_ENABLE_CURL */
-
-/* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
-/* #undef LLVM_HAVE_TF_API */
-
-/* Define if LLVM was built with a dependency to the tensorflow compiler */
-/* #undef LLVM_HAVE_TF_AOT */
-
-/* Define to 1 if you have the <sysexits.h> header file. */
-/* HAVE_SYSEXITS_H defined in Bazel */
-
-/* Define if the xar_open() function is supported this platform. */
-/* #undef HAVE_LIBXAR */
-
-/* Define if building libLLVM shared library */
-/* #undef LLVM_BUILD_LLVM_DYLIB */
-
-/* Define if building LLVM with BUILD_SHARED_LIBS */
-/* #undef LLVM_BUILD_SHARED_LIBS */
-
-/* Define if building LLVM with LLVM_FORCE_USE_OLD_TOOLCHAIN_LIBS */
-/* #undef LLVM_FORCE_USE_OLD_TOOLCHAIN ${LLVM_FORCE_USE_OLD_TOOLCHAIN} */
-
-/* Define if llvm_unreachable should be optimized with undefined behavior
- * in non assert builds */
-#define LLVM_UNREACHABLE_OPTIMIZE 1
-
-/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */
-#define LLVM_ENABLE_DIA_SDK 0
-
-#endif
--- /dev/null
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# Rule for transforming CMake config files.
+#
+# Typical usage:
+# load("/tools/build_rules/write_cmake_config", "write_cmake_config")
+# write_cmake_config(
+# name = "ExpandMyTemplate",
+# src = "my.template",
+# out = "my.txt",
+# substitutions = {
+# "$VAR1": "foo",
+# "$VAR2": "bar",
+# }
+# )
+#
+# Args:
+# name: The name of the rule.
+# template: The template file to expand
+# out: The destination of the expanded file
+# substitutions: A dictionary mapping strings to their substitutions
+
+def write_cmake_config_impl(ctx):
+ args = ctx.actions.args()
+ args.add(ctx.files._script[0])
+ args.add(ctx.file.src)
+ args.add_all(ctx.attr.values)
+ args.add("-o", ctx.outputs.out)
+ ctx.actions.run(
+ mnemonic = "WriteCMakeConfig",
+ executable = "python3",
+ inputs = ctx.files._script + [ ctx.file.src ],
+ outputs = [ctx.outputs.out],
+ arguments = [args],
+ )
+
+write_cmake_config = rule(
+ attrs = {
+ "src": attr.label(
+ mandatory = True,
+ allow_single_file = True,
+ ),
+ "out": attr.output(mandatory = True),
+ "values": attr.string_list(mandatory = True),
+ "_script": attr.label(default="//llvm:write_cmake_config")
+ },
+ # output_to_genfiles is required for header files.
+ output_to_genfiles = True,
+ implementation = write_cmake_config_impl,
+)