Skip to content

Commit a8601db

Browse files
authored
Fix rules_cc leftovers from #47716 for Bazel 9 (#47745)
### What does this PR do? Completes the full `rules_cc` migration started in #47716, covering the cases I missed: our own `.bzl` rule files and the `gcc-toolchain` external dependency. ### Motivation #47716 covered our `BUILD.bazel` files but left other files still relying on injected globals, absent from Bazel 9+. ### Additional Notes The additional patch to `gcc-toolchain` will disappear once f0rmiga/gcc-toolchain#217 gets merged. Co-authored-by: regis.desgroppes <[email protected]>
1 parent 88d4c44 commit a8601db

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ git_override(
176176
"//bazel/patches:gcc-toolchain/0002-fix-c-x86_64-header-locations-with-our-ctng-toolchai.patch",
177177
"//bazel/patches:gcc-toolchain/0003-add-nostdinc-to-asmflags.patch",
178178
"//bazel/patches:gcc-toolchain/0004-fix-re-fetching.patch", # https://github.com/f0rmiga/gcc-toolchain/pull/207
179+
"//bazel/patches:gcc-toolchain/0005-fix-bazel-9-compat.patch",
179180
],
180181
remote = "https://github.com/f0rmiga/gcc-toolchain.git",
181182
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl
2+
index b8ae535..4839532 100644
3+
--- a/toolchain/cc_toolchain_config.bzl
4+
+++ b/toolchain/cc_toolchain_config.bzl
5+
@@ -29,6 +29,7 @@ load(
6+
"tool_path",
7+
"with_feature_set",
8+
)
9+
+load("@rules_cc//cc:defs.bzl", "CcToolchainConfigInfo", "cc_common")
10+
11+
all_compile_actions = [
12+
ACTION_NAMES.c_compile,
13+
diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl
14+
index 65095db..c5b7ee0 100644
15+
--- a/toolchain/defs.bzl
16+
+++ b/toolchain/defs.bzl
17+
@@ -433,7 +433,7 @@ ARCHS = struct(
18+
)
19+
20+
_TOOLCHAIN_BUILD_FILE_CONTENT = """\
21+
-load("@rules_cc//cc:defs.bzl", "cc_toolchain")
22+
+load("@rules_cc//cc:defs.bzl", "cc_library", "cc_toolchain")
23+
load("@{gcc_toolchain_workspace_name}//toolchain:cc_toolchain_config.bzl", "cc_toolchain_config")
24+
load("//:tool_paths.bzl", "tool_paths")
25+

bazel/rules/foreign_cc_shared_wrapper.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
2-
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
1+
load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common")
32
load("@rules_cc//cc/common:cc_shared_library_info.bzl", "CcSharedLibraryInfo")
43

54
def _foreign_cc_shared_wrapper_impl(ctx):

bazel/rules/preprocessor.bzl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
load("@bazel_skylib//lib:paths.bzl", "paths")
22
load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME")
3-
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cpp_toolchain", "use_cc_toolchain")
4-
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
5-
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
3+
load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common")
4+
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cc_toolchain", "use_cc_toolchain")
65

76
def _c_preprocessor_impl(ctx):
87
out = ctx.outputs.output
98
source = ctx.file.input
109
include_dirs = [paths.dirname(f.path) for f in ctx.files.deps]
11-
cc_toolchain = find_cpp_toolchain(ctx)
10+
cc_toolchain = find_cc_toolchain(ctx)
1211
compilation_ctx = cc_common.create_compilation_context(
1312
headers = depset(ctx.files.deps),
1413
)

bazel/toolchains/mingw/toolchain.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ load(
1111
"tool_path",
1212
)
1313
load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES")
14-
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
14+
load("@rules_cc//cc:defs.bzl", "CcToolchainConfigInfo", "cc_common")
1515

1616
def _impl(ctx):
1717
tools = [

0 commit comments

Comments
 (0)