summary refs log tree commit diff
path: root/pkgs/development/compilers
diff options
context:
space:
mode:
authorBoey Maun Suang <account-at-github@boeyms.info>2023-01-06 16:24:50 +1100
committerBoey Maun Suang <account-at-github@boeyms.info>2023-01-07 18:32:12 +1100
commit3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23 (patch)
treeaca587fb60a9b1024664f2cf726392d8df87a2ea /pkgs/development/compilers
parentc1308ac58cb1bccf29e6729b6b0da0254710bf70 (diff)
downloadnixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar.gz
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar.bz2
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar.lz
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar.xz
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.tar.zst
nixpkgs-3d64e7edbb8c541d03f1f8c86bc7e19f6298aa23.zip
gnat12: Add support for x86_64-darwin
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r--pkgs/development/compilers/gcc/10/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/11/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/12/default.nix5
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/8/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/9/default.nix2
-rw-r--r--pkgs/development/compilers/gcc/ada-cctools-as-detection-configure.patch33
-rw-r--r--pkgs/development/compilers/gcc/common/pre-configure.nix27
11 files changed, 71 insertions, 10 deletions
diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix
index e4cebab266e..b2c2ac9875a 100644
--- a/pkgs/development/compilers/gcc/10/default.nix
+++ b/pkgs/development/compilers/gcc/10/default.nix
@@ -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
   '';
diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix
index de764b9ccc7..0724eedc29c 100644
--- a/pkgs/development/compilers/gcc/11/default.nix
+++ b/pkgs/development/compilers/gcc/11/default.nix
@@ -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
   '';
diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix
index 3c9362fee1a..1a4af0ab286 100644
--- a/pkgs/development/compilers/gcc/12/default.nix
+++ b/pkgs/development/compilers/gcc/12/default.nix
@@ -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
   '';
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index ba084af53ee..e0c30f35a13 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index c28ef88ce93..d886cc84eca 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 8bd9d41f1ea..f82070153b7 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 637be9fd971..076eec21a14 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix
index 4eb47d00c5c..18054c8c19b 100644
--- a/pkgs/development/compilers/gcc/8/default.nix
+++ b/pkgs/development/compilers/gcc/8/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix
index 4c49cdaa3e2..7cdde48667f 100644
--- a/pkgs/development/compilers/gcc/9/default.nix
+++ b/pkgs/development/compilers/gcc/9/default.nix
@@ -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;
diff --git a/pkgs/development/compilers/gcc/ada-cctools-as-detection-configure.patch b/pkgs/development/compilers/gcc/ada-cctools-as-detection-configure.patch
new file mode 100644
index 00000000000..e6b5b365332
--- /dev/null
+++ b/pkgs/development/compilers/gcc/ada-cctools-as-detection-configure.patch
@@ -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.*
diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix
index ae5ffe6ab0d..e3b38eb74e9 100644
--- a/pkgs/development/compilers/gcc/common/pre-configure.nix
+++ b/pkgs/development/compilers/gcc/common/pre-configure.nix
@@ -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: