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

Rust and cargo improvements #16052

Merged
merged 4 commits into from
Jun 16, 2016
Merged

Rust and cargo improvements #16052

merged 4 commits into from
Jun 16, 2016

Conversation

dvc94ch
Copy link
Contributor

@dvc94ch dvc94ch commented Jun 7, 2016

Motivation for this change
  • Enable cross-compiling std crates
  • Prepare for the 1.10.0 release when we can bootstrap from release tarball
  • Update cargo and use release tarball
  • Add scripts to fetch release tarball hashes for supported platforms

To try out rust on arm (depends on #15867):

with import <nixpkgs> {};

let
  pkgs = import ../../../nixpkgs;
  pkgsNative = pkgs {};
  pkgsCross = pkgs {
    inherit system;
    inherit crossSystem;
  };
  crossSystem = rec {
    config = "arm-linux-gnueabihf";
    bigEndian = false;
    arch = "arm";
    float = "hard";
    fpu = "vfpv3-d16";
    withTLS = true;
    libc = "glibc";
    platform = platforms.armv7l-hf-multiplatform;
    openssl.system = "linux-generic32";
    inherit (platform) gcc;
  };
  rustc = pkgsNative.rustc.override {
    targets = ["armv7-unknown-linux-gnueabihf"];
    targetToolchains = [pkgsCross.gccCrossStageFinal];
  };
  cargo = pkgsNative.cargo.override {
    inherit rustc;
  };
in
stdenv.mkDerivation rec {
    name = "arm-hello";

    buildInputs = [ cargo pkgsCross.gccCrossStageFinal qemu ];

    shellHook = ''
        PS1="rust-arm> "
        alias build="cargo build --target=${rustc.target}"
        alias run-debug="qemu-arm target/${rustc.target}/debug/${name}"
        alias run-release="qemu-arm target/${rustc.target}/release/${name}"
    '';
}
Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @wizeman, @abbradar and @madjar to be potential reviewers

@jagajaga
Copy link
Member

jagajaga commented Jun 7, 2016

cc @wizeman

@dvc94ch dvc94ch force-pushed the rust-cross branch 4 times, most recently from 8a27ac3 to 30d5f37 Compare June 8, 2016 09:52
@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 11, 2016

don't merge this just yet, I want to rework this. rust is moving to using cargo as a build system, so the rustc and cargo packages can share the bootstrapping code. should this be a new package then? or can we put the cargo and rustc code in the same folder so that we can share the bootstrapping code through local imports without polluting all-packages?

@the-kenny
Copy link
Contributor

I'm fine with moving cargo and rustc to the same folder if that simplifies the implementation.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 14, 2016

So final building and testing is still pending, but I think it should be ok. If someone wants to test it on mac osx to make sure there are no regressions, that would be good...

@dvc94ch dvc94ch force-pushed the rust-cross branch 2 times, most recently from fbefb0d to 3196059 Compare June 14, 2016 17:54
@the-kenny
Copy link
Contributor

Seems like there is an issue with evaluating the package set:

% nix-env -f . -qa
error: getting status of ‘/home/moritz/dev/nixpkgs/pkgs/development/tools/build-managers/cargo’: No such file or directory

@the-kenny
Copy link
Contributor

Also, personally, I'd like an alias for rustc in all-packages.nix just like for cargo.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 14, 2016

mmh that is right there is no build-managers cargo anymore. have you added any custom patches to nixpkgs? I'm not having that problem... I rebased on master and added a sha256 fix for the exa package, and added a rustc alias, can you try again?

@the-kenny
Copy link
Contributor

I didn't at the time. I re-applied everything after your recent rebase and now it's evaluating fine.

@the-kenny
Copy link
Contributor

I'll check if everything builds fine with sandbox . Otherwise 👍

@the-kenny
Copy link
Contributor

@dvc94ch

nix-build . -A rustc 
...
output path ‘/nix/store/dx95c8mp9g1gqvy5qin10xzwngw2yr97-rust-e4e8b66’ has r:sha256 hash ‘1pz4qx70mqv78fxm4w1mq7csk5pssq4qmr2vwwb5v8hyx03caff8’ when ‘167rh7hs77grn895h54s7np7f0k7b6i8z4wdfinncg4chy08hxq1’ was expected

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 15, 2016

I get these spurious hash changes sometimes too. My rust src is currently cached, so I didn't notice the change. I think fetchgit isn't 100% deterministic.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 15, 2016

Pushed the hash change

@the-kenny
Copy link
Contributor

Ugh, non-determinism in fetchgit isn't good. It pulls quite a bunch of submodules (I think), maybe it's related to that?

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 15, 2016

Maybe. If I would make a wild guess I'd say this happens when a submodule
gets a new branch. But I haven't looked into this, since once it's
committed the package is in the binary cache, so it isn't an issue until
you make a change...
On Jun 15, 2016 1:13 PM, "Moritz Ulrich" [email protected] wrote:

Ugh, non-determinism in fetchgit isn't good. It pulls quite a bunch of
submodules (I think), maybe it's related to that?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16052 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAtRr6861CK49DlWtNivyJUDE2nav8z7ks5qL95SgaJpZM4IwQmw
.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jun 15, 2016

@the-kenny I know I'm inpatient, but I'll ask anyway. Are we good to go?

@the-kenny
Copy link
Contributor

the-kenny commented Jun 16, 2016

Sorry! I was busy at work yesterday (while my machine built all of Rust in Nix). To me it looks good. I think it's fine to merge it, but we should try to investigate the sha256 issue further.

@the-kenny the-kenny merged commit e72282b into NixOS:master Jun 16, 2016
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.

5 participants