Skip to content

Commit 9db4d1c

Browse files
acozzettecopybara-github
authored andcommitted
Add the experimental_use_cc_common_link flag for Rust
Upgrading to rules_rust 0.54.1 seems to have fixed some of our Rust linking problems, but not all, so this change adds back in the `--@rules_rust//rust/settings:experimental_use_cc_common_link=True` flag. This fixes some local build errors like the following: ``` $ bazel build //rust/test/shared:bad_names_cpp_test ... = note: bazel-out/k8-fastbuild/bin/rust/test/shared/_ambiguous_libs/bad_names_cpp_test/libport-330124825.a(port.pic.o):port.cc:function google::protobuf::internal::CounterMap():(.text+0xe6): error: undefined reference to 'atexit' ``` PiperOrigin-RevId: 702380176
1 parent 4d998f2 commit 9db4d1c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
33
# TODO: ErrorProne's SelfAssertions are violated in protobuf's test
44
build --javacopt=-Xep:SelfAssertion:WARN
55

6+
# This flag works around some issues with Rust linking.
7+
build --@rules_rust//rust/settings:experimental_use_cc_common_link=True
8+
69
build:dbg --compilation_mode=dbg
710

811
build:opt --compilation_mode=opt

.github/workflows/test_rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ jobs:
4848
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
4949
bazel-cache: rust_linux
5050
bazel: >-
51-
${{ matrix.bazel_cmd }} --crosstool_top=//toolchain:clang_suite --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
51+
${{ matrix.bazel_cmd }} --crosstool_top=//toolchain:clang_suite --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --@rules_rust//rust/settings:experimental_use_cc_common_link=True
5252
${{ matrix.targets }} ${{ matrix.config.flags }}
5353

0 commit comments

Comments
 (0)