-
-
Notifications
You must be signed in to change notification settings - Fork 18k
fix pkgsMusl.cargo via cargoSetupHook #198311
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
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 |
|---|---|---|
|
|
@@ -68,15 +68,37 @@ in { | |
| # The `.nativeDrv` stanza works like nativeBuildInputs and ensures cross-compiling has the right version available. | ||
| diff = "${diffutils.nativeDrv or diffutils}/bin/diff"; | ||
|
|
||
| # Target platform | ||
| rustTarget = '' | ||
| [target."${rust.toRustTarget stdenv.buildPlatform}"] | ||
| # We want to specify the correct crt-static flag for both | ||
| # the build and host platforms. This is important when the wanted | ||
| # value for crt-static does not match the defaults in the rustc target, | ||
| # like for pkgsMusl or pkgsCross.musl64; Upstream rustc still assumes | ||
| # that musl = static[1]. | ||
| # | ||
| # By default, Cargo doesn't apply RUSTFLAGS when building build.rs | ||
| # if --target is passed, so the only good way to set crt-static for | ||
| # build.rs files is to use the unstable -Zhost-config Cargo feature. | ||
| # This allows us to specify flags that should be passed to rustc | ||
| # when building for the build platform. We also need to use | ||
| # -Ztarget-applies-to-host, because using -Zhost-config requires it. | ||
| # | ||
| # When doing this, we also have to specify the linker, or cargo | ||
| # won't pass a -C linker= argument to rustc. This will make rustc | ||
| # try to use its default value of "cc", which won't be available | ||
| # when cross-compiling. | ||
| # | ||
| # [1]: https://github.com/rust-lang/compiler-team/issues/422 | ||
| cargoConfig = '' | ||
| [host] | ||
| "linker" = "${ccForBuild}" | ||
| ${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) '' | ||
| [target."${shortTarget}"] | ||
| "linker" = "${ccForHost}" | ||
| ''} | ||
| "rustflags" = [ "-C", "target-feature=${if stdenv.buildPlatform.isStatic then "+" else "-"}crt-static" ] | ||
|
|
||
| [target."${shortTarget}"] | ||
| "linker" = "${ccForHost}" | ||
| "rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ] | ||
|
|
||
| [unstable] | ||
| host-config = true | ||
| target-applies-to-host = true | ||
|
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'm very puzzled as to why you set target-applies-to-host to true: the doc says
https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#host-config
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. There is two things here:
Also see, in the same section:
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. ok I understand. Then the change looks sensible to me, and if things build with it then go for it. |
||
| ''; | ||
| }; | ||
| } ./cargo-setup-hook.sh) {}; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.