Skip to content

Commit 1ae7bb5

Browse files
authored
Reorganize gcc-system toolchains (#198)
Reorganize gcc-system toolchains for `gcc-11` and `gcc-12`. Add platforms for easy toolchain selection.
1 parent f89855a commit 1ae7bb5

File tree

5 files changed

+133
-2
lines changed

5 files changed

+133
-2
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
module(
1212
name = "rules_swiftnav",
13-
version = "0.8.0",
13+
version = "0.9.0",
1414
compatibility_level = 1,
1515
)
1616

cc/constraints/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ constraint_value(
1919
constraint_setting = ":toolchain",
2020
)
2121

22+
constraint_value(
23+
name = "gcc_11_system_toolchain",
24+
constraint_setting = ":toolchain",
25+
)
26+
27+
constraint_value(
28+
name = "gcc_12_system_toolchain",
29+
constraint_setting = ":toolchain",
30+
)
31+
2232
constraint_value(
2333
name = "yocto_generic_toolchain",
2434
constraint_setting = ":toolchain",

cc/toolchains/gcc_11/x86_64-linux/BUILD.bazel renamed to cc/toolchains/system_gcc/gcc11_x86_64-linux/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ cc_toolchain(
8585
)
8686

8787
toolchain(
88-
name = "cc-toolchain-x86_64-linux",
88+
name = "system-cc-toolchain-x86_64-linux",
8989
exec_compatible_with = [
9090
"@platforms//os:linux",
9191
"@platforms//cpu:x86_64",
9292
],
9393
target_compatible_with = [
9494
"@platforms//os:linux",
9595
"@platforms//cpu:x86_64",
96+
"@rules_swiftnav//cc/constraints:gcc_11_system_toolchain",
9697
],
9798
toolchain = ":cc-gcc-x86_64-linux",
9899
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
load("@rules_cc//cc/private/toolchain:unix_cc_toolchain_config.bzl", "cc_toolchain_config")
2+
load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain")
3+
4+
package(default_visibility = ["//visibility:public"])
5+
6+
cc_toolchain_config(
7+
name = "local-x86_64-linux",
8+
abi_libc_version = "unknown",
9+
abi_version = "unknown",
10+
compiler = "gcc-12",
11+
coverage_compile_flags = ["--coverage"],
12+
coverage_link_flags = ["--coverage"],
13+
cpu = "k8",
14+
cxx_builtin_include_directories = [
15+
"/usr/include",
16+
"/usr/include/c++/12",
17+
"/usr/include/x86_64-linux-gnu/c++/12",
18+
"/usr/include/c++/12/backward",
19+
"/usr/lib/gcc/x86_64-linux-gnu/12/include",
20+
"/usr/lib/gcc/x86_64-linux-gnu/12/include-fixed",
21+
],
22+
cxx_flags = ["-std=c++17"],
23+
dbg_compile_flags = ["-g"],
24+
host_system_name = "local",
25+
link_flags = [
26+
"-lstdc++",
27+
"-fuse-ld=gold",
28+
"-Wl,-no-as-needed",
29+
"-Wl,-z,relro,-z,now",
30+
"-B/usr/bin",
31+
"-pass-exit-codes",
32+
"-lm",
33+
],
34+
opt_compile_flags = [
35+
"-g0",
36+
"-O2",
37+
"-D_FORTIFY_SOURCE=1",
38+
"-DNDEBUG",
39+
"-ffunction-sections",
40+
"-fdata-sections",
41+
],
42+
opt_link_flags = ["-Wl,--gc-sections"],
43+
supports_start_end_lib = True,
44+
target_libc = "glibc",
45+
target_system_name = "local",
46+
tool_paths = {
47+
"ar": "/usr/bin/ar",
48+
"as": "/usr/bin/as",
49+
"cpp": "/usr/bin/cpp-12",
50+
"gcc": "/usr/bin/gcc-12",
51+
"g++": "/usr/bin/g++-12",
52+
"gcov": "/usr/bin/gcov-12",
53+
"ld": "/usr/bin/g++-12",
54+
"nm": "/usr/bin/nm",
55+
"objcopy": "/usr/bin/objcopy",
56+
"objdump": "/usr/bin/objdump",
57+
"ranlib": "/usr/bin/ranlib",
58+
"strip": "/usr/bin/strip",
59+
},
60+
toolchain_identifier = "cc-gcc-x86_64-linux",
61+
unfiltered_compile_flags = [
62+
"-fno-canonical-system-headers",
63+
"-Wno-builtin-macro-redefined",
64+
"-D__DATE__=\"redacted\"",
65+
"-D__TIMESTAMP__=\"redacted\"",
66+
"-D__TIME__=\"redacted\"",
67+
],
68+
)
69+
70+
filegroup(name = "empty")
71+
72+
cc_toolchain(
73+
name = "cc-gcc-x86_64-linux",
74+
all_files = ":empty",
75+
ar_files = ":empty",
76+
as_files = ":empty",
77+
compiler_files = ":empty",
78+
dwp_files = ":empty",
79+
linker_files = ":empty",
80+
objcopy_files = ":empty",
81+
strip_files = ":empty",
82+
supports_param_files = 0,
83+
toolchain_config = ":local-x86_64-linux",
84+
toolchain_identifier = "cc-gcc-x86_64-linux",
85+
)
86+
87+
toolchain(
88+
name = "system-cc-toolchain-x86_64-linux",
89+
exec_compatible_with = [
90+
"@platforms//os:linux",
91+
"@platforms//cpu:x86_64",
92+
],
93+
target_compatible_with = [
94+
"@platforms//os:linux",
95+
"@platforms//cpu:x86_64",
96+
"@rules_swiftnav//cc/constraints:gcc_12_system_toolchain",
97+
],
98+
toolchain = ":cc-gcc-x86_64-linux",
99+
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
100+
)

platforms/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,23 @@ platform(
211211
],
212212
visibility = ["//visibility:public"],
213213
)
214+
215+
platform(
216+
name = "x86_64_linux_gcc11_system",
217+
constraint_values = [
218+
"@platforms//os:linux",
219+
"@platforms//cpu:x86_64",
220+
"@rules_swiftnav//cc/constraints:gcc_11_system_toolchain",
221+
],
222+
visibility = ["//visibility:public"],
223+
)
224+
225+
platform(
226+
name = "x86_64_linux_gcc12_system",
227+
constraint_values = [
228+
"@platforms//os:linux",
229+
"@platforms//cpu:x86_64",
230+
"@rules_swiftnav//cc/constraints:gcc_12_system_toolchain",
231+
],
232+
visibility = ["//visibility:public"],
233+
)

0 commit comments

Comments
 (0)