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

makeRustPlatform: handle json targets #95405

Closed
wants to merge 1 commit into from

Conversation

aaronjanse
Copy link
Member

Motivation for this change

I'm working to compile the Redox kernel using Nix, which involves using a custom json target (x86_64-unknown-none.json) in buildRustPackage.

At the end of the compile process, the target json path is not "shortened" (relevant Cargo code), causing a failure:

    Finished dev [optimized + debuginfo] target(s) in 42.60s
cp: missing destination file operand after 'target//nix/store/dk55xqrgyavw1gizs9b07p71j7przki0-x86_64-unknown-none.json/debug-tmp/'
Try 'cp --help' for more information.
builder for '/nix/store/dhpb8p1nibwr8hw95rymlipcqvw3swrs-redox-iso-latest-x86_64-unknown-redox.drv' failed with exit code 1
error: build of '/nix/store/dhpb8p1nibwr8hw95rymlipcqvw3swrs-redox-iso-latest-x86_64-unknown-redox.drv' failed

Ping to @Ericson2314 because I've seen you in relevant Rust community discussions. I'm currently using cargo-sysroot to compile to a custom target using Nix. Once I get everything cleaned up and fully declarative, I'll try to figure out how other Nix people can re-use my code for following tutorials like os.phil-opp.com (assuming there isn't an existing solution for a custom cargo sysroot in Nix derivations).

Things done
  • added handling for when a buildRustPackage target is defined by a JSON file
  • avoided causing existing Rust packages to need to be recompiled
  • 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 nixpkgs-review --run "nixpkgs-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.

@aaronjanse
Copy link
Member Author

aaronjanse commented Aug 15, 2020

I just realized there's a bug in the code I used to test this. I'm closing this until I re-test

@aaronjanse aaronjanse closed this Aug 15, 2020
@Ericson2314
Copy link
Member

It would be cool to make the JSON file from Nix, based on the hostPlatform. C.f. hostPlatform.platform.gcc.

@aaronjanse
Copy link
Member Author

Ah, so the target based on the hostPlatform is already implemented (this the rust.toRustTarget) thing. Using a target json file is useful for scenarios such as OS development where you want to compile one project specially (e.g. to run on bare metal while blacklisting certain asm instructions). See #95542 for a better version of this PR

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.

None yet

2 participants