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

Specifying extra rustc flags based on --compilation_mode #2833

Open
martingms opened this issue Sep 4, 2024 · 1 comment
Open

Specifying extra rustc flags based on --compilation_mode #2833

martingms opened this issue Sep 4, 2024 · 1 comment

Comments

@martingms
Copy link

Hi!

Currently, the rustc flags -Copt-level (and -Cdebug-info) is set based on the --compilation_mode.
However, I want to also set some additional flags that should change based on --compilation_mode, such as -Clto=true and -Ccodegen-units=1 on opt (with some other default values on dbg or fastbuild), for example.

Is there some way of achieving this with rules_rust at the moment without wrapper macros with select(..), or is that the preferred approach? I'm using rules_rust through bzlmod if that matters, but I could switch back to WORKSPACE if that makes it easier.

@marvin-hansen
Copy link
Contributor

Wrapper macros with select is the preferred approach, as shown in the example.

https://github.com/bazelbuild/rules_rust/tree/main/examples/bzlmod/compile_opt

It is not perfect, but allows per binary opt settings. I am unaware of a better solution atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants