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

Support "local" rustflags only affecting the main crate #215

Merged
merged 4 commits into from
Sep 10, 2022

Conversation

jschwe
Copy link
Collaborator

@jschwe jschwe commented Sep 7, 2022

For some scenarios it is better to not set Rustflags for all crates
in the dependency graph and instead only set it for the top-level
crate.
For example rust-lang/cargo#8716
can be avoided in some scenarios by setting the rustflags via
rustc, which allows for faster rebuilds in such cases.

Note:
Switching to "cargo rustc" is slightly problematic in cases where a package has multiple crates (e.g. lib and one or more bins), however Corrosion doesn't actually support those cases right now anyway.
A follow-up PR will add support for multiple targets per package.

The currently available way of setting Rustflags is by setting the `RUSTFLAGS`
environment variable, which affects all crates in the dependency graph.

This may be undesirable in some circumstances, so a future commit will
the option to specify RUSTFLAGS via `cargo rustc`, which only affects
the current crate and not dependencies.

This commit prepares by refactoring some names to make the distinction
easier.
For some scenarios it is better to not set Rustflags for all crates
in the dependency graph and instead only set it for the top-level
crate.
For example rust-lang/cargo#8716
can be avoided in some scenarios by setting the rustflags via
rustc, which allows for faster rebuilds in such cases.
Using local rustflags passed via `cargo rustc` has the advantage,
that they are not set for dependencies.
This is mostly benenficial in workspaces, where different crates link
different C dependencies, but share common rust dependencies.
If the RUSTFLAGS environment variable is used this will cause rebuilds
of the common rust dependencies, since the RUSTFLAGS  differ.
When passing rustflags via cargo rustc, this does not happen, since they
only affects the main crate.
Document recent changes
@jschwe jschwe merged commit d9dfdef into corrosion-rs:master Sep 10, 2022
@jschwe jschwe added this to the v0.3 milestone Sep 18, 2022
@jschwe jschwe deleted the local_rustflags branch September 28, 2022 04:38
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

Successfully merging this pull request may close these issues.

1 participant