Skip to content

Commit

Permalink
bazel: remove rules_cc (envoyproxy#19760)
Browse files Browse the repository at this point in the history
The plans for bazel to move to rules_cc have been postponed without any
communication. There's no value to us in using this right now, but it
will be trivial to re-adopt in the future if needed. But it has the
downside of using a fork of bazel's crosstool, that has to be updated
independently of bazel, which doesn't always happen as improvements are
made.

More details: bazelbuild/rules_cc#86 bazelbuild/bazel#14150

This also required a `--host_action_env` addition to mirror the variables we
pass through to actions in general. This is required because C++ toolchain
setup which discovers linkers in the cc configuration which uses PATH directly,
but then host actions didn't use PATH because of
--incompatible_strict_action_env, so gcc couldn't discover the path of lld even
though `-fuse-ld=lld` was passed.

Fixes envoyproxy#16608

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
  • Loading branch information
keith authored Apr 27, 2022
1 parent 0be448e commit 1edd65f
Show file tree
Hide file tree
Showing 35 changed files with 17 additions and 82 deletions.
8 changes: 4 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ build --tool_java_runtime_version=remotejdk_11
build --platform_mappings=bazel/platform_mappings

# Pass PATH, CC, CXX and LLVM_CONFIG variables from the environment.
build --action_env=CC
build --action_env=CXX
build --action_env=LLVM_CONFIG
build --action_env=PATH
build --action_env=CC --host_action_env=CC
build --action_env=CXX --host_action_env=CXX
build --action_env=LLVM_CONFIG --host_action_env=LLVM_CONFIG
build --action_env=PATH --host_action_env=PATH

build --enable_platform_specific_config

Expand Down
3 changes: 1 addition & 2 deletions api/bazel/api_build_system.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@com_envoyproxy_protoc_gen_validate//bazel:pgv_proto_library.bzl", "pgv_cc_proto_library")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("@com_google_protobuf//:protobuf.bzl", _py_proto_library = "py_proto_library")
Expand Down Expand Up @@ -143,7 +142,7 @@ def api_cc_py_proto_library(
_api_cc_grpc_library(name = cc_grpc_name, proto = relative_name, deps = cc_proto_deps)

def api_cc_test(name, **kwargs):
cc_test(
native.cc_test(
name = name,
**kwargs
)
Expand Down
1 change: 0 additions & 1 deletion bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load("//bazel:envoy_build_system.bzl", "envoy_package")
load("//bazel:envoy_internal.bzl", "envoy_select_force_libcpp")
load("//bazel:utils.bzl", "json_data")
Expand Down
3 changes: 0 additions & 3 deletions bazel/dependency_imports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ load("@upb//bazel:workspace_deps.bzl", "upb_deps")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_dependencies")
load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies", "rules_cc_toolchains")
load("@base_pip3//:requirements.bzl", pip_dependencies = "install_deps")
load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")

Expand Down Expand Up @@ -43,8 +42,6 @@ def envoy_dependency_imports(go_version = GO_VERSION):
oss_fuzz = True,
honggfuzz = False,
)
rules_cc_dependencies()
rules_cc_toolchains()
emscripten_deps()

# These dependencies, like most of the Go in this repository, exist only for the API.
Expand Down
4 changes: 1 addition & 3 deletions bazel/envoy_binary.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy binary targets
load(
Expand Down Expand Up @@ -30,7 +28,7 @@ def envoy_cc_binary(
linkopts = linkopts + _envoy_stamped_linkopts()
deps = deps + _envoy_stamped_deps()
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps] + envoy_stdlib_deps()
cc_binary(
native.cc_binary(
name = name,
srcs = srcs,
data = data,
Expand Down
10 changes: 4 additions & 6 deletions bazel/envoy_library.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy library targets
load(
Expand Down Expand Up @@ -40,7 +38,7 @@ def tcmalloc_external_deps(repository):
# all envoy targets pass through an envoy-declared Starlark function where they can be modified
# before being passed to a native bazel function.
def envoy_basic_cc_library(name, deps = [], external_deps = [], **kargs):
cc_library(
native.cc_library(
name = name,
deps = deps + [envoy_external_dep_path(dep) for dep in external_deps],
**kargs
Expand All @@ -62,7 +60,7 @@ def envoy_cc_extension(
visibility = visibility,
**kwargs
)
cc_library(
native.cc_library(
name = ext_name,
tags = tags,
deps = select({
Expand Down Expand Up @@ -99,7 +97,7 @@ def envoy_cc_library(
if tcmalloc_dep:
deps += tcmalloc_external_deps(repository)

cc_library(
native.cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
Expand All @@ -125,7 +123,7 @@ def envoy_cc_library(

# Intended for usage by external consumers. This allows them to disambiguate
# include paths via `external/envoy...`
cc_library(
native.cc_library(
name = name + "_with_external_headers",
hdrs = hdrs,
copts = envoy_copts(repository) + copts,
Expand Down
4 changes: 1 addition & 3 deletions bazel/envoy_pch.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy library targets
load(
Expand Down Expand Up @@ -27,7 +25,7 @@ def envoy_pch_library(
visibility,
testonly = False,
repository = ""):
cc_library(
native.cc_library(
name = name + "_libs",
visibility = ["//visibility:private"],
copts = envoy_copts(repository),
Expand Down
7 changes: 3 additions & 4 deletions bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# DO NOT LOAD THIS FILE. Load envoy_build_system.bzl instead.
# Envoy test targets. This includes both test library and test binary targets.
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "fuzzing_decoration")
load(":envoy_binary.bzl", "envoy_cc_binary")
load(":envoy_library.bzl", "tcmalloc_external_deps")
Expand Down Expand Up @@ -42,7 +41,7 @@ def _envoy_cc_test_infrastructure_library(
extra_deps = [repository + "//test:test_pch"]
pch_copts = envoy_pch_copts(repository, "//test:test_pch")

cc_library(
native.cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
Expand Down Expand Up @@ -103,7 +102,7 @@ def envoy_cc_fuzz_test(
**kwargs
)

cc_test(
native.cc_test(
name = name,
copts = envoy_copts("@envoy", test = True),
linkopts = _envoy_test_linkopts() + select({
Expand Down Expand Up @@ -161,7 +160,7 @@ def envoy_cc_test(
exec_properties = {}):
coverage_tags = tags + ([] if coverage else ["nocoverage"])

cc_test(
native.cc_test(
name = name,
srcs = srcs,
data = data,
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

# Use a wrapper cc_library with an empty source source file to force
Expand Down
1 change: 0 additions & 1 deletion bazel/external/boringssl_fips.BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load(":genrule_cmd.bzl", "genrule_cmd")

licenses(["notice"]) # Apache 2
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/compiler_rt.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/fmtlib.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/http_parser/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/json.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/libcircllhist.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/libprotobuf_mutator.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
1 change: 0 additions & 1 deletion bazel/external/quiche.BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"@envoy//bazel:envoy_build_system.bzl",
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/rapidjson.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/spdlog.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/sqlparser.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/su-exec.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

licenses(["notice"]) # Apache 2

cc_binary(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/tclap.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/wasm-c-api.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

package(default_visibility = ["//visibility:public"])
Expand Down
1 change: 0 additions & 1 deletion bazel/external/wasmtime.BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_static_library")

licenses(["notice"]) # Apache 2
Expand Down
2 changes: 0 additions & 2 deletions bazel/external/xxhash.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
Expand Down
1 change: 0 additions & 1 deletion bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:envoy_build_system.bzl", "envoy_cmake", "envoy_package")
load("@rules_foreign_cc//foreign_cc:configure.bzl", "configure_make")

Expand Down
1 change: 0 additions & 1 deletion bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def envoy_dependencies(skip_targets = []):
external_http_archive("bazel_toolchains")
external_http_archive("bazel_compdb")
external_http_archive("envoy_build_tools")
external_http_archive("rules_cc")
external_http_archive("rules_pkg")
_com_github_fdio_vpp_vcl()

Expand Down
10 changes: 0 additions & 10 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -707,16 +707,6 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"org_golang_x_tools",
],
),
rules_cc = dict(
project_name = "C++ rules for Bazel",
project_desc = "Bazel rules for the C++ language",
project_url = "https://github.com/bazelbuild/rules_cc",
version = "0.0.1",
sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{version}/rules_cc-{version}.tar.gz"],
release_date = "2021-10-07",
use_category = ["build"],
),
rules_foreign_cc = dict(
project_name = "Rules for using foreign build systems in Bazel",
project_desc = "Rules for using foreign build systems in Bazel",
Expand Down
1 change: 0 additions & 1 deletion contrib/vcl/source/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load(
"envoy_cc_library",
"envoy_contrib_package",
)
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_binary")
load("@base_pip3//:requirements.bzl", "requirement")

Expand Down
1 change: 0 additions & 1 deletion source/common/protobuf/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(
"//bazel:envoy_build_system.bzl",
Expand Down
1 change: 0 additions & 1 deletion source/extensions/common/wasm/ext/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library")
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
Expand Down
1 change: 0 additions & 1 deletion test/extensions/filters/http/wasm/test_data/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
Expand Down
8 changes: 3 additions & 5 deletions tools/clang_tools/support/clang_tools.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")

_clang_tools_copts = [
"-fno-exceptions",
"-fno-rtti",
]

def clang_tools_cc_binary(name, copts = [], tags = [], deps = [], **kwargs):
cc_binary(
native.cc_binary(
name = name,
copts = copts + _clang_tools_copts,
tags = tags + ["manual"],
Expand All @@ -15,14 +13,14 @@ def clang_tools_cc_binary(name, copts = [], tags = [], deps = [], **kwargs):
)

def clang_tools_cc_library(name, copts = [], **kwargs):
cc_library(
native.cc_library(
name = name,
copts = copts + _clang_tools_copts,
**kwargs
)

def clang_tools_cc_test(name, copts = [], deps = [], **kwargs):
cc_test(
native.cc_test(
name = name,
copts = copts + _clang_tools_copts,
deps = deps + ["@com_google_googletest//:gtest_main"],
Expand Down
2 changes: 0 additions & 2 deletions tools/testdata/check_format/skip_envoy_package.BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

licenses(["notice"]) # Apache 2

cc_binary(
Expand Down
2 changes: 0 additions & 2 deletions tools/testdata/check_format/skip_envoy_package.BUILD.gold
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")

licenses(["notice"]) # Apache 2

cc_binary(
Expand Down

0 comments on commit 1edd65f

Please sign in to comment.