From 8834c2f569bd51e52fcc1e51e47f212de40dba78 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 15 Apr 2024 15:30:13 -0400 Subject: [PATCH] darwin.binutilsDualAs: use gas output of darwin.cctools --- pkgs/top-level/darwin-packages.nix | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index 7a5ddbc27c74..69d22c8b9625 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -95,17 +95,29 @@ impure-cmds // appleSourcePackages // chooseLibs // { bintools = self.binutils-unwrapped; }; - binutilsDualAs-unwrapped = callPackage ../os-specific/darwin/binutils { - inherit (pkgs) binutils-unwrapped; - inherit (pkgs.llvmPackages) llvm clang-unwrapped; - dualAs = true; + # x86-64 Darwin gnat-bootstrap emits assembly + # with MOVQ as the mnemonic for quadword interunit moves + # such as `movq %rbp, %xmm0`. + # The clang integrated assembler recognises this as valid, + # but unfortunately the cctools.gas GNU assembler does not; + # it instead uses MOVD as the mnemonic. + # The assembly that a GCC build emits is determined at build time + # and cannot be changed afterwards. + # + # To build GNAT on x86-64 Darwin, therefore, + # we need both the clang _and_ the cctools.gas assemblers to be available: + # the former to build at least the stage1 compiler, + # and the latter at least to be detectable + # as the target for the final compiler. + binutilsDualAs-unwrapped = pkgs.buildEnv { + name = "${lib.getName self.binutils-unwrapped}-dualas-${lib.getVersion self.binutils-unwrapped}"; + paths = [ + self.binutils-unwrapped + (lib.getOutput "gas" self.cctools) + ]; }; - binutilsDualAs = pkgs.wrapBintoolsWith { - libc = - if stdenv.targetPlatform != stdenv.hostPlatform - then pkgs.libcCross - else pkgs.stdenv.cc.libc; + binutilsDualAs = self.binutils.override { bintools = self.binutilsDualAs-unwrapped; };