Skip to content

Commit 1729660

Browse files
committed
Revert "[Bazel][GN] Reuse the GN LLVM config file generation code"
This reverts commit e2ee8bf. This change is beyond my ability to integrate into Google's internal build configuration tonight.
1 parent 80fd9f3 commit 1729660

File tree

7 files changed

+580
-315
lines changed

7 files changed

+580
-315
lines changed

llvm/utils/gn/build/write_cmake_config.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ template("write_cmake_config") {
2828
assert(defined(invoker.values), "must set 'values' in $target_name")
2929

3030
action(target_name) {
31-
script = "//llvm/utils/write_cmake_config.py"
31+
script = "//llvm/utils/gn/build/write_cmake_config.py"
3232

3333
sources = [ invoker.input ]
3434
outputs = [ invoker.output ]

llvm/utils/write_cmake_config.py renamed to llvm/utils/gn/build/write_cmake_config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
r"""Emulates the bits of CMake's configure_file() function needed in LLVM.
33
44
The CMake build uses configure_file() for several things. This emulates that
5-
function for alternative build systems such as GN and Bazel. In both GN and
6-
Bazel, config file generation happens during the build rather than before it.
5+
function for the GN build. In the GN build, this runs at build time instead
6+
of at generator time.
77
88
Takes a list of KEY=VALUE pairs (where VALUE can be empty).
99
@@ -28,9 +28,8 @@
2828
#define FOO [...]
2929
/* #undef FOO */
3030
31-
To ensure that config file changes do not go unnoticed, this script fails if
32-
any of the KEY=VALUE arguments aren't needed for processing the input file, or
33-
if the input file references keys that weren't passed in.
31+
Fails if any of the KEY=VALUE arguments aren't needed for processing the
32+
input file, or if the input file references keys that weren't passed in.
3433
"""
3534

3635
import argparse

utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5-
load(":write_cmake_config.bzl", "write_cmake_config")
5+
load(":template_rule.bzl", "template_rule")
66
load(":tblgen.bzl", "gentbl")
7-
load(":config.bzl", "config_h_values", "llvm_config_h_values", "llvm_global_defines")
7+
load(":config.bzl", "llvm_config_defines")
88
load(":targets.bzl", "llvm_targets")
99
load(":enum_targets_gen.bzl", "enum_targets_gen")
1010
load(":binary_alias.bzl", "binary_alias")
@@ -101,30 +101,17 @@ genrule(
101101
cmd = "echo '#define LLVM_VERSION_INFO \"git\"' > $@",
102102
)
103103

104-
write_cmake_config(
104+
template_rule(
105105
name = "abi_breaking_h_gen",
106106
src = "include/llvm/Config/abi-breaking.h.cmake",
107107
out = "include/llvm/Config/abi-breaking.h",
108-
# Currently, in the Bazel build, we opt out of ABI breaking checks and
109-
# reverse iteration.
110-
values = [
111-
"LLVM_ENABLE_ABI_BREAKING_CHECKS=",
112-
"LLVM_ENABLE_REVERSE_ITERATION=",
113-
],
114-
)
115-
116-
write_cmake_config(
117-
name = "config_h_gen",
118-
src = "include/llvm/Config/config.h.cmake",
119-
out = "include/llvm/Config/config.h",
120-
values = config_h_values,
121-
)
108+
substitutions = {
109+
# Define to enable checks that alter the LLVM C++ ABI
110+
"#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0",
122111

123-
write_cmake_config(
124-
name = "llvm_config_h_gen",
125-
src = "include/llvm/Config/llvm-config.h.cmake",
126-
out = "include/llvm/Config/llvm-config.h",
127-
values = llvm_config_h_values,
112+
# Define to enable reverse iteration of unordered llvm containers
113+
"#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0",
114+
},
128115
)
129116

130117
# To enable diff testing out of tree
@@ -142,7 +129,7 @@ cc_library(
142129
"include/llvm/Config/llvm-config.h",
143130
],
144131
copts = llvm_copts,
145-
defines = llvm_global_defines,
132+
defines = llvm_config_defines,
146133
includes = ["include"],
147134
textual_hdrs = [
148135
"include/llvm/Config/AsmParsers.def",
@@ -2920,11 +2907,11 @@ cc_binary(
29202907
copts = llvm_copts,
29212908
stamp = 0,
29222909
deps = [
2910+
":Symbolize",
29232911
":BitReader",
29242912
":Core",
2925-
":Debuginfod",
29262913
":Support",
2927-
":Symbolize",
2914+
":Debuginfod",
29282915
],
29292916
)
29302917

@@ -4442,8 +4429,3 @@ cc_binary(
44424429
":Support",
44434430
],
44444431
)
4445-
4446-
py_binary(
4447-
name = "write_cmake_config",
4448-
srcs = ["utils/write_cmake_config.py"],
4449-
)

0 commit comments

Comments
 (0)