Skip to content

lib.systems: Internally translate -gnuabielfv<1,2> to -gnu + gcc.abi#493090

Draft
OPNA2608 wants to merge 5 commits intoNixOS:stagingfrom
OPNA2608:fix/ppc64-elfv2-clang-cross
Draft

lib.systems: Internally translate -gnuabielfv<1,2> to -gnu + gcc.abi#493090
OPNA2608 wants to merge 5 commits intoNixOS:stagingfrom
OPNA2608:fix/ppc64-elfv2-clang-cross

Conversation

@OPNA2608
Copy link
Contributor

While GCC supports the powerpc64-unknown-linux-gnuabielfv1 & powerpc64-unknown-linux-gnuabielfv2 triplets, Clang does not.
So using these triplets while configuring compilers and other tools that build upon them leads to issues and hacks.

Instead, set the name that should be used for -gnuabielfv<1,2> to just -gnu, with an annotation of the actual ABI for
GCC / the cc-wrapper. This still allows isAbiElfv<1,2> inspections to work without resulting in triplets that are
unknown to Clang & rustc.


I don't know if this is a good idea, I feel like it kinda just replaces hacks in one location with hacks in another… But it fixes some things ig… I don't feel like merging this as-is is fine without someone with a better understanding of & opinion on the lib.systems stuff having a look. Turning to draft once pings go out.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

…ality

We switched to gnuabielfv1 being the default.
While GCC supports the powerpc64-unknown-linux-gnuabielfv1 & powerpc64-unknown-linux-gnuabielfv2 triplets, Clang does not.
So using these triplets while configuring compilers and other tools that build upon them leads to issues and hacks.

Instead, set the name that should be used for -gnuabielfv<1,2> to just -gnu, with an annotation of the actual ABI for
GCC / the cc-wrapper. This still allows isAbiElfv<1,2> inspections to work without resulting in triplets that are
unknown to Clang & rustc.
@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Feb 22, 2026

let
  pkgs = import ./. { };
  triplets = [
    "powerpc64-linux"
    "powerpc64-unknown-linux-gnuabielfv1"
    "powerpc64-unknown-linux-gnuabielfv2"
    "powerpc64-unknown-linux-musl"
  ];
  examples = [
    "ppc64-elfv1"
    "ppc64-elfv2"
  ];
  inheritDetails = platform: {
    inherit (platform) config isAbiElfv1 isAbiElfv2;
    parsed-abi = builtins.removeAttrs platform.parsed.abi [ "assertions" ];
    gcc-abi = platform.gcc.abi or null;
  };
in
(builtins.map (triplet:
  let
    crossPkgs = import ./. { crossSystem = triplet; };
  in
  (inheritDetails crossPkgs.stdenv.hostPlatform) // {
    via = "triplet-${triplet}";
  }
) triplets)
++ (builtins.map (example:
  let
    crossPkgs = pkgs.pkgsCross.${example};
  in
  (inheritDetails crossPkgs.stdenv.hostPlatform) // {
    via = "example-${example}";
  }
) examples)
[
  {
    config = "powerpc64-unknown-linux-gnu";
    gcc-abi = "elfv1";
    isAbiElfv1 = true;
    isAbiElfv2 = false;
    parsed-abi = {
      _type = "abi";
      abi = "elfv1";
      name = "gnu";
    };
    via = "triplet-powerpc64-linux";
  }
  {
    config = "powerpc64-unknown-linux-gnu";
    gcc-abi = "elfv1";
    isAbiElfv1 = true;
    isAbiElfv2 = false;
    parsed-abi = {
      _type = "abi";
      abi = "elfv1";
      name = "gnu";
    };
    via = "triplet-powerpc64-unknown-linux-gnuabielfv1";
  }
  {
    config = "powerpc64-unknown-linux-gnu";
    gcc-abi = "elfv2";
    isAbiElfv1 = false;
    isAbiElfv2 = true;
    parsed-abi = {
      _type = "abi";
      abi = "elfv2";
      name = "gnu";
    };
    via = "triplet-powerpc64-unknown-linux-gnuabielfv2";
  }
  {
    config = "powerpc64-unknown-linux-musl";
    gcc-abi = "elfv2";
    isAbiElfv1 = false;
    isAbiElfv2 = true;
    parsed-abi = {
      _type = "abi";
      name = "musl";
    };
    via = "triplet-powerpc64-unknown-linux-musl";
  }
  {
    config = "powerpc64-unknown-linux-gnu";
    gcc-abi = "elfv1";
    isAbiElfv1 = true;
    isAbiElfv2 = false;
    parsed-abi = {
      _type = "abi";
      abi = "elfv1";
      name = "gnu";
    };
    via = "example-ppc64-elfv1";
  }
  {
    config = "powerpc64-unknown-linux-gnu";
    gcc-abi = "elfv2";
    isAbiElfv1 = false;
    isAbiElfv2 = true;
    parsed-abi = {
      _type = "abi";
      abi = "elfv2";
      name = "gnu";
    };
    via = "example-ppc64-elfv2";
  }
]

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: lib The Nixpkgs function library labels Feb 22, 2026
@OPNA2608 OPNA2608 marked this pull request as draft February 22, 2026 18:38
@alyssais
Copy link
Member

@Ericson2314 I remember discussing with you how we should handle mismatching triples between compilers with you years ago. What do you think is right here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 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-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 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.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants