Skip to content

Commit

Permalink
bazel: update toolchains to support remote execution
Browse files Browse the repository at this point in the history
We need to add some extra files to `compiler_files` and `linker_files`
and update some compiler flags to make sure remote execution works.

Epic: none
Release note: None
  • Loading branch information
rickystewart committed Mar 31, 2023
1 parent dcac33e commit 687fd80
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
25 changes: 23 additions & 2 deletions build/toolchains/crosstool-ng/BUILD.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ filegroup(
srcs = [
"bin/%{target}-gcc",
"bin/%{target}-g++",
],
"libexec/gcc/%{target}/6.5.0/cc1",
"libexec/gcc/%{target}/6.5.0/cc1plus",
] + glob([
"%{target}/bin/*",
"%{target}/include/c++/6.5.0/**",
"%{target}/sysroot/mingw/include/**",
"%{target}/sysroot/usr/include/**",
"lib/gcc/%{target}/6.5.0/include/**",
"lib/gcc/%{target}/6.5.0/include-fixed/**",
])
)

filegroup(
Expand All @@ -43,7 +52,19 @@ filegroup(
name = "linker_files",
srcs = [
"bin/%{target}-g++",
],
] + glob([
"%{target}/sysroot/lib/**",
"%{target}/sysroot/lib64/**",
"%{target}/sysroot/usr/%{target}/lib/**",
"%{target}/sysroot/usr/%{target}/lib32/**",
"%{target}/sysroot/usr/lib/**",
"%{target}/sysroot/usr/lib64/**",
]) + glob(
["lib/gcc/%{target}/6.5.0/**"],
exclude=[
"lib/gcc/%{target}/6.5.0/include/**",
"lib/gcc/%{target}/6.5.0/include-fixed/**",
]),
)

filegroup(
Expand Down
16 changes: 8 additions & 8 deletions build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def _impl(ctx):
action_name = ACTION_NAMES.cpp_link_static_library,
tools = [tool(path="bin/%{target}-ar")],
),

]

opt_feature = feature(
Expand Down Expand Up @@ -106,7 +105,6 @@ def _impl(ctx):
],
)


default_compile_flags = feature(
name = "default_compile_flags",
enabled = True,
Expand All @@ -117,15 +115,17 @@ def _impl(ctx):
flag_group(
flags = [
"-Wall",
"-I%{repo_path}/%{target}/include/c++/6.5.0",
"-Iexternal/%{repo_name}/%{target}/include/c++/6.5.0",
"-no-canonical-prefixes",
"-fno-canonical-system-headers",
],
),
]),
),
],
)

linker_flags = []
linker_flags = ["-fno-use-linker-plugin"]
if "%{target}" == "x86_64-w64-mingw32":
linker_flags.append("-static")
if "-linux-" in "%{target}":
Expand Down Expand Up @@ -178,11 +178,11 @@ def _impl(ctx):
action_configs = action_configs,
cxx_builtin_include_directories = [
"%sysroot%/usr/include",
"%{repo_path}/%{target}/include/c++/6.5.0",
"%{repo_path}/lib/gcc/%{target}/6.5.0/include",
"%{repo_path}/lib/gcc/%{target}/6.5.0/include-fixed",
"external/%{repo_name}/%{target}/include/c++/6.5.0",
"external/%{repo_name}/lib/gcc/%{target}/6.5.0/include",
"external/%{repo_name}/lib/gcc/%{target}/6.5.0/include-fixed",
],
builtin_sysroot = "%{repo_path}/%{target}/sysroot",
builtin_sysroot = "external/%{repo_name}/%{target}/sysroot",
)

cc_toolchain_config = rule(
Expand Down
4 changes: 1 addition & 3 deletions build/toolchains/crosstool-ng/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ def _impl(rctx):
stripPrefix = "x-tools/{}/".format(rctx.attr.target),
)

repo_path = str(rctx.path(""))

rctx.template(
"BUILD",
Label("@com_github_cockroachdb_cockroach//build:toolchains/crosstool-ng/BUILD.tmpl"),
Expand All @@ -26,7 +24,7 @@ def _impl(rctx):
substitutions = {
"%{target}": rctx.attr.target,
"%{host}": rctx.attr.host,
"%{repo_path}": repo_path,
"%{repo_name}": rctx.name,
},
executable = False,
)
Expand Down

0 comments on commit 687fd80

Please sign in to comment.