Skip to content

Commit

Permalink
[bazel] Add the remaining llvm-driver tools (llvm#87302)
Browse files Browse the repository at this point in the history
  • Loading branch information
rupprecht authored Apr 5, 2024
1 parent a1b2f0c commit 25afb77
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 291 deletions.
44 changes: 13 additions & 31 deletions utils/bazel/llvm-project-overlay/clang/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load(
"//:vars.bzl",
"LLVM_VERSION",
Expand All @@ -13,6 +12,7 @@ load(
load("//:workspace_root.bzl", "workspace_root")
load("//llvm:binary_alias.bzl", "binary_alias")
load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
load("//llvm:driver.bzl", "llvm_driver_cc_binary")
load("//llvm:tblgen.bzl", "gentbl")

package(
Expand Down Expand Up @@ -2320,20 +2320,9 @@ cc_binary(
],
)

expand_template(
name = "clang_main",
out = "clang-driver.cpp",
substitutions = {
"@TOOL_NAME@": "clang",
},
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
)

cc_library(
name = "clang-driver",
srcs = glob([
"tools/driver/*.cpp",
]) + ["clang-driver.cpp"],
srcs = glob(["tools/driver/*.cpp"]),
copts = [
# Disable stack frame size checks in the driver because
# clang::ensureStackAddressSpace allocates a large array on the stack.
Expand Down Expand Up @@ -2371,13 +2360,10 @@ cc_library(
],
)

cc_binary(
llvm_driver_cc_binary(
name = "clang",
srcs = [],
stamp = 0,
deps = [
":clang-driver",
],
deps = [":clang-driver"],
)

cc_binary(
Expand Down Expand Up @@ -2622,19 +2608,9 @@ gentbl(
td_srcs = ["//llvm:include/llvm/Option/OptParser.td"],
)

expand_template(
name = "clang-scan-deps-main",
out = "clang-scan-deps-driver.cpp",
substitutions = {
"@TOOL_NAME@": "clang_scan_deps",
},
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
)

cc_binary(
name = "clang-scan-deps",
srcs = glob(["tools/clang-scan-deps/*.cpp"]) + ["clang-scan-deps-driver.cpp"],
stamp = 0,
cc_library(
name = "clang-scan-deps-lib",
srcs = glob(["tools/clang-scan-deps/*.cpp"]),
deps = [
":ScanDepsTableGen",
":driver",
Expand All @@ -2646,6 +2622,12 @@ cc_binary(
],
)

llvm_driver_cc_binary(
name = "clang-scan-deps",
stamp = 0,
deps = [":clang-scan-deps-lib"],
)

cc_library(
name = "extract_api",
srcs = glob([
Expand Down
24 changes: 9 additions & 15 deletions utils/bazel/llvm-project-overlay/lld/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load(
"//:vars.bzl",
"LLVM_VERSION",
)
load("//llvm:binary_alias.bzl", "binary_alias")
load("//llvm:driver.bzl", "llvm_driver_cc_binary")
load("//llvm:tblgen.bzl", "gentbl")

package(
Expand Down Expand Up @@ -282,20 +282,9 @@ cc_library(
],
)

expand_template(
name = "lld_main",
out = "lld-driver.cpp",
substitutions = {
"@TOOL_NAME@": "lld",
},
template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
)

cc_binary(
name = "lld",
srcs = glob([
"tools/lld/*.cpp",
]) + ["lld-driver.cpp"],
cc_library(
name = "lld-lib",
srcs = glob(["tools/lld/*.cpp"]),
deps = [
":COFF",
":Common",
Expand All @@ -308,6 +297,11 @@ cc_binary(
],
)

llvm_driver_cc_binary(
name = "lld",
deps = [":lld-lib"],
)

# These are the required names for lld running under different environs.
#
# Unix/Linux require that the binary be named "ld.lld".
Expand Down
Loading

0 comments on commit 25afb77

Please sign in to comment.