at master 1.8 kB view raw
1{ lib, targetPlatform }: 2 3let 4 isAarch64Darwin = targetPlatform.isDarwin && targetPlatform.isAarch64; 5 gcc = targetPlatform.gcc or { }; 6 p = gcc // targetPlatform.parsed.abi; 7in 8lib.concatLists [ 9 # --with-arch= is unknown flag on x86_64 and aarch64-darwin. 10 (lib.optional (!targetPlatform.isx86_64 && !isAarch64Darwin && p ? arch) "--with-arch=${p.arch}") 11 # See supported_defaults in gcc/config.gcc for architecture support. 12 # --with-cpu on aarch64-darwin fails with "Unknown cpu used in --with-cpu=apple-a13". 13 (lib.optional ( 14 with targetPlatform; !isLoongArch64 && !isMips && !isRiscV && !isS390 && !isAarch64Darwin && p ? cpu 15 ) "--with-cpu=${p.cpu}") 16 (lib.optional (p ? abi) "--with-abi=${p.abi}") 17 (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") 18 (lib.optional (p ? float) "--with-float=${p.float}") 19 (lib.optional (p ? mode) "--with-mode=${p.mode}") 20 (lib.optionals targetPlatform.isPower64 21 # musl explicitly rejects 128-bit long double on 22 # powerpc64; see musl/arch/powerpc64/bits/float.h 23 ( 24 lib.optionals 25 ( 26 !targetPlatform.isMusl 27 && ( 28 targetPlatform.isLittleEndian 29 || 30 # "... --with-long-double-format is only supported if the default cpu is power7 or newer" 31 # https://github.com/NixOS/nixpkgs/pull/170215#issuecomment-1202164709 32 (lib.lists.elem (lib.strings.substring 0 6 (p.cpu or "")) [ 33 "power7" 34 "power8" 35 "power9" 36 "power1" # 0, 11, etc 37 ]) 38 ) 39 ) 40 [ 41 "--with-long-double-128" 42 "--with-long-double-format=${gcc.long-double-format or "ieee"}" 43 ] 44 ) 45 ) 46 (lib.optional targetPlatform.isMips64n32 "--disable-libsanitizer") # libsanitizer does not compile on mips64n32 47]