Skip to content
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

Analog to cargo profiles in rules_rust #515

Open
djmarcin opened this issue Nov 30, 2020 · 1 comment
Open

Analog to cargo profiles in rules_rust #515

djmarcin opened this issue Nov 30, 2020 · 1 comment
Labels

Comments

@djmarcin
Copy link
Contributor

Currently it seems that the compilation mode is used to drive the opt_level and debuginfo settings at the toolchain level. This makes it extremely difficult to override settings for more than one crate at a time. For example, if I wanted to override -c opt to use "s" instead of 3, I would need to define an entirely new toolchain and figure out how to get my binaries to use it instead of the default toolchain.

This is substantially more difficult than cargo profiles. It would be nice if a profile-like option was exposed in the repository rules to allow the option to more easily change these options that apply across many crates at once. It would be ideal if such an option was able to be toggled by individual targets rather than globally. For example, we may want to have different optimization settings for code shipped to client devices vs cloud servers without needing to define custom toolchains for one or the other.

I'm not sure after skimming the bazel toolchain docs if this is really possible without defining multiple toolchains, but if not, it would be ideal if rules_rust could make this simpler with a helper rule to define additional toolchains by passing it a profile-like dict.

Looking for feedback on this idea / has it been thought about before? If so, are there ideas about how it might work?

@mattbonnell
Copy link

Late to the party.

I'm using rules_bazel in "direct packages"/Cargo.toml-free. We run a polyglot monorepo so being able to use pure Bazel and avoid bringing in language-specific build config formats is a big usability win for us.

That said, the ability to configure compilation profiles that Cargo.toml provides is noticeably absent in this setup. Curious how other folks in the community are working around this and what would need to be done to expose this sort of functionality in rules_rust. I have time and motivation to contribute in this area.

github-merge-queue bot pushed a commit that referenced this issue Jul 12, 2024
This PR provides documentation of Bazelmod and several code examples
that addresses a number of issues related to Bazelmod.

Preview of the documentation:
https://github.com/marvin-hansen/rules_rust/blob/main/docs/crate_universe_bzlmod.md

First and foremost it paves the way for a meaningful update the Bazelmod
documentation that references these and existing code examples. This
touches at least the following issues:
* #2670
* #2181


The compile_opt example addresses or resolves:
*  #515
* #2701

The musl_cross_compilling example addresses or resolves
* #390 
* #276

The oci_container does not relate to any open issue, 
although the tokio example in it gives a nice end to end example so 
this definitely helps those looking for something non-trivial.

The proto example addresses or resolves:
*  #2668
*  #302
* #2534
* Possibly a few more if I were to search longer

Formalities
* I've signed the CLA
* I've signed all commits

---------

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants