gnat12: Add support for x86_64-darwin

This commit is contained in:
Boey Maun Suang 2023-01-06 16:24:50 +11:00
parent c1308ac58c
commit 3d64e7edbb
12 changed files with 78 additions and 10 deletions

View file

@ -185,7 +185,7 @@ stdenv.mkDerivation ({
preConfigure = (import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
}) + ''
ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h
'';

View file

@ -189,7 +189,7 @@ stdenv.mkDerivation ({
preConfigure = (import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
}) + ''
ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h
'';

View file

@ -109,6 +109,9 @@ let majorVersion = "12";
})
]
# Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin
++ optional (stdenv.isDarwin && langAda) ../ada-cctools-as-detection-configure.patch
# Obtain latest patch with ../update-mcfgthread-patches.sh
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch;
@ -227,7 +230,7 @@ stdenv.mkDerivation ({
preConfigure = (import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
}) + ''
ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h
'';

View file

@ -192,7 +192,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform langJava langGo crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform langJava langGo crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -212,7 +212,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform langJava langGo crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform langJava langGo crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -223,7 +223,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform gnatboot langJava langAda langGo crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform gnatboot langJava langAda langGo crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -191,7 +191,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform langGo crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform langGo crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -173,7 +173,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform langGo crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform langGo crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -186,7 +186,7 @@ stdenv.mkDerivation ({
preConfigure = import ../common/pre-configure.nix {
inherit lib;
inherit version targetPlatform hostPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
inherit version targetPlatform hostPlatform buildPlatform gnatboot langAda langGo langJit crossStageStatic enableMultilib;
};
dontDisableStatic = true;

View file

@ -0,0 +1,33 @@
As originally implemented, the error message check
described in the configure script
breaks detection of Ada compiler support on x86_64-darwin,
because the assembler in the version of cctools currently used
unconditionally emits a deprecation message to stdout,
with no way to disable it.
Furthermore, GCC 3.4 was the minimum version needed to build GNAT
as far back as GCC 4.4 (see the GCC git repo, tags/releases/gcc-4.4.0,
gcc/doc/install.texi, lines 2052-2053 [1]);
GCC 3.4 is newer than any of the broken GCC versions
that the configure script works around
(see the part of the comment in the configure script
before the context in the patch below),
and GCC 4.4 is older than any GCC that Nix currently packages (GCC 4.8).
We therefore choose to not check for error messages,
and just check for an error code.
There's no harm in still checking for an object file being created, though.
[1]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/doc/install.texi;h=6bdfbece981f7fb6c26da672d45e5d3ba7879c69;hb=b7fc996728085c0591ea7c5d0e1c84a8f6a29bd8#l2052
--- a/configure 2022-08-19 18:09:52.000000000 +1000
+++ b/configure 2022-12-26 17:30:49.000000000 +1100
@@ -5622,8 +5622,7 @@
# Other compilers, like HP Tru64 UNIX cc, exit successfully when
# given a .adb file, but produce no object file. So we must check
# if an object file was really produced to guard against this.
-errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
-if test x"$errors" = x && test -f conftest.$ac_objext; then
+if ${CC} -c conftest.adb && test -f conftest.$ac_objext; then
acx_cv_cc_gcc_supports_ada=yes
fi
rm -f conftest.*

View file

@ -1,4 +1,4 @@
{ lib, version, hostPlatform, targetPlatform
{ lib, version, buildPlatform, hostPlatform, targetPlatform
, gnatboot ? null
, langAda ? false
, langJava ? false
@ -24,6 +24,31 @@ in lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
export PATH=${gnatboot}/bin:$PATH
''
# On x86_64-darwin, the gnatboot bootstrap compiler that we need to build a
# native GCC with Ada support emits assembly that is accepted by the Clang
# integrated assembler, but not by the GNU assembler in cctools-port that Nix
# usually in the x86_64-darwin stdenv. In particular, x86_64-darwin gnatboot
# emits MOVQ as the mnemonic for quadword interunit moves, such as between XMM
# and general registers (e.g "movq %xmm0, %rbp"); the cctools-port assembler,
# however, only recognises MOVD for such moves.
#
# Therefore, for native x86_64-darwin builds that support Ada, we have to use
# the Clang integrated assembler to build (at least stage 1 of) GCC, but have to
# target GCC at the cctools-port GNU assembler. In the wrapped x86_64-darwin
# gnatboot, the former is provided as `as`, while the latter is provided as
# `gas`.
#
+ lib.optionalString (
langAda
&& buildPlatform == hostPlatform
&& hostPlatform == targetPlatform
&& targetPlatform.isx86_64
&& targetPlatform.isDarwin
) ''
export AS_FOR_BUILD=${gnatboot}/bin/as
export AS_FOR_TARGET=${gnatboot}/bin/gas
''
# NOTE 2020/3/18: This environment variable prevents configure scripts from
# detecting the presence of aligned_alloc on Darwin. There are many facts that
# collectively make this fix necessary:

View file

@ -14491,6 +14491,13 @@ with pkgs;
&& stdenv.buildPlatform == stdenv.hostPlatform
then buildPackages.gnatboot12
else buildPackages.gnat12;
stdenv =
if stdenv.hostPlatform == stdenv.targetPlatform
&& stdenv.buildPlatform == stdenv.hostPlatform
&& stdenv.buildPlatform.isDarwin
&& stdenv.buildPlatform.isx86_64
then overrideCC stdenv gnatboot12
else stdenv;
});
gnatboot = gnatboot12;