Skip to content

wrapRustcWith: allow --sysroot to be overridden#274853

Merged
alyssais merged 2 commits intoNixOS:stagingfrom
alyssais:rustc-sysroot
Dec 19, 2023
Merged

wrapRustcWith: allow --sysroot to be overridden#274853
alyssais merged 2 commits intoNixOS:stagingfrom
alyssais:rustc-sysroot

Conversation

@alyssais
Copy link
Member

Description of changes

It turns out that unlike a normal Unix program, if the --sysroot option is given more than once, rustc will error rather than using the last value given. Therefore, we need to ensure we only add our default --sysroot argument if one hasn't been given explicitly on the wrapper's command line.

This fixes cross compilation of rustc.

Closes: #271736
Fixes: 8b51cdd ("rustc: add a compiler wrapper")

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@alyssais alyssais requested review from a user and yu-re-ka December 17, 2023 00:26
@alyssais alyssais changed the base branch from master to staging December 17, 2023 00:26
@github-actions github-actions bot added the 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. label Dec 17, 2023
@alyssais alyssais added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Dec 17, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Every day I learn some crazy new bash syntax. :^)

@delroth delroth added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 17, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Dec 17, 2023
It turns out that unlike a normal Unix program, if the --sysroot
option is given more than once, rustc will error rather than using the
last value given.  Therefore, we need to ensure we only add our
default --sysroot argument if one hasn't been given explicitly on the
wrapper's command line.

This fixes cross compilation of rustc.

Closes: NixOS#271736
Fixes: 8b51cdd ("rustc: add a compiler wrapper")
@yu-re-ka
Copy link
Contributor

With this change we should be able to revert the hacky fix of rust-hypervisor-firmware in #257345 cc @astro

@delroth delroth removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 17, 2023
This reverts commit e97f8fe.

No longer necessary since the rustc wrapper now handles --sysroot
correctly.
Copy link
Contributor

@yu-re-ka yu-re-ka left a comment

Choose a reason for hiding this comment

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

I have done only end to end tests

@delroth delroth added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Dec 17, 2023
@yu-re-ka
Copy link
Contributor

Do you mind if I merge this?

@alyssais alyssais merged commit 1ee9f3c into NixOS:staging Dec 19, 2023
@alyssais alyssais deleted the rustc-sysroot branch December 19, 2023 10:34
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/rust-cross-compiling-no-std-with-custom-target/39236/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: rustc 1.73.0 (cross-compilation)

5 participants

Comments