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: use more complete meta.platforms list when doing cross compilation #379671

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Feb 5, 2025

Before building rust-hypervisor-firmware failed like:

 ➜ nix eval -f. rust-hypervisor-firmware
...
...
       error: Package ‘rust-hypervisor-firmware-0.4.2’ in nixpkgs/pkgs/applications/virtualization/rust-hypervisor-firmware/default.nix:60 is not available on the requested hostPlatform:
         hostPlatform.config = "x86_64-elf"
         package.meta.platforms = [ ]
         package.meta.badPlatforms = [
           {
             abi = {
               abi = "n32";
             };
             cpu = {
               bits = 64;
               family = "mips";
             };
           }
         ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

with this change it can be compiled properly:

 ➜ nix eval -f. rust-hypervisor-firmware
/nix/store/b0hlzbvj8wyrpxavb1jxww6c4v674wsa-rust-hypervisor-firmware-x86_64-elf-0.4.2.drv

Motivated by #377247

cc @astro

Reviewer note: to successful test this you must cherry-pick #378694

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Feb 5, 2025
@nix-owners nix-owners bot requested review from winterqt, Mic92, figsoda and zowoq February 5, 2025 18:36
@SuperSandro2000 SuperSandro2000 force-pushed the rustc-cross-meta-platforms branch from acf32ed to 22c1d88 Compare February 5, 2025 18:41
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Feb 5, 2025
@SuperSandro2000 SuperSandro2000 force-pushed the rustc-cross-meta-platforms branch from 22c1d88 to dcdfb2e Compare February 5, 2025 18:49
@SuperSandro2000 SuperSandro2000 force-pushed the rustc-cross-meta-platforms branch from dcdfb2e to 1678ec5 Compare February 5, 2025 18:49
if (stdenv.buildPlatform != stdenv.hostPlatform) then
rustc.targetPlatforms
else
rustc.tier1TargetPlatforms;
Copy link
Member

Choose a reason for hiding this comment

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

No, this would be incorrect. This describes which platforms we can build the compiler for. If you made this change, it would express that rustc can be built for any platform that rustc can target, which is not true.

One change that would be correct, though, would be that we could use a broader list for fastCross — in that case , the "rustc" package is actually only libstd, so we could list every platform libstd supports in the platform list.

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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants