Skip to content
Draft
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
9 changes: 1 addition & 8 deletions lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,6 @@ let
}
.${cpu.name} or cpu.name;
vendor_ = final.rust.platform.vendor;
abi_ =
# We're very explicit about the POWER ELF ABI w/ glibc in our parsing, while Rust is not.
# TODO: Somehow ensure that Rust actually *uses* the correct ABI, and not just a libc-based default.
if (lib.strings.hasPrefix "powerpc" cpu.name) && (lib.strings.hasPrefix "gnuabielfv" abi.name) then
"gnu"
else
abi.name;
in
# TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL.
args.rust.rustcTarget or args.rustc.config or (
Expand All @@ -507,7 +500,7 @@ let
if final.isWasi then
"${cpu_}-wasip1"
else
"${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi_}"}"
"${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi.name}"}"
);

# The name of the rust target if it is standard, or the json file
Expand Down
6 changes: 4 additions & 2 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ rec {
};

ppc64-elfv1 = {
config = "powerpc64-unknown-linux-gnuabielfv1";
# system instead of config, need environment to get parsed during pkgsCross
system = "powerpc64-unknown-linux-gnuabielfv1";
};
ppc64-elfv2 = {
config = "powerpc64-unknown-linux-gnuabielfv2";
# system instead of config, need environment to get parsed during pkgsCross
system = "powerpc64-unknown-linux-gnuabielfv2";
};
ppc64 = ppc64-elfv2;
ppc64-musl = {
Expand Down
4 changes: 2 additions & 2 deletions lib/systems/inspect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ rec {
abi = "elfv1";
};
};
# 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
# This ABI is not the default when building mainline GCC against glibc,
# so it sometimes causes issues in certain packages that make the wrong
# assumption on the used ABI.
isAbiElfv2 = [
{
Expand Down
3 changes: 3 additions & 0 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,13 @@ rec {
abi = "n32";
};

# Clang does not understand these, ABI set via <platform>.gcc.abi & cc-wrapper
gnuabielfv2 = {
name = "gnu";
abi = "elfv2";
};
gnuabielfv1 = {
name = "gnu";
abi = "elfv1";
};

Expand Down
33 changes: 23 additions & 10 deletions lib/systems/platforms.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
# optional fields; currently these are: linux-kernel, gcc, and rustc.

{ lib }:
let
ppc64ForAbi = abi: {
linux-kernel = {
name = "powerpc64";

baseConfig = "ppc64_defconfig";
target = "vmlinux";
autoModules = true;
};

gcc = {
inherit abi;
};
};
in
rec {
pc = {
linux-kernel = {
Expand Down Expand Up @@ -36,15 +51,8 @@ rec {
};
};

ppc64 = {
linux-kernel = {
name = "powerpc64";

baseConfig = "ppc64_defconfig";
target = "vmlinux";
autoModules = true;
};
};
ppc64-elfv1 = ppc64ForAbi "elfv1";
ppc64-elfv2 = ppc64ForAbi "elfv2";

##
## ARM
Expand Down Expand Up @@ -630,7 +638,12 @@ rec {
(import ./examples.nix { inherit lib; }).mipsel-linux-gnu

else if platform.isPower64 then
if platform.isLittleEndian then powernv else ppc64
if platform.isLittleEndian then
powernv
else if platform.isAbiElfv2 then
ppc64-elfv2
else
ppc64-elfv1

else if platform.isLoongArch64 then
loongarch64-multiplatform
Expand Down
4 changes: 0 additions & 4 deletions pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ if $targetPassed && [[ "$targetValue" != "@defaultTarget@" ]] && (( "${NIX_CC_WR
echo "Warning: supplying the --target $targetValue != @defaultTarget@ argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead." >&2
elif [[ $0 != *cpp ]]; then
extraBefore+=(-target @defaultTarget@ @machineFlags@)

if [[ "@explicitAbiValue@" != "" ]]; then
extraBefore+=(-mabi=@explicitAbiValue@)
fi
fi

if [[ "@darwinMinVersion@" ]]; then
Expand Down
27 changes: 7 additions & 20 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ let
getLib
getName
getVersion
hasPrefix
mapAttrsToList
optional
optionalAttrs
optionals
optionalString
removePrefix
removeSuffix
replaceStrings
toList
versionAtLeast
Expand Down Expand Up @@ -331,6 +329,7 @@ let
optional (
targetPlatform ? gcc.cpu && !(targetPlatform.isDarwin && targetPlatform.isAarch64)
) "-mcpu=${targetPlatform.gcc.cpu}"
++ optional (targetPlatform ? gcc.abi) "-mabi=${targetPlatform.gcc.abi}"
++
# -mfloat-abi only matters on arm32 but we set it here
# unconditionally just in case. If the abi specifically sets hard
Expand Down Expand Up @@ -942,24 +941,12 @@ stdenvNoCC.mkDerivation {
## General Clang support
## Needs to go after ^ because the for loop eats \n and makes this file an invalid script
##
+ optionalString isClang (
let
hasUnsupportedGnuSuffix = hasPrefix "gnuabielfv" targetPlatform.parsed.abi.name;
clangCompatibleConfig =
if hasUnsupportedGnuSuffix then
removeSuffix (removePrefix "gnu" targetPlatform.parsed.abi.name) targetPlatform.config
else
targetPlatform.config;
explicitAbiValue = if hasUnsupportedGnuSuffix then targetPlatform.parsed.abi.abi else "";
in
''
# Escape twice: once for this script, once for the one it gets substituted into.
export machineFlags=${escapeShellArg (escapeShellArgs machineFlags)}
export defaultTarget=${clangCompatibleConfig}
export explicitAbiValue=${explicitAbiValue}
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
''
)
+ optionalString isClang ''
# Escape twice: once for this script, once for the one it gets substituted into.
export machineFlags=${escapeShellArg (escapeShellArgs machineFlags)}
export defaultTarget=${targetPlatform.config}
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
''

##
## Extra custom steps
Expand Down
Loading