From 61582c704327002b75d61354a769ebf00f594cdf Mon Sep 17 00:00:00 2001 From: Emily Date: Tue, 25 Mar 2025 21:54:53 +0000 Subject: [PATCH] lib/systems: use Darwin architecture names for `config` and `uname` `aarch64-apple-darwin` no longer works with LLVM 20. --- doc/release-notes/rl-2505.section.md | 2 ++ lib/systems/default.nix | 11 ++++------- lib/systems/examples.nix | 4 ++-- lib/systems/parse.nix | 11 ++++++++++- pkgs/by-name/di/discord-gamesdk/package.nix | 2 +- .../compilers/llvm/common/llvm/default.nix | 11 ++--------- pkgs/development/compilers/swift/compiler/default.nix | 7 +------ pkgs/development/compilers/zig/generic.nix | 2 +- .../darwin/apple-source-releases/libffi/package.nix | 9 +++++---- 9 files changed, 28 insertions(+), 31 deletions(-) diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 13270084769f..fc40e5eefe4e 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -53,6 +53,8 @@ - The hand written `perlPackages.SearchXapian` bindings have been dropped in favor of the (mostly compatible) `perlPackages.Xapian`. +- The `config` triple for `aarch64-darwin` has been changed from `aarch64-apple-darwin` to `arm64-apple-darwin` to match the Apple toolchain and LLVM’s expectations. + - [testers.shellcheck](https://nixos.org/manual/nixpkgs/unstable/#tester-shellcheck) now warns when `name` is not provided. The `name` argument will become mandatory in a future release. diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 5e16240e4263..97f3d0dced17 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -209,6 +209,8 @@ let "ppc${optionalString final.isLittleEndian "le"}" else if final.isMips64 then "mips64" # endianness is *not* included on mips64 + else if final.isDarwin then + final.darwinArch else final.parsed.cpu.name; @@ -329,12 +331,7 @@ let else final.parsed.cpu.name; - darwinArch = - { - armv7a = "armv7"; - aarch64 = "arm64"; - } - .${final.parsed.cpu.name} or final.parsed.cpu.name; + darwinArch = parse.darwinArch final.parsed.cpu; darwinPlatform = if final.isMacOS then @@ -488,8 +485,8 @@ let } .${cpu.name} or cpu.name; vendor_ = final.rust.platform.vendor; - # TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL. in + # TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL. args.rust.rustcTarget or args.rustc.config or ( # Rust uses `wasm32-wasip?` rather than `wasm32-unknown-wasi`. # We cannot know which subversion does the user want, and diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index f87162e83277..3988e39f150c 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -276,7 +276,7 @@ rec { # iphone64 = { - config = "aarch64-apple-ios"; + config = "arm64-apple-ios"; # config = "aarch64-apple-darwin14"; darwinSdkVersion = "14.3"; xcodeVer = "12.3"; @@ -295,7 +295,7 @@ rec { }; aarch64-darwin = { - config = "aarch64-apple-darwin"; + config = "arm64-apple-darwin"; xcodePlatform = "MacOSX"; platform = { }; }; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index a7f65e69bf4c..ec773c824def 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -396,6 +396,12 @@ rec { significantByte = littleEndian; family = "javascript"; }; + } + // { + # aliases + # Apple architecture name, as used by `darwinArch`; required by + # LLVM ≥ 20. + arm64 = cpuTypes.aarch64; }; # GNU build systems assume that older NetBSD architectures are using a.out. @@ -921,6 +927,8 @@ rec { kernelName = kernel: kernel.name + toString (kernel.version or ""); + darwinArch = cpu: if cpu.name == "aarch64" then "arm64" else cpu.name; + doubleFromSystem = { cpu, @@ -949,8 +957,9 @@ rec { kernel.name == "netbsd" && gnuNetBSDDefaultExecFormat cpu != kernel.execFormat ) kernel.execFormat.name; optAbi = optionalString (abi != abis.unknown) "-${abi.name}"; + cpuName = if kernel.families ? darwin then darwinArch cpu else cpu.name; in - "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; + "${cpuName}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; ################################################################################ diff --git a/pkgs/by-name/di/discord-gamesdk/package.nix b/pkgs/by-name/di/discord-gamesdk/package.nix index 5d7a8185be45..c82b6c4fde10 100644 --- a/pkgs/by-name/di/discord-gamesdk/package.nix +++ b/pkgs/by-name/di/discord-gamesdk/package.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { installPhase = let - processor = stdenv.hostPlatform.uname.processor; + processor = stdenv.hostPlatform.parsed.cpu.name; sharedLibrary = stdenv.hostPlatform.extensions.sharedLibrary; in '' diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index ea2f024f617c..d2f9e711f653 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -594,21 +594,14 @@ stdenv.mkDerivation ( (lib.cmakeBool "LLVM_LINK_LLVM_DYLIB" enableSharedLibraries) (lib.cmakeFeature "LLVM_TABLEGEN" "${buildLlvmTools.tblgen}/bin/llvm-tblgen") ]; - - triple = - if stdenv.hostPlatform.isDarwin && lib.versionAtLeast release_version "20" then - # JIT tests expect the triple to use Darwin arch's naming for CPU architectures. - "${stdenv.hostPlatform.darwinArch}-apple-${stdenv.hostPlatform.darwinPlatform}" - else - stdenv.hostPlatform.config; in flagsForLlvmConfig ++ [ (lib.cmakeBool "LLVM_INSTALL_UTILS" true) # Needed by rustc (lib.cmakeBool "LLVM_BUILD_TESTS" finalAttrs.finalPackage.doCheck) (lib.cmakeBool "LLVM_ENABLE_FFI" true) - (lib.cmakeFeature "LLVM_HOST_TRIPLE" triple) - (lib.cmakeFeature "LLVM_DEFAULT_TARGET_TRIPLE" triple) + (lib.cmakeFeature "LLVM_HOST_TRIPLE" stdenv.hostPlatform.config) + (lib.cmakeFeature "LLVM_DEFAULT_TARGET_TRIPLE" stdenv.hostPlatform.config) (lib.cmakeBool "LLVM_ENABLE_DUMP" true) (lib.cmakeBool "LLVM_ENABLE_TERMINFO" enableTerminfo) (lib.cmakeBool "LLVM_INCLUDE_TESTS" finalAttrs.finalPackage.doCheck) diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index e5ee9323eea0..844bb4c3d6d8 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -72,12 +72,7 @@ let else targetPlatform.parsed.kernel.name; - # Apple Silicon uses a different CPU name in the target triple. - swiftArch = - if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then - "arm64" - else - targetPlatform.parsed.cpu.name; + swiftArch = stdenv.hostPlatform.darwinArch; # On Darwin, a `.swiftmodule` is a subdirectory in `lib/swift/`, # containing binaries for supported archs. On other platforms, binaries are diff --git a/pkgs/development/compilers/zig/generic.nix b/pkgs/development/compilers/zig/generic.nix index eb08623f2013..0dba4983ea98 100644 --- a/pkgs/development/compilers/zig/generic.nix +++ b/pkgs/development/compilers/zig/generic.nix @@ -156,7 +156,7 @@ stdenv.mkDerivation (finalAttrs: { nixSupport.cc-cflags = [ "-target" - "${stdenv.targetPlatform.parsed.cpu.name}-${stdenv.targetPlatform.parsed.kernel.name}-${stdenv.targetPlatform.parsed.abi.name}" + "${stdenv.targetPlatform.config}" ] ++ lib.optional ( stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.isStatic or false) diff --git a/pkgs/os-specific/darwin/apple-source-releases/libffi/package.nix b/pkgs/os-specific/darwin/apple-source-releases/libffi/package.nix index 176455d15f11..4fe40e86aab9 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libffi/package.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libffi/package.nix @@ -48,23 +48,24 @@ mkAppleDerivation (finalAttrs: { configureFlags = [ "--with-gcc-arch=generic" # no detection of -march= or -mtune= + "--enable-builddir=build" ]; postConfigure = '' # Use Apple’s configuration instead of the one generated by the `configure` script. - cp darwin/include/fficonfig_${stdenv.hostPlatform.darwinArch}.h ${stdenv.hostPlatform.config}/fficonfig.h + cp darwin/include/fficonfig_${stdenv.hostPlatform.darwinArch}.h build/fficonfig.h cp darwin/include/ffitarget_${ if stdenv.hostPlatform.isAarch64 then "arm64" else "x86" - }.h ${stdenv.hostPlatform.config}/include/ffitarget.h + }.h build/include/ffitarget.h # Use `macCatalyst` instead of `iosmac` to avoid errors due to invalid availability annotations. - substitute darwin/include/ffi.h ${stdenv.hostPlatform.config}/include/ffi.h \ + substitute darwin/include/ffi.h build/include/ffi.h \ --replace-fail iosmac macCatalyst ''; postBuild = lib.optionalString stdenv.hostPlatform.isAarch64 '' $CC -Os -Wl,-allowable_client,! -Wl,-not_for_dyld_shared_cache -Wl,-no_compact_unwind \ src/aarch64/trampoline.S -dynamiclib -o libffi-trampolines.dylib \ - -Iinclude -Iaarch64-apple-darwin -Iaarch64-apple-darwin/include \ + -Iinclude -Ibuild -Ibuild/include \ -install_name "$out/lib/libffi-trampoline.dylib" -Wl,-compatibility_version,1 -Wl,-current_version,1 '';