Skip to content

Commit 0343010

Browse files
committed
Works around the -fPIC issue for rust
Rust binaries are compiled with -fPIC by default, and this fights with bazel's default of -fno-pic when using `-c opt` mode. This has caused the compilation to fail. After some running around with hair on fire, I found bazelbuild/rules_rust#118, which seems to work around the issue. I think in the long run, rules_rust should handle this automagically for the users.
1 parent 9ebe958 commit 0343010

File tree

1 file changed

+7
-0
lines changed
  • kythe/rust/fuchsia_extractor

1 file changed

+7
-0
lines changed

kythe/rust/fuchsia_extractor/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ rust_test(
2525
"//kythe/rust/cargo:tempdir",
2626
],
2727
edition = "2018",
28+
# See https://github.com/bazelbuild/rules_rust/issues/118. Without this,
29+
# rust binaries require their deps to be compiled with -fPIC, which is not
30+
# always the case. fastbuild and dbg use -fPIC, but opt does not; and rust
31+
# build rules are not yet sophisticated enough to know the difference.
32+
rustc_flags = [
33+
"-Crelocation-model=static",
34+
],
2835
)
2936

3037
rust_clippy(

0 commit comments

Comments
 (0)