From ea889da7e6a16078e32f341bfbe24b5efad7cd53 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 13 May 2024 19:46:19 -0400 Subject: [PATCH 1/3] =?UTF-8?q?gcc:=20drop=20rpath=20from=20build=20on=20p?= =?UTF-8?q?latforms=20that=20don=E2=80=99t=20set=20rpaths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Darwin uses absolute path install names, so setting rpaths is unnecessary. This fixes breakage on older versions of GCC that try to set a deployment target that does not support rpaths. --- .../compilers/gcc/common/builder.nix | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/builder.nix b/pkgs/development/compilers/gcc/common/builder.nix index 25c564633865..9a254ef59c02 100644 --- a/pkgs/development/compilers/gcc/common/builder.nix +++ b/pkgs/development/compilers/gcc/common/builder.nix @@ -7,6 +7,14 @@ let forceLibgccToBuildCrtStuff = import ./libgcc-buildstuff.nix { inherit lib stdenv; }; + + # todo(@reckenrode) Remove in staging. This is ugly, but it avoid unwanted rebuilds on Darwin and Linux. + enableDarwinFixesForStagingNext = + version: + stdenv.buildPlatform.isDarwin + && stdenv.buildPlatform.isx86_64 + && lib.versionAtLeast version "6" + && lib.versionOlder version "10"; in originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { @@ -20,9 +28,20 @@ originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { if test "$staticCompiler" = "1"; then EXTRA_LDFLAGS="-static" - else - EXTRA_LDFLAGS="-Wl,-rpath,''${!outputLib}/lib" - fi + ${ + if enableDarwinFixesForStagingNext finalAttrs.version then + '' + elif test "''${NIX_DONT_SET_RPATH-}" != "1"; then + EXTRA_LDFLAGS="-Wl,-rpath,''${!outputLib}/lib" + else + EXTRA_LDFLAGS="" + '' + else + '' + else + EXTRA_LDFLAGS="-Wl,-rpath,''${!outputLib}/lib" + '' + }fi # GCC interprets empty paths as ".", which we don't want. if test -z "''${CPATH-}"; then unset CPATH; fi @@ -56,9 +75,24 @@ originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { extraLDFlags=("-L/usr/lib64" "-L/usr/lib") libc_libdir="/usr/lib" fi - extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" - "''${extraLDFlags[@]}") - for i in "''${extraLDFlags[@]}"; do + ${ + if enableDarwinFixesForStagingNext finalAttrs.version then + '' + extraLDFlags=("-L$libc_libdir") + nixDontSetRpathVar=NIX_DONT_SET_RPATH''${post} + if test "''${!nixDontSetRpathVar-}" != "1"; then + extraLDFlags+=("-rpath" "$libc_libdir") + fi + extraLDFlags+=("''${extraLDFlags[@]}") + '' + else + '' + extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" + "''${extraLDFlags[@]}") + '' +# The strange indentation with the next line is to ensure the string renders the same when the condition is false, +# which is necessary to prevent unwanted rebuilds in staging-next. +} for i in "''${extraLDFlags[@]}"; do declare -g EXTRA_LDFLAGS''${post}+=" -Wl,$i" done done From 621d0e188ec239e180dd53842da90ff15e1483cb Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 13 May 2024 19:47:52 -0400 Subject: [PATCH 2/3] gcc{6,7,8,9}: fix compatibility with Darwin headers The version of `AvailabilityInternal.h` used in newer SDKs does not work with older versions of GCC that do not support `__has_builtin`. Apply a fixinclude on those versions to allow them to build against the newer version of that header (also used in the source-based SDK after the ld64 update). --- .../AvailabilityInternal.h-fixincludes.patch | 105 ++++++++++++++++++ .../AvailabilityInternal.h-fixincludes.patch | 105 ++++++++++++++++++ .../AvailabilityInternal.h-fixincludes.patch | 105 ++++++++++++++++++ .../AvailabilityInternal.h-fixincludes.patch | 105 ++++++++++++++++++ .../compilers/gcc/patches/default.nix | 8 ++ 5 files changed, 428 insertions(+) create mode 100644 pkgs/development/compilers/gcc/patches/6/AvailabilityInternal.h-fixincludes.patch create mode 100644 pkgs/development/compilers/gcc/patches/7/AvailabilityInternal.h-fixincludes.patch create mode 100644 pkgs/development/compilers/gcc/patches/8/AvailabilityInternal.h-fixincludes.patch create mode 100644 pkgs/development/compilers/gcc/patches/9/AvailabilityInternal.h-fixincludes.patch diff --git a/pkgs/development/compilers/gcc/patches/6/AvailabilityInternal.h-fixincludes.patch b/pkgs/development/compilers/gcc/patches/6/AvailabilityInternal.h-fixincludes.patch new file mode 100644 index 000000000000..a29bb5eba98c --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/6/AvailabilityInternal.h-fixincludes.patch @@ -0,0 +1,105 @@ +diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x +index 662dc97762c..5140a04f9dd 100644 +--- a/fixincludes/fixincl.x ++++ b/fixincludes/fixincl.x +@@ -3053,6 +3053,43 @@ static const char* apzDarwin_Stdint_7Patch[] = { + #endif", + (char*)NULL }; + ++/* * * * * * * * * * * * * * * * * * * * * * * * * * ++ * ++ * Description of Darwin_Nix_Sdk_Availabilityinternal fix ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalName[] = ++ "darwin_nix_sdk_availabilityinternal"; ++ ++/* ++ * File name selection pattern ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalList[] = ++ "AvailabilityInternal.h\0"; ++/* ++ * Machine/OS name selection pattern ++ */ ++tSCC* apzDarwin_Nix_Sdk_AvailabilityinternalMachs[] = { ++ "*-*-darwin*", ++ (const char*)NULL }; ++ ++/* ++ * content selection pattern - do fix if pattern found ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalSelect0[] = ++ "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ ++#define DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT 1 ++static tTestDesc aDarwin_Nix_Sdk_AvailabilityinternalTests[] = { ++ { TT_EGREP, zDarwin_Nix_Sdk_AvailabilityinternalSelect0, (regex_t*)NULL }, }; ++ ++/* ++ * Fix Command Arguments for Darwin_Nix_Sdk_Availabilityinternal ++ */ ++static const char* apzDarwin_Nix_Sdk_AvailabilityinternalPatch[] = { ++ "format", ++ "%10%2", ++ (char*)NULL }; ++ + /* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Dec_Intern_Asm fix +@@ -9855,9 +9892,9 @@ static const char* apzX11_SprintfPatch[] = { + * + * List of all fixes + */ +-#define REGEX_COUNT 277 ++#define REGEX_COUNT 278 + #define MACH_LIST_SIZE_LIMIT 187 +-#define FIX_COUNT 241 ++#define FIX_COUNT 242 + + /* + * Enumerate the fixes +@@ -9933,6 +9970,7 @@ typedef enum { + DARWIN_STDINT_5_FIXIDX, + DARWIN_STDINT_6_FIXIDX, + DARWIN_STDINT_7_FIXIDX, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_FIXIDX, + DEC_INTERN_ASM_FIXIDX, + DJGPP_WCHAR_H_FIXIDX, + ECD_CURSOR_FIXIDX, +@@ -10457,6 +10495,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { + DARWIN_STDINT_7_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Stdint_7Tests, apzDarwin_Stdint_7Patch, 0 }, + ++ { zDarwin_Nix_Sdk_AvailabilityinternalName, zDarwin_Nix_Sdk_AvailabilityinternalList, ++ apzDarwin_Nix_Sdk_AvailabilityinternalMachs, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, ++ aDarwin_Nix_Sdk_AvailabilityinternalTests, apzDarwin_Nix_Sdk_AvailabilityinternalPatch, 0 }, ++ + { zDec_Intern_AsmName, zDec_Intern_AsmList, + apzDec_Intern_AsmMachs, + DEC_INTERN_ASM_TEST_CT, FD_MACH_ONLY, +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index 98fb5b61649..8aad418dff8 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -1591,6 +1591,20 @@ fix = { + "#define UINTMAX_C(v) (v ## ULL)"; + }; + ++/* ++ * Newer versions of AvailabilityInternal.h use `__has_builtin`, ++ * which is not implemented in or compatible with GCC. ++ */ ++fix = { ++ hackname = darwin_nix_sdk_availabilityinternal; ++ mach = "*-*-darwin*"; ++ files = AvailabilityInternal.h; ++ c_fix = format; ++ c_fix_arg = "%10%2"; ++ select = "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ test_text = "__has_builtin(__is_target_os)"; ++}; ++ + /* + * Fix on Digital UNIX V4.0: + * It contains a prototype for a DEC C internal asm() function, diff --git a/pkgs/development/compilers/gcc/patches/7/AvailabilityInternal.h-fixincludes.patch b/pkgs/development/compilers/gcc/patches/7/AvailabilityInternal.h-fixincludes.patch new file mode 100644 index 000000000000..a8a995d030df --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/7/AvailabilityInternal.h-fixincludes.patch @@ -0,0 +1,105 @@ +diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x +index d12ba7c3e88..9f31b29c509 100644 +--- a/fixincludes/fixincl.x ++++ b/fixincludes/fixincl.x +@@ -3468,6 +3468,43 @@ static const char* apzDarwin_Ucred__AtomicPatch[] = { + #endif\n", + (char*)NULL }; + ++/* * * * * * * * * * * * * * * * * * * * * * * * * * ++ * ++ * Description of Darwin_Nix_Sdk_Availabilityinternal fix ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalName[] = ++ "darwin_nix_sdk_availabilityinternal"; ++ ++/* ++ * File name selection pattern ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalList[] = ++ "AvailabilityInternal.h\0"; ++/* ++ * Machine/OS name selection pattern ++ */ ++tSCC* apzDarwin_Nix_Sdk_AvailabilityinternalMachs[] = { ++ "*-*-darwin*", ++ (const char*)NULL }; ++ ++/* ++ * content selection pattern - do fix if pattern found ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalSelect0[] = ++ "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ ++#define DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT 1 ++static tTestDesc aDarwin_Nix_Sdk_AvailabilityinternalTests[] = { ++ { TT_EGREP, zDarwin_Nix_Sdk_AvailabilityinternalSelect0, (regex_t*)NULL }, }; ++ ++/* ++ * Fix Command Arguments for Darwin_Nix_Sdk_Availabilityinternal ++ */ ++static const char* apzDarwin_Nix_Sdk_AvailabilityinternalPatch[] = { ++ "format", ++ "%10%2", ++ (char*)NULL }; ++ + /* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Dec_Intern_Asm fix +@@ -10347,9 +10384,9 @@ static const char* apzX11_SprintfPatch[] = { + * + * List of all fixes + */ +-#define REGEX_COUNT 291 ++#define REGEX_COUNT 292 + #define MACH_LIST_SIZE_LIMIT 187 +-#define FIX_COUNT 253 ++#define FIX_COUNT 254 + + /* + * Enumerate the fixes +@@ -10435,6 +10472,7 @@ typedef enum { + DARWIN_STDINT_6_FIXIDX, + DARWIN_STDINT_7_FIXIDX, + DARWIN_UCRED__ATOMIC_FIXIDX, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_FIXIDX, + DEC_INTERN_ASM_FIXIDX, + DJGPP_WCHAR_H_FIXIDX, + ECD_CURSOR_FIXIDX, +@@ -11011,6 +11049,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { + DARWIN_UCRED__ATOMIC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Ucred__AtomicTests, apzDarwin_Ucred__AtomicPatch, 0 }, + ++ { zDarwin_Nix_Sdk_AvailabilityinternalName, zDarwin_Nix_Sdk_AvailabilityinternalList, ++ apzDarwin_Nix_Sdk_AvailabilityinternalMachs, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, ++ aDarwin_Nix_Sdk_AvailabilityinternalTests, apzDarwin_Nix_Sdk_AvailabilityinternalPatch, 0 }, ++ + { zDec_Intern_AsmName, zDec_Intern_AsmList, + apzDec_Intern_AsmMachs, + DEC_INTERN_ASM_TEST_CT, FD_MACH_ONLY, +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index 179e2f3c98a..70b681f35c8 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -1793,6 +1793,20 @@ fix = { + test_text = ""; /* Don't provide this for wrap fixes. */ + }; + ++/* ++ * Newer versions of AvailabilityInternal.h use `__has_builtin`, ++ * which is not implemented in or compatible with GCC. ++ */ ++fix = { ++ hackname = darwin_nix_sdk_availabilityinternal; ++ mach = "*-*-darwin*"; ++ files = AvailabilityInternal.h; ++ c_fix = format; ++ c_fix_arg = "%10%2"; ++ select = "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ test_text = "__has_builtin(__is_target_os)"; ++}; ++ + /* + * Fix on Digital UNIX V4.0: + * It contains a prototype for a DEC C internal asm() function, diff --git a/pkgs/development/compilers/gcc/patches/8/AvailabilityInternal.h-fixincludes.patch b/pkgs/development/compilers/gcc/patches/8/AvailabilityInternal.h-fixincludes.patch new file mode 100644 index 000000000000..0a4f46bce066 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/8/AvailabilityInternal.h-fixincludes.patch @@ -0,0 +1,105 @@ +diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x +index 9578c99ab7b..e0ae73496c6 100644 +--- a/fixincludes/fixincl.x ++++ b/fixincludes/fixincl.x +@@ -3428,6 +3428,43 @@ static const char* apzDarwin_Ucred__AtomicPatch[] = { + #endif\n", + (char*)NULL }; + ++/* * * * * * * * * * * * * * * * * * * * * * * * * * ++ * ++ * Description of Darwin_Nix_Sdk_Availabilityinternal fix ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalName[] = ++ "darwin_nix_sdk_availabilityinternal"; ++ ++/* ++ * File name selection pattern ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalList[] = ++ "AvailabilityInternal.h\0"; ++/* ++ * Machine/OS name selection pattern ++ */ ++tSCC* apzDarwin_Nix_Sdk_AvailabilityinternalMachs[] = { ++ "*-*-darwin*", ++ (const char*)NULL }; ++ ++/* ++ * content selection pattern - do fix if pattern found ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalSelect0[] = ++ "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ ++#define DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT 1 ++static tTestDesc aDarwin_Nix_Sdk_AvailabilityinternalTests[] = { ++ { TT_EGREP, zDarwin_Nix_Sdk_AvailabilityinternalSelect0, (regex_t*)NULL }, }; ++ ++/* ++ * Fix Command Arguments for Darwin_Nix_Sdk_Availabilityinternal ++ */ ++static const char* apzDarwin_Nix_Sdk_AvailabilityinternalPatch[] = { ++ "format", ++ "%10%2", ++ (char*)NULL }; ++ + /* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Dec_Intern_Asm fix +@@ -10356,9 +10393,9 @@ static const char* apzX11_SprintfPatch[] = { + * + * List of all fixes + */ +-#define REGEX_COUNT 294 ++#define REGEX_COUNT 295 + #define MACH_LIST_SIZE_LIMIT 187 +-#define FIX_COUNT 255 ++#define FIX_COUNT 256 + + /* + * Enumerate the fixes +@@ -10445,6 +10482,7 @@ typedef enum { + DARWIN_STDINT_6_FIXIDX, + DARWIN_STDINT_7_FIXIDX, + DARWIN_UCRED__ATOMIC_FIXIDX, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_FIXIDX, + DEC_INTERN_ASM_FIXIDX, + DJGPP_WCHAR_H_FIXIDX, + ECD_CURSOR_FIXIDX, +@@ -11027,6 +11065,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { + DARWIN_UCRED__ATOMIC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Ucred__AtomicTests, apzDarwin_Ucred__AtomicPatch, 0 }, + ++ { zDarwin_Nix_Sdk_AvailabilityinternalName, zDarwin_Nix_Sdk_AvailabilityinternalList, ++ apzDarwin_Nix_Sdk_AvailabilityinternalMachs, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, ++ aDarwin_Nix_Sdk_AvailabilityinternalTests, apzDarwin_Nix_Sdk_AvailabilityinternalPatch, 0 }, ++ + { zDec_Intern_AsmName, zDec_Intern_AsmList, + apzDec_Intern_AsmMachs, + DEC_INTERN_ASM_TEST_CT, FD_MACH_ONLY, +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index 948ea1d9183..5eb403ac841 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -1697,6 +1697,20 @@ fix = { + test_text = ""; /* Don't provide this for wrap fixes. */ + }; + ++/* ++ * Newer versions of AvailabilityInternal.h use `__has_builtin`, ++ * which is not implemented in or compatible with GCC. ++ */ ++fix = { ++ hackname = darwin_nix_sdk_availabilityinternal; ++ mach = "*-*-darwin*"; ++ files = AvailabilityInternal.h; ++ c_fix = format; ++ c_fix_arg = "%10%2"; ++ select = "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ test_text = "__has_builtin(__is_target_os)"; ++}; ++ + /* + * Fix on Digital UNIX V4.0: + * It contains a prototype for a DEC C internal asm() function, diff --git a/pkgs/development/compilers/gcc/patches/9/AvailabilityInternal.h-fixincludes.patch b/pkgs/development/compilers/gcc/patches/9/AvailabilityInternal.h-fixincludes.patch new file mode 100644 index 000000000000..8575f71912a1 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/AvailabilityInternal.h-fixincludes.patch @@ -0,0 +1,105 @@ +diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x +index 47a3578f017..6cf22d19b2a 100644 +--- a/fixincludes/fixincl.x ++++ b/fixincludes/fixincl.x +@@ -3480,6 +3480,43 @@ static const char* apzDarwin_Ucred__AtomicPatch[] = { + #endif\n", + (char*)NULL }; + ++/* * * * * * * * * * * * * * * * * * * * * * * * * * ++ * ++ * Description of Darwin_Nix_Sdk_Availabilityinternal fix ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalName[] = ++ "darwin_nix_sdk_availabilityinternal"; ++ ++/* ++ * File name selection pattern ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalList[] = ++ "AvailabilityInternal.h\0"; ++/* ++ * Machine/OS name selection pattern ++ */ ++tSCC* apzDarwin_Nix_Sdk_AvailabilityinternalMachs[] = { ++ "*-*-darwin*", ++ (const char*)NULL }; ++ ++/* ++ * content selection pattern - do fix if pattern found ++ */ ++tSCC zDarwin_Nix_Sdk_AvailabilityinternalSelect0[] = ++ "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ ++#define DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT 1 ++static tTestDesc aDarwin_Nix_Sdk_AvailabilityinternalTests[] = { ++ { TT_EGREP, zDarwin_Nix_Sdk_AvailabilityinternalSelect0, (regex_t*)NULL }, }; ++ ++/* ++ * Fix Command Arguments for Darwin_Nix_Sdk_Availabilityinternal ++ */ ++static const char* apzDarwin_Nix_Sdk_AvailabilityinternalPatch[] = { ++ "format", ++ "%10%2", ++ (char*)NULL }; ++ + /* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Dec_Intern_Asm fix +@@ -10445,9 +10482,9 @@ static const char* apzX11_SprintfPatch[] = { + * + * List of all fixes + */ +-#define REGEX_COUNT 296 ++#define REGEX_COUNT 297 + #define MACH_LIST_SIZE_LIMIT 187 +-#define FIX_COUNT 257 ++#define FIX_COUNT 258 + + /* + * Enumerate the fixes +@@ -10535,6 +10572,7 @@ typedef enum { + DARWIN_STDINT_6_FIXIDX, + DARWIN_STDINT_7_FIXIDX, + DARWIN_UCRED__ATOMIC_FIXIDX, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_FIXIDX, + DEC_INTERN_ASM_FIXIDX, + DJGPP_WCHAR_H_FIXIDX, + ECD_CURSOR_FIXIDX, +@@ -11123,6 +11161,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { + DARWIN_UCRED__ATOMIC_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Ucred__AtomicTests, apzDarwin_Ucred__AtomicPatch, 0 }, + ++ { zDarwin_Nix_Sdk_AvailabilityinternalName, zDarwin_Nix_Sdk_AvailabilityinternalList, ++ apzDarwin_Nix_Sdk_AvailabilityinternalMachs, ++ DARWIN_NIX_SDK_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, ++ aDarwin_Nix_Sdk_AvailabilityinternalTests, apzDarwin_Nix_Sdk_AvailabilityinternalPatch, 0 }, ++ + { zDec_Intern_AsmName, zDec_Intern_AsmList, + apzDec_Intern_AsmMachs, + DEC_INTERN_ASM_TEST_CT, FD_MACH_ONLY, +diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def +index bf136fdaa20..89bceb46c26 100644 +--- a/fixincludes/inclhack.def ++++ b/fixincludes/inclhack.def +@@ -1727,6 +1727,20 @@ fix = { + test_text = ""; /* Don't provide this for wrap fixes. */ + }; + ++/* ++ * Newer versions of AvailabilityInternal.h use `__has_builtin`, ++ * which is not implemented in or compatible with GCC. ++ */ ++fix = { ++ hackname = darwin_nix_sdk_availabilityinternal; ++ mach = "*-*-darwin*"; ++ files = AvailabilityInternal.h; ++ c_fix = format; ++ c_fix_arg = "%10%2"; ++ select = "(.*)__has_builtin\\(__is_target_os\\)(.*)"; ++ test_text = "__has_builtin(__is_target_os)"; ++}; ++ + /* + * Fix on Digital UNIX V4.0: + * It contains a prototype for a DEC C internal asm() function, diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index c64e16753fc6..eabf034d9824 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -167,6 +167,14 @@ in }) ]; }.${majorVersion} or []) +# Work around newer AvailabilityInternal.h when building older versions of GCC. +++ optionals (stdenv.isDarwin) ({ + "9" = [ ../patches/9/AvailabilityInternal.h-fixincludes.patch ]; + "8" = [ ../patches/8/AvailabilityInternal.h-fixincludes.patch ]; + "7" = [ ../patches/7/AvailabilityInternal.h-fixincludes.patch ]; + "6" = [ ../patches/6/AvailabilityInternal.h-fixincludes.patch ]; +}.${majorVersion} or []) + ## Windows From 33f416e434089dc3d2fa4389297d9f6c60c9373c Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 21 Jul 2024 22:57:11 -0400 Subject: [PATCH 3/3] gcc6: add x86_64-darwin to badPlatforms ld64 crashes when trying to link during the GCC bootstrap. --- 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 2105fe752dd5..24c65f8c7421 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -450,7 +450,7 @@ pipe ((callFile ./common/builder.nix {}) ({ badPlatforms = # avr-gcc8 is maintained for the `qmk` package if (is8 && targetPlatform.isAvr) then [] - else if !(is48 || is49) then [ "aarch64-darwin" ] + else if !(is48 || is49 || is6) then [ "aarch64-darwin" ] else platforms.darwin; } // optionalAttrs is11 { badPlatforms = if targetPlatform != hostPlatform then [ "aarch64-darwin" ] else [ ];