Skip to content

Commit 25afb77

Browse files
authored
[bazel] Add the remaining llvm-driver tools (#87302)
1 parent a1b2f0c commit 25afb77

File tree

4 files changed

+185
-291
lines changed

4 files changed

+185
-291
lines changed

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

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

5-
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
65
load(
76
"//:vars.bzl",
87
"LLVM_VERSION",
@@ -13,6 +12,7 @@ load(
1312
load("//:workspace_root.bzl", "workspace_root")
1413
load("//llvm:binary_alias.bzl", "binary_alias")
1514
load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
15+
load("//llvm:driver.bzl", "llvm_driver_cc_binary")
1616
load("//llvm:tblgen.bzl", "gentbl")
1717

1818
package(
@@ -2320,20 +2320,9 @@ cc_binary(
23202320
],
23212321
)
23222322

2323-
expand_template(
2324-
name = "clang_main",
2325-
out = "clang-driver.cpp",
2326-
substitutions = {
2327-
"@TOOL_NAME@": "clang",
2328-
},
2329-
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
2330-
)
2331-
23322323
cc_library(
23332324
name = "clang-driver",
2334-
srcs = glob([
2335-
"tools/driver/*.cpp",
2336-
]) + ["clang-driver.cpp"],
2325+
srcs = glob(["tools/driver/*.cpp"]),
23372326
copts = [
23382327
# Disable stack frame size checks in the driver because
23392328
# clang::ensureStackAddressSpace allocates a large array on the stack.
@@ -2371,13 +2360,10 @@ cc_library(
23712360
],
23722361
)
23732362

2374-
cc_binary(
2363+
llvm_driver_cc_binary(
23752364
name = "clang",
2376-
srcs = [],
23772365
stamp = 0,
2378-
deps = [
2379-
":clang-driver",
2380-
],
2366+
deps = [":clang-driver"],
23812367
)
23822368

23832369
cc_binary(
@@ -2622,19 +2608,9 @@ gentbl(
26222608
td_srcs = ["//llvm:include/llvm/Option/OptParser.td"],
26232609
)
26242610

2625-
expand_template(
2626-
name = "clang-scan-deps-main",
2627-
out = "clang-scan-deps-driver.cpp",
2628-
substitutions = {
2629-
"@TOOL_NAME@": "clang_scan_deps",
2630-
},
2631-
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
2632-
)
2633-
2634-
cc_binary(
2635-
name = "clang-scan-deps",
2636-
srcs = glob(["tools/clang-scan-deps/*.cpp"]) + ["clang-scan-deps-driver.cpp"],
2637-
stamp = 0,
2611+
cc_library(
2612+
name = "clang-scan-deps-lib",
2613+
srcs = glob(["tools/clang-scan-deps/*.cpp"]),
26382614
deps = [
26392615
":ScanDepsTableGen",
26402616
":driver",
@@ -2646,6 +2622,12 @@ cc_binary(
26462622
],
26472623
)
26482624

2625+
llvm_driver_cc_binary(
2626+
name = "clang-scan-deps",
2627+
stamp = 0,
2628+
deps = [":clang-scan-deps-lib"],
2629+
)
2630+
26492631
cc_library(
26502632
name = "extract_api",
26512633
srcs = glob([

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

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

5-
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
65
load(
76
"//:vars.bzl",
87
"LLVM_VERSION",
98
)
109
load("//llvm:binary_alias.bzl", "binary_alias")
10+
load("//llvm:driver.bzl", "llvm_driver_cc_binary")
1111
load("//llvm:tblgen.bzl", "gentbl")
1212

1313
package(
@@ -282,20 +282,9 @@ cc_library(
282282
],
283283
)
284284

285-
expand_template(
286-
name = "lld_main",
287-
out = "lld-driver.cpp",
288-
substitutions = {
289-
"@TOOL_NAME@": "lld",
290-
},
291-
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
292-
)
293-
294-
cc_binary(
295-
name = "lld",
296-
srcs = glob([
297-
"tools/lld/*.cpp",
298-
]) + ["lld-driver.cpp"],
285+
cc_library(
286+
name = "lld-lib",
287+
srcs = glob(["tools/lld/*.cpp"]),
299288
deps = [
300289
":COFF",
301290
":Common",
@@ -308,6 +297,11 @@ cc_binary(
308297
],
309298
)
310299

300+
llvm_driver_cc_binary(
301+
name = "lld",
302+
deps = [":lld-lib"],
303+
)
304+
311305
# These are the required names for lld running under different environs.
312306
#
313307
# Unix/Linux require that the binary be named "ld.lld".

0 commit comments

Comments
 (0)