mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 13:40:11 +01:00
Add cc rule wrappers for cc_env (#5277)
Rules executed by bazel don't necessarily have the right environment to find the symbolizer, which was the intent of `cc_env` setting `LLVM_SYMBOLIZER_PATH`. So far, this has kind of been a case-by-case fix, but every so often I'm trying to debug a crash in a test that doesn't provide it. Rather continuing down this route, instead add drop-in wrappers for cc rules so that it's hard to forget. Note `bazel/cc_rules` is intended to mirror `bazel/carbon_rules` and `bazel/cc_toolchains`, rather than `@rules_cc`. AFAICT there isn't a great way to add this as a default for the `bazel run` environment. It's not typically going to be set on its own, forwarding `$PATH` would be too broad, and the [action `env_sets`](https://bazel.build/docs/cc-toolchain-config-reference#using-action-config) I think are not quite what we need (I think those don't include output execution, only compilation).
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Empty; only defs.bzl is needed.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
"""Wraps standard cc rules with the `cc_env` addition.
|
||||
|
||||
These should generally be used in place of `@rules_cc`.
|
||||
"""
|
||||
|
||||
load(
|
||||
"@rules_cc//cc:defs.bzl",
|
||||
actual_cc_binary = "cc_binary",
|
||||
actual_cc_library = "cc_library",
|
||||
actual_cc_test = "cc_test",
|
||||
)
|
||||
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
||||
|
||||
# Expose cc_library directly, for consistency.
|
||||
cc_library = actual_cc_library
|
||||
|
||||
def cc_binary(env = {}, **kwargs):
|
||||
"""Wraps `cc_binary`, adding `cc_env`."""
|
||||
actual_cc_binary(
|
||||
env = cc_env() | env,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def cc_test(env = {}, **kwargs):
|
||||
"""Wraps `cc_binary`, adding `cc_env`."""
|
||||
actual_cc_test(
|
||||
env = cc_env() | env,
|
||||
**kwargs
|
||||
)
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
config_setting(
|
||||
name = "is_linux",
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/version:rules.bzl", "expand_version_build_info")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
# Trivial, single-file testing libraries. More complex libraries should get
|
||||
# their own directory.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
load("rules.bzl", "file_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -8,8 +8,7 @@ file_test uses the tests_as_input_file rule to transform test dependencies into
|
||||
a file which can be accessed as a list. This avoids long argument parsing.
|
||||
"""
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_test")
|
||||
load("//bazel/manifest:defs.bzl", "manifest", "manifest_as_cpp")
|
||||
|
||||
def file_test(
|
||||
@@ -58,7 +57,6 @@ def file_test(
|
||||
deps = deps,
|
||||
data = [":" + tests_file] + tests + data,
|
||||
args = args,
|
||||
env = cc_env(),
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
@@ -75,6 +73,5 @@ def file_test(
|
||||
deps = deps + ["//testing/file_test:manifest_impl"],
|
||||
data = tests + data,
|
||||
args = args,
|
||||
env = cc_env(),
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
"""Rules for building fuzz tests."""
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_test")
|
||||
|
||||
def _cc_fuzz_test(corpus, args, data, **kwargs):
|
||||
"""Generates a single test target.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
load("llvm_tools.bzl", "LLVM_MAIN_TOOLS", "generate_llvm_tools_def")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/manifest:defs.bzl", "manifest")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
@@ -39,7 +38,6 @@ cc_test(
|
||||
name = "clang_runner_test",
|
||||
size = "small",
|
||||
srcs = ["clang_runner_test.cpp"],
|
||||
env = cc_env(),
|
||||
deps = [
|
||||
":clang_runner",
|
||||
"//common:all_llvm_targets",
|
||||
@@ -155,7 +153,6 @@ cc_test(
|
||||
name = "driver_test",
|
||||
size = "small",
|
||||
srcs = ["driver_test.cpp"],
|
||||
env = cc_env(),
|
||||
deps = [
|
||||
":driver",
|
||||
"//common:all_llvm_targets",
|
||||
@@ -208,7 +205,6 @@ cc_test(
|
||||
name = "lld_runner_test",
|
||||
size = "small",
|
||||
srcs = ["lld_runner_test.cpp"],
|
||||
env = cc_env(),
|
||||
deps = [
|
||||
":clang_runner",
|
||||
":lld_runner",
|
||||
@@ -248,7 +244,6 @@ cc_test(
|
||||
name = "llvm_runner_test",
|
||||
size = "small",
|
||||
srcs = ["llvm_runner_test.cpp"],
|
||||
env = cc_env(),
|
||||
deps = [
|
||||
":llvm_runner",
|
||||
"//common:all_llvm_targets",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ load(
|
||||
"@llvm-project//:vars.bzl",
|
||||
"LLVM_VERSION_MAJOR",
|
||||
)
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("@rules_python//python:defs.bzl", "py_test")
|
||||
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/manifest:defs.bzl", "manifest")
|
||||
load("//toolchain/base:llvm_tools.bzl", "LLVM_MAIN_TOOLS", "LLVM_TOOL_ALIASES")
|
||||
load("install_filegroups.bzl", "install_filegroup", "install_symlink", "install_target", "make_install_filegroups")
|
||||
@@ -104,7 +103,6 @@ cc_test(
|
||||
cc_binary(
|
||||
name = "carbon-busybox",
|
||||
srcs = ["busybox_main.cpp"],
|
||||
env = cc_env(),
|
||||
deps = [
|
||||
":busybox_info",
|
||||
":install_paths",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/manifest:defs.bzl", "manifest")
|
||||
load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
|
||||
load("//testing/file_test:rules.bzl", "file_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Exceptions. See /LICENSE for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||
|
||||
package(default_visibility = ["//bazel/check_deps:__pkg__"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user