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

gcc.libgcc: compare host and target platforms, rather than their triples #264976

Merged
2 commits merged into from Nov 4, 2023
Merged

gcc.libgcc: compare host and target platforms, rather than their triples #264976

2 commits merged into from Nov 4, 2023

Conversation

ghost
Copy link

@ghost ghost commented Nov 2, 2023

Description of changes

The rest of our gcc expression prepends "${targetPlatform.config}-" to paths and binaries if hostPlatform!=targetPlatform. The libgcc.nix expression was using hostPlatform.config!=targetPlatform.config, which caused it to look in the wrong place when moving files. This commit corrects that.

Closes #263040

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/)
  • 23.11 Release Notes (or backporting 23.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.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Nov 2, 2023
@ghost ghost changed the title tests.cross.sanity: add pkgsCross.gnu64.bash gcc.libgcc: compare host and target platforms, rathern than their triples Nov 2, 2023
@ghost ghost changed the base branch from master to staging November 2, 2023 11:11
@ghost ghost marked this pull request as ready for review November 2, 2023 11:12
@ghost ghost requested review from alyssais and Ericson2314 as code owners November 2, 2023 11:12
@ghost
Copy link
Author

ghost commented Nov 2, 2023

@ofborg build pkgsCross.gnu64_simplekernel.bash

@@ -91,7 +91,7 @@ stdenv.mkDerivation rec {

strictDeps = true;
# Note: Bison is needed because the patches above modify parse.y.
depsBuildBuild = [ buildPackages.stdenv.cc ];
depsBuildBuild = [ stdenv ];
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? I've never seen depending on entire other stdenvs like that.

Copy link
Member

Choose a reason for hiding this comment

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

If we just skip this, everything else looks good to me.

Copy link
Author

Choose a reason for hiding this comment

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

Why this change?

Because !(buildPackages.stdenv.cc?__spliced).

See #264992 for the test case.

The reproducer requires two platforms which have the same triple but aren't ==-equal to each other. People are creating them on their own and getting burned by this. Latest example:

There aren't any in lib.systems.examples, so #264992 adds one in order to be able to answer your question "why this change".

Copy link
Author

Choose a reason for hiding this comment

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

Why this change?

Because: #264992 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

If we just skip this, everything else looks good to me.

I moved it into

@lilyball
Copy link
Member

lilyball commented Nov 3, 2023

It looks like this should fix #263040, except you missed a comparison, libgcc.nix does another config check in preFixupLibGccPhase that needs to be updated.

@ghost ghost marked this pull request as draft November 4, 2023 01:44
@ghost
Copy link
Author

ghost commented Nov 4, 2023

It looks like this should fix #263040, except you missed a comparison, libgcc.nix does another config check in preFixupLibGccPhase that needs to be updated.

Thank you @lilyball! Verifying this now.

We have several cross-compilation bugs that show up if
hostPlatform!=buildPlatform yet
hostPlatform.config==buildPlatform.config.

These bugs have appeared and disappeared as we've fiddled with the
definition of equality for platform objects.  This commit adds a
clear-cut case where they are *not* equal and never will be, so we
can test it.
…ples

The rest of our gcc expression prepends "${targetPlatform.config}-"
to paths and binaries if `hostPlatform!=targetPlatform`.  The
`libgcc.nix` expression was using
'hostPlatform.config!=targetPlatform.config`, which caused it to
look in the wrong place when moving files.  This commit corrects that.
@ghost
Copy link
Author

ghost commented Nov 4, 2023

Thank you @lilyball! Verifying this now.

I have verified that your test case (deflakified below) builds correctly at a37a7d2

nix build --impure --expr 'let pkgs = import <nixpkgs> {
  crossOverlays = [(self: super: {
    glibcCross = super.glibcCross.overrideAttrs (old: {
      passthru = builtins.removeAttrs old.passthru [ "libgcc" ];
    });
  })];
}; in pkgs.pkgsLLVM.buildPackages.gcc.cc'

@ghost ghost marked this pull request as ready for review November 4, 2023 03:21
@ghost
Copy link
Author

ghost commented Nov 4, 2023

I rebuilt the entire pkgs.tests.cross.sanity mega-regression-suite at commit a37a7d2.

This won't break anything. If it does I take full responsibility.

This pull request was closed.
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 sort platform than than they will be run on 6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 10.rebuild-linux: 1-10
Projects
None yet
2 participants