Skip to content

Commit 4979207

Browse files
authored
fix: Set SYSROOT environment variable to the directory of the rust_lib files (#786)
This change fixes some issues that the Kythe team is having building our Rust extractor inside Bazel
1 parent f67d96d commit 4979207

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

docs/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ bzl_library(
1111
"@build_bazel_rules_nodejs//internal/providers:bzl",
1212
],
1313
deps = [
14+
"@bazel_skylib//lib:paths",
1415
"@rules_proto//proto:rules",
1516
],
1617
)

rust/private/rustc.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
# buildifier: disable=module-docstring
16+
load("@bazel_skylib//lib:paths.bzl", "paths")
1617
load(
1718
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
1819
"CPP_LINK_EXECUTABLE_ACTION_NAME",
@@ -487,9 +488,8 @@ def construct_arguments(
487488
data_paths,
488489
))
489490

490-
# This empty value satisfies Clippy, which otherwise complains about the
491-
# sysroot being undefined.
492-
env["SYSROOT"] = ""
491+
# Set the SYSROOT to the directory of the rust_lib files passed to the toolchain
492+
env["SYSROOT"] = paths.dirname(toolchain.rust_lib.files.to_list()[0].short_path)
493493

494494
return args, env
495495

0 commit comments

Comments
 (0)