diff --git a/pkgs/applications/blockchains/polkadot/default.nix b/pkgs/applications/blockchains/polkadot/default.nix index f247b05eb93ab..cfc66da2d586f 100644 --- a/pkgs/applications/blockchains/polkadot/default.nix +++ b/pkgs/applications/blockchains/polkadot/default.nix @@ -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; }; } diff --git a/pkgs/applications/misc/pagefind/default.nix b/pkgs/applications/misc/pagefind/default.nix index aa0fb08984edc..2da4e5eb7eb10 100644 --- a/pkgs/applications/misc/pagefind/default.nix +++ b/pkgs/applications/misc/pagefind/default.nix @@ -8,7 +8,6 @@ , gzip , nodejs , rustc -, stdenv , wasm-bindgen-cli , wasm-pack }: @@ -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"; }; } diff --git a/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh b/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh index a1d06b9c6b0ae..51bfeb18f58a1 100644 --- a/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh +++ b/pkgs/build-support/cc-wrapper/add-clang-cc-cflags-before.sh @@ -7,5 +7,5 @@ for p in "${params[@]}"; do done if $needsTarget; then - extraBefore+=(-target @defaultTarget@ @march@) + extraBefore+=(-target @defaultTarget@ @machineFlags@) fi diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 4adc1dcb1f8d8..d842f3fc70909 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -67,6 +67,7 @@ let concatMapStrings concatStringsSep escapeShellArg + escapeShellArgs getBin getDev getLib @@ -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 @@ -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" @@ -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 '' diff --git a/pkgs/by-name/re/rerun/package.nix b/pkgs/by-name/re/rerun/package.nix index 6fedb10cfed12..4d9c8da8041c0 100644 --- a/pkgs/by-name/re/rerun/package.nix +++ b/pkgs/by-name/re/rerun/package.nix @@ -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; }; } diff --git a/pkgs/by-name/su/surrealist/package.nix b/pkgs/by-name/su/surrealist/package.nix index 53290ea042c73..0c1e0abd1e57b 100644 --- a/pkgs/by-name/su/surrealist/package.nix +++ b/pkgs/by-name/su/surrealist/package.nix @@ -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; }; }) diff --git a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix b/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix index c01bc623c9d9d..0ee89e9e037bb 100644 --- a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix +++ b/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix @@ -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; }; }; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 2bfa5b8ca6f2a..1a7e22363acb1 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -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 diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh index 5836dea397874..5cd5d8da88195 100644 --- a/pkgs/development/compilers/swift/wrapper/wrapper.sh +++ b/pkgs/development/compilers/swift/wrapper/wrapper.sh @@ -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}" diff --git a/pkgs/servers/ldap/lldap/default.nix b/pkgs/servers/ldap/lldap/default.nix index 7db37e57c2d2b..80d7710ccbaf4 100644 --- a/pkgs/servers/ldap/lldap/default.nix +++ b/pkgs/servers/ldap/lldap/default.nix @@ -5,7 +5,6 @@ , nixosTests , rustPlatform , rustc -, stdenv , wasm-bindgen-cli , wasm-pack , which @@ -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"; }; diff --git a/pkgs/servers/teleport/generic.nix b/pkgs/servers/teleport/generic.nix index 94ca520964cd7..84b57160d4fa0 100644 --- a/pkgs/servers/teleport/generic.nix +++ b/pkgs/servers/teleport/generic.nix @@ -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; }; }