Skip to content

gcc: fix inconsistency in isCross condition#389469

Merged
K900 merged 3 commits intoNixOS:masterfrom
SFrijters:gcc-fix-cross-inconsistency
Mar 13, 2025
Merged

gcc: fix inconsistency in isCross condition#389469
K900 merged 3 commits intoNixOS:masterfrom
SFrijters:gcc-fix-cross-inconsistency

Conversation

@SFrijters
Copy link
Member

In libgcc.nix, targetPlatformSlash is set by checking if hostPlatform == targetPlatform. In default.nix, targetConfig (which is also going to be part of the path) is also set by checking if hostPlatform == targetPlatform.

However, in common.nix, the recently added isCross is set by checking if hostPlatform.config == targetPlatform.config. This means that for platforms like '-nolibc' the paths in common.nix are not set up correctly for libgcc.nix to find and move libgcc_s.so .

Changing isCross to also check hostPlatform == targetPlatform fixes this issue.

Followup to #380325 .
Fixes #383914 (comment) .

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.

@SFrijters SFrijters requested a review from K900 March 13, 2025 09:52
@SFrijters SFrijters changed the title gcc: fix inconsistencty in isCross condition gcc: fix inconsistency in isCross condition Mar 13, 2025
In libgcc.nix, `targetPlatformSlash` is set by checking if hostPlatform == targetPlatform.
In default.nix, `targetConfig` (which is also going to be part of the path) is also set by checking if hostPlatform == targetPlatform.

However, in common.nix, the recently added `isCross` is set by checking if hostPlatform.config == targetPlatform.config.
This means that for platforms like '-nolibc' the paths in common.nix are not set up correctly for libgcc.nix to find and move libgcc_s.so .

Changing isCross to also check hostPlatform == targetPlatform fixes this issue.
@SFrijters SFrijters force-pushed the gcc-fix-cross-inconsistency branch from 539fbd0 to 54849e2 Compare March 13, 2025 09:52
@SFrijters SFrijters requested a review from Mindavi March 13, 2025 09:53

let
forceLibgccToBuildCrtStuff = import ./libgcc-buildstuff.nix { inherit lib stdenv; };
isCross = with stdenv; targetPlatform.config != hostPlatform.config;
Copy link
Contributor

Choose a reason for hiding this comment

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

These really should be lib.systems.equals, all of them, now that I think about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just those three or everything in gcc? A quick git grep 'Platform *[!=]=' | wc -l inside pkgs/development/compilers/gcc gives me 40 hits.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, all of them in nixpkgs, technically...

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but I don't want to let this single line change scope creep into doing a treewide update.
I've replaced things inside gcc, a simple rebuild of nix-build -A gcc was a no-op, but I'm not sure how to test this properly.

@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Mar 13, 2025
@SFrijters SFrijters force-pushed the gcc-fix-cross-inconsistency branch from b705345 to d8634f9 Compare March 13, 2025 10:37
@SFrijters
Copy link
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 389469


x86_64-linux

@SFrijters SFrijters changed the base branch from staging to master March 13, 2025 12:21
@K900 K900 merged commit 7c846d3 into NixOS:master Mar 13, 2025
33 of 35 checks passed
@SFrijters SFrijters deleted the gcc-fix-cross-inconsistency branch March 13, 2025 14:55
@SFrijters SFrijters mentioned this pull request Jul 12, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: gcc-14 for cross due to broken symlink

2 participants