diff options
author | Randy Eckenrode <randy@largeandhighquality.com> | 2023-11-06 16:48:02 -0500 |
---|---|---|
committer | Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com> | 2023-11-08 10:50:07 +0000 |
commit | 93153208ccd87b7e7dcfc00b5f1a732e675ff5a6 (patch) | |
tree | ad2e1b6564b98a3d7d9e25adfd93ddf4f80b08d5 /pkgs/development/compilers/gcc | |
parent | d4f8aac2c57ff594fea2ffa4ed95e84af5036e1d (diff) | |
download | nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar.gz nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar.bz2 nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar.lz nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar.xz nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.tar.zst nixlib-93153208ccd87b7e7dcfc00b5f1a732e675ff5a6.zip |
gcc{8,9}: don’t pass --gstabs to clang assembler
Darwin uses the clang integrated assembler, which does not support `--gstabs`. While the `configure` script detects whether the assembler supports it, Darwin passes `--gstabs` unconditionally. This patch is backported to make the bootstrap only use it when supported.
Diffstat (limited to 'pkgs/development/compilers/gcc')
3 files changed, 203 insertions, 0 deletions
diff --git a/pkgs/development/compilers/gcc/patches/8/gcc8-darwin-as-gstabs.patch b/pkgs/development/compilers/gcc/patches/8/gcc8-darwin-as-gstabs.patch new file mode 100644 index 000000000000..1ac870e57298 --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/8/gcc8-darwin-as-gstabs.patch @@ -0,0 +1,96 @@ +Backported from https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b2cee5e1e89c8f939bc36fe9756befcb93d96982 + +diff -ur a/gcc/config/darwin.h b/gcc/config/darwin.h +--- a/gcc/config/darwin.h 2021-05-14 04:42:08.000000000 -0400 ++++ b/gcc/config/darwin.h 2023-11-06 08:53:27.629155053 -0500 +@@ -233,12 +233,18 @@ + + #define DSYMUTIL "\ndsymutil" + ++/* Spec that controls whether the debug linker is run automatically for ++ a link step. This needs to be done if there is a source file on the ++ command line which will result in a temporary object (and debug is ++ enabled). */ ++ + #define DSYMUTIL_SPEC \ + "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ + %{v} \ +- %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ +- %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \ +- %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" ++ %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ ++ %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\ ++ .f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ ++ %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" + + #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC + +@@ -469,18 +475,31 @@ + /* Default ASM_DEBUG_SPEC. Darwin's as cannot currently produce dwarf + debugging data. */ + ++#ifdef HAS_AS_STABS_DIRECTIVE ++/* We only pass a debug option to the assembler if that supports stabs, since ++ dwarf is not uniformly supported in the assemblers. */ + #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}" ++#else ++#define ASM_DEBUG_SPEC "" ++#endif ++ ++#undef ASM_DEBUG_OPTION_SPEC ++#define ASM_DEBUG_OPTION_SPEC "" ++ + #define ASM_FINAL_SPEC \ + "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform } %<gsplit-dwarf" + +-/* We still allow output of STABS if the assembler supports it. */ ++/* We now require C++11 to bootstrap and newer tools than those based on ++ stabs, so require DWARF-2, even if stabs is supported by the assembler. */ ++ ++#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG ++#define DARWIN_PREFER_DWARF ++#define DWARF2_DEBUGGING_INFO 1 ++ + #ifdef HAVE_AS_STABS_DIRECTIVE + #define DBX_DEBUGGING_INFO 1 +-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG + #endif + +-#define DWARF2_DEBUGGING_INFO 1 +- + #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug" + #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug" + #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug" +diff -ur a/gcc/config/darwin9.h b/gcc/config/darwin9.h +--- a/gcc/config/darwin9.h 2021-05-14 04:42:08.000000000 -0400 ++++ b/gcc/config/darwin9.h 2023-11-06 08:54:02.663945206 -0500 +@@ -18,29 +18,6 @@ + along with GCC; see the file COPYING3. If not see + <http://www.gnu.org/licenses/>. */ + +-/* Prefer DWARF2. */ +-#undef PREFERRED_DEBUGGING_TYPE +-#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG +-#define DARWIN_PREFER_DWARF +- +-/* Since DWARF2 is default, conditions for running dsymutil are different. */ +-#undef DSYMUTIL_SPEC +-#define DSYMUTIL_SPEC \ +- "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ +- %{v} \ +- %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ +- %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|.f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ +- %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" +- +-/* Tell collect2 to run dsymutil for us as necessary. */ +-#define COLLECT_RUN_DSYMUTIL 1 +- +-/* Only ask as for debug data if the debug style is stabs (since as doesn't +- yet generate dwarf.) */ +- +-#undef ASM_DEBUG_SPEC +-#define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{gstabs:--gstabs}}}" +- + #undef ASM_OUTPUT_ALIGNED_COMMON + #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ + do { \ diff --git a/pkgs/development/compilers/gcc/patches/9/gcc9-darwin-as-gstabs.patch b/pkgs/development/compilers/gcc/patches/9/gcc9-darwin-as-gstabs.patch new file mode 100644 index 000000000000..454139c5396c --- /dev/null +++ b/pkgs/development/compilers/gcc/patches/9/gcc9-darwin-as-gstabs.patch @@ -0,0 +1,99 @@ +Backported from https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b2cee5e1e89c8f939bc36fe9756befcb93d96982 + +diff -ur a/gcc/config/darwin.h b/gcc/config/darwin.h +--- a/gcc/config/darwin.h 2022-05-27 03:21:10.947379000 -0400 ++++ b/gcc/config/darwin.h 2023-11-06 12:18:27.209236423 -0500 +@@ -230,12 +230,18 @@ + + #define DSYMUTIL "\ndsymutil" + ++/* Spec that controls whether the debug linker is run automatically for ++ a link step. This needs to be done if there is a source file on the ++ command line which will result in a temporary object (and debug is ++ enabled). */ ++ + #define DSYMUTIL_SPEC \ + "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ + %{v} \ +- %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ +- %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \ +- %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" ++ %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ ++ %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\ ++ .f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ ++ %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" + + #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC + +@@ -463,21 +469,31 @@ + %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \ + %{static}" ASM_MMACOSX_VERSION_MIN_SPEC + +-/* Default ASM_DEBUG_SPEC. Darwin's as cannot currently produce dwarf +- debugging data. */ +- ++#ifdef HAS_AS_STABS_DIRECTIVE ++/* We only pass a debug option to the assembler if that supports stabs, since ++ dwarf is not uniformly supported in the assemblers. */ + #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}" ++#else ++#define ASM_DEBUG_SPEC "" ++#endif ++ ++#undef ASM_DEBUG_OPTION_SPEC ++#define ASM_DEBUG_OPTION_SPEC "" ++ + #define ASM_FINAL_SPEC \ + "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} %<gsplit-dwarf" + +-/* We still allow output of STABS if the assembler supports it. */ ++/* We now require C++11 to bootstrap and newer tools than those based on ++ stabs, so require DWARF-2, even if stabs is supported by the assembler. */ ++ ++#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG ++#define DARWIN_PREFER_DWARF ++#define DWARF2_DEBUGGING_INFO 1 ++ + #ifdef HAVE_AS_STABS_DIRECTIVE + #define DBX_DEBUGGING_INFO 1 +-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG + #endif + +-#define DWARF2_DEBUGGING_INFO 1 +- + #define DEBUG_FRAME_SECTION "__DWARF,__debug_frame,regular,debug" + #define DEBUG_INFO_SECTION "__DWARF,__debug_info,regular,debug" + #define DEBUG_ABBREV_SECTION "__DWARF,__debug_abbrev,regular,debug" +diff -ur a/gcc/config/darwin9.h b/gcc/config/darwin9.h +--- a/gcc/config/darwin9.h 2022-05-27 03:21:10.947379000 -0400 ++++ b/gcc/config/darwin9.h 2023-11-06 12:18:48.325260590 -0500 +@@ -18,29 +18,6 @@ + along with GCC; see the file COPYING3. If not see + <http://www.gnu.org/licenses/>. */ + +-/* Prefer DWARF2. */ +-#undef PREFERRED_DEBUGGING_TYPE +-#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG +-#define DARWIN_PREFER_DWARF +- +-/* Since DWARF2 is default, conditions for running dsymutil are different. */ +-#undef DSYMUTIL_SPEC +-#define DSYMUTIL_SPEC \ +- "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ +- %{v} \ +- %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ +- %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|.f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ +- %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" +- +-/* Tell collect2 to run dsymutil for us as necessary. */ +-#define COLLECT_RUN_DSYMUTIL 1 +- +-/* Only ask as for debug data if the debug style is stabs (since as doesn't +- yet generate dwarf.) */ +- +-#undef ASM_DEBUG_SPEC +-#define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{gstabs:--gstabs}}}" +- + #undef ASM_OUTPUT_ALIGNED_COMMON + #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ + do { \ diff --git a/pkgs/development/compilers/gcc/patches/default.nix b/pkgs/development/compilers/gcc/patches/default.nix index 8e295e161869..4325c9f81677 100644 --- a/pkgs/development/compilers/gcc/patches/default.nix +++ b/pkgs/development/compilers/gcc/patches/default.nix @@ -200,6 +200,10 @@ in ++ optional (majorVersion == "9") ./9/fix-struct-redefinition-on-glibc-2.36.patch ++ optional (atLeast7 && !atLeast10 && targetPlatform.isNetBSD) ./libstdc++-netbsd-ctypes.patch +# Make Darwin bootstrap respect whether the assembler supports `--gstabs`, +# which is not supported by the clang integrated assembler used by default on Darwin. +++ optional (is9 && hostPlatform.isDarwin) ./9/gcc9-darwin-as-gstabs.patch + ## gcc 8.0 and older ############################################################################## @@ -207,6 +211,10 @@ in ++ optional (atLeast49 && !is49 && !atLeast9) ./libsanitizer-no-cyclades-9.patch ++ optional (is7 || is8) ./9/fix-struct-redefinition-on-glibc-2.36.patch +# Make Darwin bootstrap respect whether the assembler supports `--gstabs`, +# which is not supported by the clang integrated assembler used by default on Darwin. +++ optional (is8 && hostPlatform.isDarwin) ./8/gcc8-darwin-as-gstabs.patch + ## gcc 7.0 and older ############################################################################## |