Skip to content

[bazel] Add the remaining llvm-driver tools #87302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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