-
Notifications
You must be signed in to change notification settings - Fork 426
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
Bzlmod has no support for strip_level or opt_level #2701
Comments
You can do this with manual compiler option pass through in 3 steps
config_setting(
name = "release",
values = {
"compilation_mode": "opt",
},
) This maps Rusts release mode to Bazel's -c opt.
# Build binary
rust_binary(
name = "bin",
crate_root = "src/main.rs",
srcs = glob([
"src/*/*.rs",
"src/*.rs",
]),
# Compiler optimization
rustc_flags = select({
"//:release": [
"-Clto",
"-Ccodegen-units=1",
"-Cpanic=abort",
"-Copt-level=3",
"-Cstrip=symbols",
],
"//conditions:default":
[
"-Copt-level=0",
],
}),
deps = [ ],
visibility = ["//visibility:public"],
)
Example code: Hope that helps. |
Oh, that's great, thank you! |
I'm drafting currently the new Bazelmod documentation that should get upstreamed hopefully soon. Do you think this issue can be closed given this will be documented? |
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>
There's currently no way to pass the strip_level or opt_level to rust_toolchain using Bzlmod.
The text was updated successfully, but these errors were encountered: