Skip to content

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

Merged
2 commits merged intomasterfrom
unknown repository
Nov 4, 2023
Merged

gcc.libgcc: compare host and target platforms, rather than their triples#264976
2 commits merged intomasterfrom
unknown repository

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 platform than they will be used 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
@ofborg ofborg 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 Nov 2, 2023
@ghost ghost changed the base branch from master to staging November 2, 2023 11:11
@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: kernel The Linux kernel 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 6.topic: lib The Nixpkgs function library labels Nov 2, 2023
@ghost ghost marked this pull request as ready for review November 2, 2023 11:12
@ghost ghost requested review from Ericson2314 and alyssais as code owners November 2, 2023 11:12
@github-actions github-actions bot removed 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: kernel The Linux kernel 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment labels Nov 2, 2023
@ghost
Copy link
Author

ghost commented Nov 2, 2023

@ofborg build pkgsCross.gnu64_simplekernel.bash

@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. and removed 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 Nov 2, 2023
@ofborg ofborg bot requested a review from dtzWill November 2, 2023 13:29
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Nov 2, 2023
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

@ghost ghost changed the title gcc.libgcc: compare host and target platforms, rathern than their triples gcc.libgcc: compare host and target platforms, rather than their triples Nov 3, 2023
@ghost ghost requested a review from Ericson2314 November 3, 2023 07:01
@ghost ghost mentioned this pull request Nov 3, 2023
13 tasks
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 3, 2023
@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 platform than they will be used on 6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

2 participants