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

rustc: add support for armv7l targets #72480

Closed

Conversation

@urbas
Copy link

urbas commented Nov 1, 2019

Motivation for this change

rustc and Rust packages would not compile on Raspbian on a Raspberry Pi. It turns out that Rust's ARMv7 targets are slightly different from Nix's.

Addresses issue #72473

Things done

This change adds a function that maps armv7a and armv7l architectures to armv7. The former are used in Raspbian on Raspberry Pi but are unknown to rustc. Rust knows only armv7.

In addition, this change also disables the m_hugefile test in e2fsprogs as it was failing on ARMv7 Raspbian on the Raspberry Pi.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @edolstra @madjar @cstrahan @globin @Havvy

@urbas urbas requested review from LnL7 and Mic92 as code owners Nov 1, 2019
@urbas urbas force-pushed the urbas:feature/armv7l-raspbian-support-for-rust branch 2 times, most recently from b5b9ee4 to 09d24d1 Nov 1, 2019
@urbas urbas requested a review from Mic92 Nov 1, 2019
@Mic92
Mic92 approved these changes Nov 1, 2019
Copy link
Contributor

Mic92 left a comment

Have not tested, but code seems fine.

@ofborg ofborg bot added the 6.topic: rust label Nov 1, 2019
@ofborg ofborg bot requested review from Gerschtli, globin, cstrahan, madjar and edolstra Nov 1, 2019
@FRidh FRidh added this to Needs review in Staging Nov 2, 2019
Staging automation moved this from Needs review to Ready Nov 3, 2019
Copy link
Contributor

Gerschtli left a comment

Haven't tested it either, but diff LGTM.

@doronbehar

This comment has been minimized.

Copy link
Contributor

doronbehar commented Nov 7, 2019

BTW Rust 1.39.0 was released today so it might worth updating it here as well.

@edolstra

This comment has been minimized.

Copy link
Member

edolstra commented Nov 7, 2019

That's already done in #72980.

@Mic92

This comment has been minimized.

Copy link
Contributor

Mic92 commented Nov 8, 2019

@GrahamcOfBorg build rustc

Copy link
Contributor

lopsided98 left a comment

I wrote a similar patch a while ago to add support for armv7l and armv6l, see: lopsided98@d6d2c1c. My patch fixes the target in a few more places that you missed, but I missed the one in build-crate.nix.

x86_64-pc-mingw32 = "x86_64-pc-windows-gnu";
}.${nixTarget} or (
let
armMatch = builtins.match "armv7[al]-(.*)" nixTarget;

This comment has been minimized.

Copy link
@lopsided98

lopsided98 Nov 9, 2019

Contributor

It seems like you could make this simpler if you passed in the entire platform instead of just the config string. The platform elaboration logic has already parsed out all the components you need, so you don't need to do it again. You could then make your function more like the one previously used in build-crate.nix

This comment has been minimized.

Copy link
@lopsided98

This comment has been minimized.

Copy link
@urbas

urbas Nov 10, 2019

Author

My fixes look extremely similar to yours. I also see they well predate mine. I am sorry, I wasn't aware of them.

Btw, I also agree with your suggestions. I can fix this PR. However, I can also retract this pull request so you can go ahead and create yours. Let me know which way you'd prefer.

This comment has been minimized.

Copy link
@FRidh

FRidh Nov 12, 2019

Member

How will you continue?

This comment has been minimized.

Copy link
@urbas

urbas Nov 12, 2019

Author

I'll apply the fixes @lopsided98 recommended.

This comment has been minimized.

Copy link
@urbas

urbas Nov 15, 2019

Author

I now applied the fixes.

pkgs/tools/filesystems/e2fsprogs/default.nix Outdated Show resolved Hide resolved
@urbas urbas force-pushed the urbas:feature/armv7l-raspbian-support-for-rust branch from 09d24d1 to 16a73c0 Nov 10, 2019
@urbas urbas force-pushed the urbas:feature/armv7l-raspbian-support-for-rust branch 2 times, most recently from f4b514d to a3cc991 Nov 15, 2019
Addresses issue #72473

`rustc` and Rust packages would not compile on Raspbian on a Raspberry Pi. It turns out that Rust's ARMv7 targets are slightly different from Nix's.

This change adds a function that maps `armv7a` and `armv7l` architectures to `armv7`. The former are used in Raspbian on Raspberry Pi but are unknown to rustc. Rust knows only `armv7`.
@urbas urbas force-pushed the urbas:feature/armv7l-raspbian-support-for-rust branch from a3cc991 to cfc9800 Nov 15, 2019
@ofborg ofborg bot requested a review from Gerschtli Nov 15, 2019
@lopsided98

This comment has been minimized.

Copy link
Contributor

lopsided98 commented Nov 15, 2019

Sorry for not responding, but I can submit my own version of the PR if you want. I see that you integrated most of it already, but I noticed a couple of things still missing (in .cargo/config and bootstrapping hashes).

Also, we put our mapping functions inside different attrsets (rust for me vs. rustPlatform for you). This doesn't much functional difference, but it might be good to get the opinion of a Rust maintainer about where it belongs.

@lopsided98 lopsided98 mentioned this pull request Nov 15, 2019
4 of 10 tasks complete
@lopsided98

This comment has been minimized.

Copy link
Contributor

lopsided98 commented Nov 15, 2019

I submitted it: #73472

@urbas

This comment has been minimized.

Copy link
Author

urbas commented Nov 15, 2019

@lopsided98

This comment has been minimized.

Copy link
Contributor

lopsided98 commented Nov 15, 2019

This PR has the same problem, ofborg just doesn't catch it. On x86_64 macOS, the toRustTarget function returns x86_64-apple-darwin-unknown, which will probably cause the rustc build to fail because that is not a target triple Rust knows about.

@lopsided98

This comment has been minimized.

Copy link
Contributor

lopsided98 commented Nov 16, 2019

Here is my updated mapping function: https://github.com/NixOS/nixpkgs/pull/73472/files#diff-4100057d032c0d790107c2739448233cR14

It is not the most elegant, but it works for all the platforms that we have bootstrap tarballs for, as well as MinGW (which actually did not need a special case) and armv7a.

@urbas

This comment has been minimized.

Copy link
Author

urbas commented Nov 16, 2019

@lopsided98: Sounds much better.

I'm throwing this PR out in favour of #73472

@urbas urbas closed this Nov 16, 2019
Staging automation moved this from Ready to Done Nov 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.