-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Per-target profiles? #4897
Comments
I made a different work-around in Servo, have So there’s no pressing need to implement this as far as Servo is concerned. But maybe it could still be useful for other use cases. |
In my use case , I need this feature to work around wasm32 related issue: rust-lang/rust#47643 |
LTO is currently broken on |
I have a use-case for this too: I'd like to minimize code size for WASM targets, which means |
I have my own usecase for this: our company is using VS 2015 and we encounter this issue: briansmith/ring#1031 My workaround while waiting for the decision to update VS is to do: [profile.release.package.ring]
opt-level = 0
debug-assertions = false but it impacts Linux as well, and it's a pity |
While waiting for an actual / true solution, I have posted a hacky workaround, that may suit some people / use-cases: |
I eagerly need this, do we want to still do it? |
Same here, specifically [target."cfg(macos)".profile.dev]
split-debuginfo = "unpacked" So it's only turned on for macs where it matters. If cargo adds a config item, it really should work for everyone, even if ignored. Here the build is unhappy on Linux. |
I have another wasm related use case our code runs some (in wasm) tests expressly slow if no optimizations are enabled. In some of the more extreme cases setting As a side note: This is not limited to So being able to do: [target.'cfg(any(target_arch="wasm32", target_os="android"))'.profile.dev]
opt-level = 2
[target.'cfg(any(target_arch="wasm32", target_os="android"))'.profile.test]
opt-level = 2 would be grate. But there are some open questions:
|
In the meantime i think you can use rustflags with the
That should help |
I'm on the same boat. For example it would be great to change the profile according to Rust version like this:
For now, writing this option will not compile for versions below 1.58. |
This is definitely needed for WASM/Non-WASM build preferences. Those who wish to make cross-platform binaries ideally need differing targets. |
Agreed. I just ran into this. There's no way to tell Cargo "do this differently when cross-compiling". Which is usually a situation in which things are different. So I'd suggest adding a feature for that. |
I would use this to optimize for size in WASM builds and speed in native builds. |
Could someone help me understand why defining a new profile that sets the needed fields is not sufficient? |
How might one do this with profiles? I think most of everyone here is seeking to minify their WASM builds. The reason I give this feature request a big thumbs up is because I want to strip debug/panic=abort/etc. for wasm build where the bundle size is a concern, but keep all that good information available on native builds. This is the current solution I do. # SURE would be great if I could only apply these settings ONLY to WASM!
# e.g. [profile.'cfg(target_arch = "wasm32")'.release]
# Unfortunately, these settings must apply to native/wasm/etc. bc https://github.com/rust-lang/cargo/issues/4897
[profile.release]
panic = "abort"
lto = true
codegen-units = 1
opt-level = 'z' |
You can do this though: [profile.release]
lto = true
codegen-units = 1
strip = true
panic = "abort"
[profile.web-release]
inherits = "release"
opt-level = "s"
strip = "debuginfo" |
And run See Custom profiles for more. |
Well that certainly satisfies me. Didn't know that was possible. |
Custom profiles was stabilized in 1.57, 3 years after this issue was created. In general, there are a lot in rust releases and not obvious how all they can solve a specific problem in front of you. |
This might become more relevant with profile rustflags (#10271), because the rustflags to set might be scpecific to the platform you're building for, e.g.:
Some things, like the |
One issue with this actually still exists @epage :
And if you apply this at a workspace-level:
It will affect all downstream members. OR will it? Actually, to my surprise: It doesn't! When I tried putting this profile at the room level workspace Cargo.toml, and I had a sub member that I compile to wasm32. It appars the flags don't even apply to the sub members, which seems like a bug. Either way, I don't think this looks good! |
#4817
I was hoping to use something like this:
to work around rust-lang/rust#47186, but looking at
src/cargo/util/toml/mod.rs
it seems thattarget.cfg
sections can only be combined with dependencies, not other sections likeprofile
.Would it make sense to add support for this?
The text was updated successfully, but these errors were encountered: