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

Add ELFvx ABIs for PowerPC64 #182807

Merged
merged 6 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/systems/doubles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ in {
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabin32; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; });
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv1; })
++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv2; });
minijackson marked this conversation as resolved.
Show resolved Hide resolved
illumos = filterDoubles predicates.isSunOS;
linux = filterDoubles predicates.isLinux;
netbsd = filterDoubles predicates.isNetBSD;
Expand Down
5 changes: 2 additions & 3 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ rec {
};

ppc64 = {
config = "powerpc64-unknown-linux-gnu";
gcc = { abi = "elfv2"; }; # for gcc configuration
config = "powerpc64-unknown-linux-gnuabielfv2";
};
ppc64-musl = {
config = "powerpc64-unknown-linux-musl";
gcc = { abi = "elfv2"; }; # for gcc configuration
gcc = { abi = "elfv2"; };
};

sheevaplug = {
Expand Down
9 changes: 8 additions & 1 deletion lib/systems/inspect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ rec {
isx86_64 = { cpu = { family = "x86"; bits = 64; }; };
isPower = { cpu = { family = "power"; }; };
isPower64 = { cpu = { family = "power"; bits = 64; }; };
# This ABI is the default in NixOS PowerPC64 BE, but not on mainline GCC,
# so it sometimes causes issues in certain packages that makes the wrong
# assumption on the used ABI.
isAbiElfv2 = [
{ abi = { abi = "elfv2"; }; }
{ abi = { name = "musl"; }; cpu = { family = "power"; bits = 64; }; }
];
isx86 = { cpu = { family = "x86"; }; };
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
Expand Down Expand Up @@ -64,7 +71,7 @@ rec {
isNone = { kernel = kernels.none; };

isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf ];
isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf gnuabielfv1 gnuabielfv2 ];
isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf muslabin32 muslabi64 ];
isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ];

Expand Down
10 changes: 10 additions & 0 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ rec {
The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead.
'';
}
{ assertion = platform: with platform; !(isPower64 && isBigEndian);
message = ''
The "gnu" ABI is ambiguous on big-endian 64-bit PowerPC. Use "gnuabielfv2" or "gnuabielfv1" instead.
'';
}
];
};
gnuabi64 = { abi = "64"; };
Expand All @@ -361,6 +366,9 @@ rec {
gnuabin32 = { abi = "n32"; };
muslabin32 = { abi = "n32"; };

minijackson marked this conversation as resolved.
Show resolved Hide resolved
gnuabielfv2 = { abi = "elfv2"; };
gnuabielfv1 = { abi = "elfv1"; };

musleabi = { float = "soft"; };
musleabihf = { float = "hard"; };
musl = {};
Expand Down Expand Up @@ -464,6 +472,8 @@ rec {
if lib.versionAtLeast (parsed.cpu.version or "0") "6"
then abis.gnueabihf
else abis.gnueabi
# Default ppc64 BE to ELFv2
else if isPower64 parsed && isBigEndian parsed then abis.gnuabielfv2
Comment on lines +475 to +476
Copy link

Choose a reason for hiding this comment

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

Were these two lines really essential?

They cause a problem: now if we parse powerpc64-apple-linux-gnu and then unparse it, we get back powerpc64-apple-linux-gnuabielfv2. That disagrees with gnu-config:

$ /nix/store/rvxxihfvp9z7h4lw6w60lv7mvsn97dwn-gnu-config-2023-01-21/config.sub powerpc64-apple-linux-gnu
powerpc64-apple-linux-gnu

I still agree with nixpkgs PowerPC64-BE using elfv2, I just don't think the triple parsing routine is the right place to impose that default...

I've included a commit to revert these two lines as part of #235230; if that's a problem, or if there's a different way we should be handling this, please let me know.

Copy link

Choose a reason for hiding this comment

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

428c5456060ebe25ac889d9f666dfd3d114cbff0

else abis.gnu
else abis.unknown;
};
Expand Down
4 changes: 2 additions & 2 deletions pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ let
gnueabihf = lib.systems.parse.abis.musleabihf;
gnuabin32 = lib.systems.parse.abis.muslabin32;
gnuabi64 = lib.systems.parse.abis.muslabi64;
gnuabielfv2 = lib.systems.parse.abis.musl;
gnuabielfv1 = lib.systems.parse.abis.musl;
# The following two entries ensure that this function is idempotent.
musleabi = lib.systems.parse.abis.musleabi;
musleabihf = lib.systems.parse.abis.musleabihf;
Expand Down Expand Up @@ -257,8 +259,6 @@ let
crossSystem = {
isStatic = true;
parsed = makeMuslParsedPlatform stdenv.hostPlatform.parsed;
} // lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") {
gcc.abi = "elfv2";
Copy link

Choose a reason for hiding this comment

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

@OPNA2608, if you need a quick fix, the root cause is the deletion of these two lines in 82ff1f5.

};
});
};
Expand Down