···1+As originally implemented, the error message check
2+described in the configure script
3+breaks detection of Ada compiler support on x86_64-darwin,
4+because the assembler in the version of cctools currently used
5+unconditionally emits a deprecation message to stdout,
6+with no way to disable it.
7+8+Furthermore, GCC 3.4 was the minimum version needed to build GNAT
9+as far back as GCC 4.4 (see the GCC git repo, tags/releases/gcc-4.4.0,
10+gcc/doc/install.texi, lines 2052-2053 [1]);
11+GCC 3.4 is newer than any of the broken GCC versions
12+that the configure script works around
13+(see the part of the comment in the configure script
14+before the context in the patch below),
15+and GCC 4.4 is older than any GCC that Nix currently packages (GCC 4.8).
16+17+We therefore choose to not check for error messages,
18+and just check for an error code.
19+There's no harm in still checking for an object file being created, though.
20+21+[1]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/doc/install.texi;h=6bdfbece981f7fb6c26da672d45e5d3ba7879c69;hb=b7fc996728085c0591ea7c5d0e1c84a8f6a29bd8#l2052
22+--- a/configure 2022-08-19 18:09:52.000000000 +1000
23++++ b/configure 2022-12-26 17:30:49.000000000 +1100
24+@@ -5622,8 +5622,7 @@
25+ # Other compilers, like HP Tru64 UNIX cc, exit successfully when
26+ # given a .adb file, but produce no object file. So we must check
27+ # if an object file was really produced to guard against this.
28+-errors=`(${CC} -c conftest.adb) 2>&1 || echo failure`
29+-if test x"$errors" = x && test -f conftest.$ac_objext; then
30++if ${CC} -c conftest.adb && test -f conftest.$ac_objext; then
31+ acx_cv_cc_gcc_supports_ada=yes
32+ fi
33+ rm -f conftest.*
···1+{ lib, version, buildPlatform, hostPlatform, targetPlatform
2, gnatboot ? null
3, langAda ? false
4, langJava ? false
···22 export lib=$out;
23'' + lib.optionalString langAda ''
24 export PATH=${gnatboot}/bin:$PATH
25+''
26+27+# On x86_64-darwin, the gnatboot bootstrap compiler that we need to build a
28+# native GCC with Ada support emits assembly that is accepted by the Clang
29+# integrated assembler, but not by the GNU assembler in cctools-port that Nix
30+# usually in the x86_64-darwin stdenv. In particular, x86_64-darwin gnatboot
31+# emits MOVQ as the mnemonic for quadword interunit moves, such as between XMM
32+# and general registers (e.g "movq %xmm0, %rbp"); the cctools-port assembler,
33+# however, only recognises MOVD for such moves.
34+#
35+# Therefore, for native x86_64-darwin builds that support Ada, we have to use
36+# the Clang integrated assembler to build (at least stage 1 of) GCC, but have to
37+# target GCC at the cctools-port GNU assembler. In the wrapped x86_64-darwin
38+# gnatboot, the former is provided as `as`, while the latter is provided as
39+# `gas`.
40+#
41++ lib.optionalString (
42+ langAda
43+ && buildPlatform == hostPlatform
44+ && hostPlatform == targetPlatform
45+ && targetPlatform.isx86_64
46+ && targetPlatform.isDarwin
47+ ) ''
48+ export AS_FOR_BUILD=${gnatboot}/bin/as
49+ export AS_FOR_TARGET=${gnatboot}/bin/gas
50''
5152# NOTE 2020/3/18: This environment variable prevents configure scripts from