Skip to content
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
3 changes: 0 additions & 3 deletions pkgs/applications/blockchains/polkadot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,5 @@ rustPlatform.buildRustPackage rec {
maintainers = with maintainers; [ akru andresilva FlorianFranzen RaghavSood ];
# See Iso::from_arch in src/isa/mod.rs in cranelift-codegen-meta.
platforms = intersectLists platforms.unix (platforms.aarch64 ++ platforms.s390x ++ platforms.riscv64 ++ platforms.x86);
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
};
}
4 changes: 0 additions & 4 deletions pkgs/applications/misc/pagefind/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
, gzip
, nodejs
, rustc
, stdenv
, wasm-bindgen-cli
, wasm-pack
}:
Expand Down Expand Up @@ -121,9 +120,6 @@ rustPlatform.buildRustPackage rec {
license = licenses.mit;
maintainers = with maintainers; [ pbsds ];
platforms = platforms.unix;
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
mainProgram = "pagefind";
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ for p in "${params[@]}"; do
done

if $needsTarget; then
extraBefore+=(-target @defaultTarget@ @march@)
extraBefore+=(-target @defaultTarget@ @machineFlags@)
fi
77 changes: 30 additions & 47 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let
concatMapStrings
concatStringsSep
escapeShellArg
escapeShellArgs
getBin
getDev
getLib
Expand Down Expand Up @@ -234,6 +235,32 @@ let
then guess
else null;

thumb = if targetPlatform.gcc.thumb then "thumb" else "arm";
tune = if targetPlatform ? gcc.tune
then findBestTuneApproximation targetPlatform.gcc.tune
else null;

# Machine flags. These are necessary to support

# TODO: We should make a way to support miscellaneous machine
# flags and other gcc flags as well.

machineFlags =
# Always add -march based on cpu in triple. Sometimes there is a
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
# that case.
optional (targetPlatform ? gcc.arch && !(targetPlatform.isDarwin && targetPlatform.isAarch64) && isGccArchSupported targetPlatform.gcc.arch) "-march=${targetPlatform.gcc.arch}" ++
# TODO: aarch64-darwin has mcpu incompatible with gcc
optional (targetPlatform ? gcc.cpu && !(targetPlatform.isDarwin && targetPlatform.isAarch64)) "-mcpu=${targetPlatform.gcc.cpu}" ++
# -mfloat-abi only matters on arm32 but we set it here
# unconditionally just in case. If the abi specifically sets hard
# vs. soft floats we use it here.
optional (targetPlatform ? gcc.float-abi) "-mfloat-abi=${targetPlatform.gcc.float-abi}" ++
optional (targetPlatform ? gcc.fpu) "-mfpu=${targetPlatform.gcc.fpu}" ++
optional (targetPlatform ? gcc.mode) "-mmode=${targetPlatform.gcc.mode}" ++
optional (targetPlatform ? gcc.thumb) "-m${thumb}" ++
optional (tune != null) "-mtune=${tune}";

defaultHardeningFlags = bintools.defaultHardeningFlags or [];

# if cc.hardeningUnsupportedFlagsByTargetPlatform exists, this is
Expand Down Expand Up @@ -610,53 +637,11 @@ stdenvNoCC.mkDerivation {
export hardening_unsupported_flags="${concatStringsSep " " ccHardeningUnsupportedFlags}"
''

# Machine flags. These are necessary to support

# TODO: We should make a way to support miscellaneous machine
# flags and other gcc flags as well.

# Always add -march based on cpu in triple. Sometimes there is a
# discrepency (x86_64 vs. x86-64), so we provide an "arch" arg in
# that case.
#
# For clang, this is handled in add-clang-cc-cflags-before.sh

# TODO: aarch64-darwin has mcpu incompatible with gcc
+ optionalString ((targetPlatform ? gcc.arch) && !isClang && !(targetPlatform.isDarwin && targetPlatform.isAarch64) &&
isGccArchSupported targetPlatform.gcc.arch) ''
echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
''

# -mcpu is not very useful, except on PowerPC where it is used
# instead of march. On all other platforms you should use mtune
# and march instead.
# TODO: aarch64-darwin has mcpu incompatible with gcc
+ optionalString ((targetPlatform ? gcc.cpu) && (isClang || !(targetPlatform.isDarwin && targetPlatform.isAarch64))) ''
echo "-mcpu=${targetPlatform.gcc.cpu}" >> $out/nix-support/cc-cflags-before
+ lib.optionalString (!isClang && machineFlags != []) ''
printf "%s\n" ${lib.escapeShellArgs machineFlags} >> $out/nix-support/cc-cflags-before
''

# -mfloat-abi only matters on arm32 but we set it here
# unconditionally just in case. If the abi specifically sets hard
# vs. soft floats we use it here.
+ optionalString (targetPlatform ? gcc.float-abi) ''
echo "-mfloat-abi=${targetPlatform.gcc.float-abi}" >> $out/nix-support/cc-cflags-before
''
+ optionalString (targetPlatform ? gcc.fpu) ''
echo "-mfpu=${targetPlatform.gcc.fpu}" >> $out/nix-support/cc-cflags-before
''
+ optionalString (targetPlatform ? gcc.mode) ''
echo "-mmode=${targetPlatform.gcc.mode}" >> $out/nix-support/cc-cflags-before
''
+ optionalString (targetPlatform ? gcc.thumb) ''
echo "-m${if targetPlatform.gcc.thumb then "thumb" else "arm"}" >> $out/nix-support/cc-cflags-before
''
+ (let tune = if targetPlatform ? gcc.tune
then findBestTuneApproximation targetPlatform.gcc.tune
else null;
in optionalString (tune != null) ''
echo "-mtune=${tune}" >> $out/nix-support/cc-cflags-before
'')

# TODO: categorize these and figure out a better place for them
+ optionalString targetPlatform.isWindows ''
hardening_unsupported_flags+=" pic"
Expand Down Expand Up @@ -718,9 +703,7 @@ stdenvNoCC.mkDerivation {
##
+ optionalString isClang ''
# Escape twice: once for this script, once for the one it gets substituted into.
export march=${escapeShellArg
(optionalString (targetPlatform ? gcc.arch)
(escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
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
''
Expand Down
3 changes: 0 additions & 3 deletions pkgs/by-name/re/rerun/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,5 @@ rustPlatform.buildRustPackage rec {
];
maintainers = with maintainers; [ SomeoneSerge ];
mainProgram = "rerun";
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
};
}
3 changes: 0 additions & 3 deletions pkgs/by-name/su/surrealist/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,5 @@ in stdenv.mkDerivation (finalAttrs: {
mainProgram = "surrealist";
maintainers = with maintainers; [ frankp ];
platforms = platforms.linux;
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
};
})
3 changes: 0 additions & 3 deletions pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ let
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ huantian wackbyte ];
platforms = lib.platforms.linux;
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
};
};

Expand Down
4 changes: 1 addition & 3 deletions pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ in stdenv.mkDerivation (finalAttrs: {
stdenv.targetPlatform.rust.rustcTargetSpec

# Other targets that don't need any extra dependencies to build.
# Temporarily broken if some global compiler flags are set:
# https://github.com/NixOS/nixpkgs/pull/317273
] ++ optionals (!fastCross && !lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] && stdenv.hostPlatform.gcc.thumb or true) [
] ++ optionals (!fastCross) [
"wasm32-unknown-unknown"

# (build!=target): When cross-building a compiler we need to add
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/swift/wrapper/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ for ((i=0; i < ${#extraBefore[@]}; i++));do
# TODO: Assumes macOS.
extraBefore[i]="${extraBefore[i]/-apple-darwin/-apple-macosx${MACOSX_DEPLOYMENT_TARGET:-11.0}}"
;;
-march=*)
-march=*|-mcpu=*|-mfloat-abi=*|-mfpu=*|-mmode=*|-mthumb|-marm|-mtune=*)
[[ i -gt 0 && ${extraBefore[i-1]} == -Xcc ]] && continue
extraBefore=(
"${extraBefore[@]:0:i}"
Expand Down
4 changes: 0 additions & 4 deletions pkgs/servers/ldap/lldap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
, nixosTests
, rustPlatform
, rustc
, stdenv
, wasm-bindgen-cli
, wasm-pack
, which
Expand Down Expand Up @@ -85,9 +84,6 @@ in rustPlatform.buildRustPackage (commonDerivationAttrs // {
changelog = "https://github.com/lldap/lldap/blob/v${lldap.version}/CHANGELOG.md";
license = licenses.gpl3Only;
platforms = platforms.linux;
# See comment about wasm32-unknown-unknown in rustc.nix.
broken = lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
maintainers = with maintainers; [ bendlas ];
mainProgram = "lldap";
};
Expand Down
5 changes: 1 addition & 4 deletions pkgs/servers/teleport/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ buildGoModule rec {
platforms = platforms.unix;
# go-libfido2 is broken on platforms with less than 64-bit because it defines an array
# which occupies more than 31 bits of address space.
broken = stdenv.hostPlatform.parsed.cpu.bits < 64 ||
# See comment about wasm32-unknown-unknown in rustc.nix.
lib.any (a: lib.hasAttr a stdenv.hostPlatform.gcc) [ "cpu" "float-abi" "fpu" ] ||
!stdenv.hostPlatform.gcc.thumb or true;
broken = stdenv.hostPlatform.parsed.cpu.bits < 64;
};
}