darwin.binutilsDualAs: use gas output of darwin.cctools

This commit is contained in:
Randy Eckenrode 2024-04-15 15:30:13 -04:00
parent 2e0fc4a2a8
commit 8834c2f569
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9

View File

@ -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;
};