-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extra_rustc_flags_for_crate_types. #2431
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment. I think macros would be the solution for your use cases. Let me know if macros won't work.
5707027
to
668d23f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Do you mind adding some tests?
668d23f
to
8442d3e
Compare
I added a simple test. Is there a way to get the CrateInfo provider in the test so I can test with multiple crate types? I poked around a bit and didn't manage to, but I'm pretty new to working with rule implementations. |
To get any provider, you just need to do |
d17f136
to
1c87ac6
Compare
From the CI:
Did I do something to make it try and run the fake binaries? Is it the |
@granaghan I merged the main branch into your branch to rerun CI. Now it's failing with different error. Can you pull the updated branch, run |
It looks like the coverage check is still tying to use the mock compiler. For some reason it's building for OS
|
Okay, I managed to repro it after gathering all the additions flags. It seems that |
6222d3f
to
5e2943d
Compare
It seems this only happens if I declare a |
This allows extra rustc flags that will only apply to specific library types to be set by the toolchain. Cross language LTO needs '-C linker-plugin-lto' on libraries, how passing this flag to rust_binary generated bloat. Adding this attribute resolves this issue. Change-Id: Iba725fab1b1941e9586ff97cd71ec3bc1dfc1523
Change-Id: I75472b1f9bb67d7348ad31a495d59344c4a6edf1
5e2943d
to
57e9798
Compare
Any other changes here or is this good to go? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Can you also file an issue about the failure with rust_binary? Thanks!
Added #2583. I don't have write access, so you'll need to merge. Thanks! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [rules_rust](https://togithub.com/bazelbuild/rules_rust) | http_archive | patch | `0.41.0` -> `0.41.1` | --- ### Release Notes <details> <summary>bazelbuild/rules_rust (rules_rust)</summary> ### [`v0.41.1`](https://togithub.com/bazelbuild/rules_rust/releases/tag/0.41.1) [Compare Source](https://togithub.com/bazelbuild/rules_rust/compare/0.41.0...0.41.1) ### 0.41.1 ```python load("@​bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_rust", integrity = "sha256-mUV3N2A8ORVVZbrm3O9yepAe/Kv4MD2ob9YQhB8aOI8=", urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.41.1/rules_rust-v0.41.1.tar.gz"], ) ``` Additional documentation can be found at: https://bazelbuild.github.io/rules_rust/#setup #### What's Changed - Add extra_rustc_flags_for_crate_types. by [@​granaghan](https://togithub.com/granaghan) in [https://github.com/bazelbuild/rules_rust/pull/2431](https://togithub.com/bazelbuild/rules_rust/pull/2431) - Android jobs should be using LTS Bazel releases by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2589](https://togithub.com/bazelbuild/rules_rust/pull/2589) - BUG-FIX: host-triple str for bzl mod by [@​ericmcbride](https://togithub.com/ericmcbride) in [https://github.com/bazelbuild/rules_rust/pull/2587](https://togithub.com/bazelbuild/rules_rust/pull/2587) - fix(cargo-bazel): ignore example crates when checking if proc-macro by [@​qtica](https://togithub.com/qtica) in [https://github.com/bazelbuild/rules_rust/pull/2596](https://togithub.com/bazelbuild/rules_rust/pull/2596) - Deprecated `rust_bindgen.leak_symbols` by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2590](https://togithub.com/bazelbuild/rules_rust/pull/2590) - Update test metadata for crate_universe by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2599](https://togithub.com/bazelbuild/rules_rust/pull/2599) - Fixed bug where crate_universe could match aliases to bench/example deps by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2600](https://togithub.com/bazelbuild/rules_rust/pull/2600) - Cleanup splicing utils by [@​dzbarsky](https://togithub.com/dzbarsky) in [https://github.com/bazelbuild/rules_rust/pull/2564](https://togithub.com/bazelbuild/rules_rust/pull/2564) - Updated repository rules to notify users about non-reproducible repos. by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2593](https://togithub.com/bazelbuild/rules_rust/pull/2593) - feat: Strip debug info from opt builds by [@​matte1](https://togithub.com/matte1) in [https://github.com/bazelbuild/rules_rust/pull/2513](https://togithub.com/bazelbuild/rules_rust/pull/2513) - Release 0.41.1 by [@​UebelAndre](https://togithub.com/UebelAndre) in [https://github.com/bazelbuild/rules_rust/pull/2592](https://togithub.com/bazelbuild/rules_rust/pull/2592) #### New Contributors - [@​qtica](https://togithub.com/qtica) made their first contribution in [https://github.com/bazelbuild/rules_rust/pull/2596](https://togithub.com/bazelbuild/rules_rust/pull/2596) - [@​matte1](https://togithub.com/matte1) made their first contribution in [https://github.com/bazelbuild/rules_rust/pull/2513](https://togithub.com/bazelbuild/rules_rust/pull/2513) **Full Changelog**: bazelbuild/rules_rust@0.41.0...0.41.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bazel-contrib/toolchains_llvm). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This allows extra rustc flags that will only apply to library targets to be set by the toolchain. Cross language LTO needs '-C linker-plugin-lto' on libraries, how passing this flag to rust_binary generated bloat. Adding this attribute resolves this issue.
Change-Id: Iba725fab1b1941e9586ff97cd71ec3bc1dfc1523