From db20831951cebae92b8e630b61bf5ca3c1bdad11 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 2 Dec 2023 18:19:48 -0500 Subject: [PATCH 1/4] gcc11: drop AVR patch on Darwin (no longer needed) --- .../gcc/patches/11/avr-gcc-11.3-darwin.patch | 20 ------------------- .../compilers/gcc/patches/default.nix | 3 --- 2 files changed, 23 deletions(-) delete mode 100644 pkgs/development/compilers/gcc/patches/11/avr-gcc-11.3-darwin.patch diff --git a/pkgs/development/compilers/gcc/patches/11/avr-gcc-11.3-darwin.patch b/pkgs/development/compilers/gcc/patches/11/avr-gcc-11.3-darwin.patch deleted file mode 100644 index 787862fbcffa..000000000000 --- a/pkgs/development/compilers/gcc/patches/11/avr-gcc-11.3-darwin.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/gcc/config/avr/avr.c 2022-10-08 19:18:33.000000000 +0200 -+++ b/gcc/config/avr/avr.patched.c 2022-10-08 19:19:34.000000000 +0200 -@@ -10196,7 +10196,7 @@ - to track need of __do_copy_data. */ - - static void --avr_output_data_section_asm_op (const void *data) -+avr_output_data_section_asm_op (const char *data) - { - avr_need_copy_data_p = true; - -@@ -10209,7 +10209,7 @@ - to track need of __do_clear_bss. */ - - static void --avr_output_bss_section_asm_op (const void *data) -+avr_output_bss_section_asm_op (const char *data) - { - avr_need_clear_bss_p = true; - diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 9eda241f6d3a..32938be376d9 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -175,9 +175,6 @@ in ## gcc 11.0 and older ############################################################################## -# https://github.com/osx-cross/homebrew-avr/issues/280#issuecomment-1272381808 -++ optional (is11 && stdenv.isDarwin && targetPlatform.isAvr) ./avr-gcc-11.3-darwin.patch - # libgcc’s `configure` script misdetects aarch64-darwin, resulting in an invalid deployment target. ++ optional (is11 && stdenv.isDarwin && stdenv.isAarch64) ./11/libgcc-aarch64-darwin-detection.patch From fe27958aed65ac531732544dd6a8b9c20da4d813 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 2 Dec 2023 18:32:15 -0500 Subject: [PATCH 2/4] gcc{6,7,8,9}: use target bintools on Darwin Using the host bintools results in evaluation errors when building an AVR cross-compiler due to trying to build cctools for AVR. --- pkgs/development/compilers/gcc/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 57141ba23e2e..46b2404e99e5 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -421,7 +421,7 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ } // lib.optionalAttrs (!atLeast11) { badPlatforms = if !(is48 || is49) then [ "aarch64-darwin" ] else lib.platforms.darwin; }; -} // lib.optionalAttrs (!atLeast10 && stdenv.hostPlatform.isDarwin) { +} // lib.optionalAttrs (!atLeast10 && stdenv.targetPlatform.isDarwin) { # GCC <10 requires default cctools `strip` instead of `llvm-strip` used by Darwin bintools. preBuild = '' makeFlagsArray+=('STRIP=${lib.getBin darwin.cctools-port}/bin/${stdenv.cc.targetPrefix}strip') From 4a538d6b3df931c87fb38b14fa1d0038d39f45e5 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 2 Dec 2023 18:42:00 -0500 Subject: [PATCH 3/4] gcc11: mark as bad on aarch64-darwin when building a cross-compiler --- pkgs/development/compilers/gcc/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 46b2404e99e5..de82b1795ba3 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -420,6 +420,8 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ ; } // lib.optionalAttrs (!atLeast11) { badPlatforms = if !(is48 || is49) then [ "aarch64-darwin" ] else lib.platforms.darwin; + } // lib.optionalAttrs is11 { + badPlatforms = if targetPlatform != hostPlatform then [ "aarch64-darwin" ] else [ ]; }; } // lib.optionalAttrs (!atLeast10 && stdenv.targetPlatform.isDarwin) { # GCC <10 requires default cctools `strip` instead of `llvm-strip` used by Darwin bintools. From f2a7764cab5799d2a68e6771679780303b5b3afa Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 2 Dec 2023 18:43:00 -0500 Subject: [PATCH 4/4] gcc{6,7,8,9,10,11}: fix cross-compiler build on x86_64-darwin Building a cross-compiler fails due to register storage class specifier errors when building with clang 16 due to its defaulting to C++17. Downgrading the error allows the older cross-compilers to build. --- pkgs/development/compilers/gcc/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index de82b1795ba3..628b259acbd9 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -392,7 +392,11 @@ lib.pipe ((callFile ./common/builder.nix {}) ({ EXTRA_LDFLAGS_FOR_TARGET ; } // optionalAttrs is7 { - NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"; + NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument" + # Downgrade register storage class specifier errors to warnings when building a cross compiler from a clang stdenv. + + lib.optionalString (stdenv.cc.isClang && targetPlatform != hostPlatform) " -Wno-register"; + } // optionalAttrs (!is7 && !atLeast12 && stdenv.cc.isClang && targetPlatform != hostPlatform) { + NIX_CFLAGS_COMPILE = "-Wno-register"; } // optionalAttrs (!atLeast7) { inherit langJava; } // optionalAttrs atLeast6 {