Skip to content

Commit

Permalink
Add the experimental_use_cc_common_link flag for Rust
Browse files Browse the repository at this point in the history
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
  • Loading branch information
acozzette authored and copybara-github committed Dec 3, 2024
1 parent 4d998f2 commit 9db4d1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
# TODO: ErrorProne's SelfAssertions are violated in protobuf's test
build --javacopt=-Xep:SelfAssertion:WARN

# This flag works around some issues with Rust linking.
build --@rules_rust//rust/settings:experimental_use_cc_common_link=True

build:dbg --compilation_mode=dbg

build:opt --compilation_mode=opt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: rust_linux
bazel: >-
${{ matrix.bazel_cmd }} --crosstool_top=//toolchain:clang_suite --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
${{ 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
${{ matrix.targets }} ${{ matrix.config.flags }}

0 comments on commit 9db4d1c

Please sign in to comment.