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

fix pkgsMusl.rustc #186443

Merged
merged 7 commits into from
Aug 13, 2022
Merged

fix pkgsMusl.rustc #186443

merged 7 commits into from
Aug 13, 2022

Conversation

yu-re-ka
Copy link
Contributor

@yu-re-ka yu-re-ka commented Aug 13, 2022

Description of changes

Note that while the resulting rustc is fully functional, pkgsMusl.cargo is still broken

Parts of this were previously reviewd in #141972

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

pkgs/build-support/rust/hooks/default.nix Show resolved Hide resolved
pkgs/development/compilers/rust/rustc.nix Outdated Show resolved Hide resolved
This is both simpler and works in more cases, e.g. for the bootstrap binaries
linked against musl libc.
The crt-static option selects if the C runtime is linked dynamically or
statically into the resulting binaries.

There is a default value of this setting for each platform, but it is
not always what we want. For example, musl targets are assumed to always
have the C runtime linked statically, but we support both.

In practise, this fixes an error in the pkgsMusl.rustc build:
> cannot produce dylib for `rustc_driver v0.0.0 (/build/rustc-1.63.0-src/compiler/rustc_driver)` as the target `x86_64-unknown-linux-musl` does not support these crate types
A build script crashes:
> cannot produce dylib for `rustc_driver v0.0.0 (/build/rustc-1.63.0-src/compiler/rustc_driver)` as the target `x86_64-unknown-linux-musl` does not support these crate types
The linked issue was resolved upstream and the `-lgcc` is no longer required
since rust-lang/compiler-builtins#377 was merged.
Tell rust if we want our binaries linked statically or dynamically.
Otherwise the compiler will always produce statically linked binaries for musl
targets, as this is the default.
Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit messages are great now, thanks!

LGTM, but patchelf scares me so I didn't look at those changes too closely. Hopefully somebody else can who's more familiar with it.

@Mic92
Copy link
Member

Mic92 commented Aug 13, 2022

Switching from manual patching to AutopatchelfHook looks good to me.

pyelftools ships a readelf binary for its test suite that is linked
against glibc. Replacing this readelf binary with our stdenv version
doesn't work.
@Mic92 Mic92 merged commit f08b424 into NixOS:staging Aug 13, 2022
@yu-re-ka yu-re-ka deleted the feature/rustc-musl2 branch August 13, 2022 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants