-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
rustPlatform.buildRustPackage: Pass env.RUSTFLAGS only when specified or needed to fix builds
#464707
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
rustPlatform.buildRustPackage: Pass env.RUSTFLAGS only when specified or needed to fix builds
#464707
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,17 +89,20 @@ lib.extendMkDerivation { | |
| "buildRustPackage: `useFetchCargoVendor` is non‐optional and enabled by default as of 25.05, remove it" | ||
| true; | ||
| { | ||
| env = { | ||
| PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0; | ||
| RUST_LOG = logLevel; | ||
| RUSTFLAGS = | ||
| lib.optionalString ( | ||
| stdenv.hostPlatform.isDarwin && buildType == "debug" | ||
| ) "-C split-debuginfo=packed " | ||
| # Workaround the existing RUSTFLAGS specified as a list. | ||
| + interpolateString (args.RUSTFLAGS or ""); | ||
| } | ||
| // args.env or { }; | ||
| env = | ||
| let | ||
| isDarwinDebug = stdenv.hostPlatform.isDarwin && buildType == "debug"; | ||
| in | ||
| { | ||
| PKG_CONFIG_ALLOW_CROSS = if stdenv.buildPlatform != stdenv.hostPlatform then 1 else 0; | ||
| RUST_LOG = logLevel; | ||
| # Prevent shadowing *_RUSTFLAGS environment variables | ||
| ${if args ? RUSTFLAGS || isDarwinDebug then "RUSTFLAGS" else null} = | ||
| lib.optionalString isDarwinDebug "-C split-debuginfo=packed " | ||
| # Workaround the existing RUSTFLAGS specified as a list. | ||
| + interpolateString (args.RUSTFLAGS or ""); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good fix, but if you feel like putting in a bit more, even better would be not doing this in buildRustPackage to begin with — it's not the right place for it because plenty of Rust builds don't go through it. The rustc wrapper would be a much better place — it's universally used and doesn't need any environment variables to be modified.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm leaning toward addressing the simplification in a subsequent PR, as such change could introduce new incompatibility. (The existing change is a partial revert ) Would it be okay if we merge and backport this fix as-is?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's okay, at least it shouldn't be worse than the previous situation
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ShamrockLee still feel like making that subsequent PR?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After looking into the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My suggestion was to put it in the rustc wrapper. Cargo invokes rustc through that wrapper. |
||
| } | ||
| // args.env or { }; | ||
|
|
||
| cargoDeps = | ||
| if cargoVendorDir != null then | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.