From 57f55719d4f5ead2e1f1d5ebf3df31d6eaaf5685 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Wed, 15 Jul 2026 22:47:56 +0200 Subject: [PATCH] cc-wrapper: Default-disable AltiVec with powerpc64-linux LLVM GCC is very conservative about enabling AltiVec. The default target has it disabled, and it requires either: - picking a CPU target that is generic POWER7 or higher, or is a specific CPU model that had AltiVec, or - using -maltivec to opt into it LLVM default-enables AltiVec, and has it marked as supported on CPUs that historically lacked it. Inconsistency aside, this leads to issues when building things with Clang that do not expect just AltiVec to be enabled, like webkitgtk. To make things more consistent, if no gcc.cpu is configured, pass -mno-altivec to Clang. --- pkgs/build-support/cc-wrapper/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index bf079f1b0e53..4d94cac369f6 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -370,7 +370,15 @@ let # Aarch64 uses TLSDESC by default and the option is completely ignored (at least on LLVM). # TODO: Enable by default in GCC via --with-tls since https://gcc.gnu.org/cgit/gcc/commit/?id=96a291c4bb0b8a00b0a125e6a60f60072ffe53a7 (GCC 16). # No equivalent build-time option for LLVM yet. - ++ optional (tlsDialect != null) "-mtls-dialect=${tlsDialect}"; + ++ optional (tlsDialect != null) "-mtls-dialect=${tlsDialect}" + # LLVM default-enables AltiVec for powerpc64, and for many CPU targets that didn't actually have it. + # https://github.com/llvm/llvm-project/blob/40977001fcb190a509897aee592819cdd7e83740/llvm/lib/Target/PowerPC/PPC.td#L791-L796 + # GCC is more conservative: Requires selecting POWER7 or higher for auto-enable, or opting into it on older ones. + # If no CPU is specified, disable AltiVec like GCC does. + # TODO: Specify CPU + AltiVec preference? + ++ optional ( + (targetPlatform.isPower64 && targetPlatform.isBigEndian) && isClang && !(targetPlatform ? gcc.cpu) + ) "-mno-altivec"; defaultHardeningFlags = bintools.defaultHardeningFlags or [ ];