From 8f00857bf94b1bd4027e7de8ae213a5f5d392cc4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 9 Jul 2022 09:35:25 +0100 Subject: pkgsMusl.gcc12: backport build fix (PR106102) Without the change gcc-12 on musl fails to build due to system headers poisoning: /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35, .... from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77, from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24, from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25, from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23, from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32: /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" 84 | void *calloc(size_t, size_t); | ^ /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) | ^ The change pulls upstream fix as is. --- .../gcc/12/PR106102-musl-poison-cpp.patch | 52 +++++++++++++++++ .../gcc/12/PR106102-musl-poison-jit.patch | 67 ++++++++++++++++++++++ pkgs/development/compilers/gcc/12/default.nix | 3 + 3 files changed, 122 insertions(+) create mode 100644 pkgs/development/compilers/gcc/12/PR106102-musl-poison-cpp.patch create mode 100644 pkgs/development/compilers/gcc/12/PR106102-musl-poison-jit.patch (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/gcc/12/PR106102-musl-poison-cpp.patch b/pkgs/development/compilers/gcc/12/PR106102-musl-poison-cpp.patch new file mode 100644 index 0000000000000..05677f5cf85ca --- /dev/null +++ b/pkgs/development/compilers/gcc/12/PR106102-musl-poison-cpp.patch @@ -0,0 +1,52 @@ +https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3b21c21f3f5726823e19728fdd1571a14aae0fb3 +https://gcc.gnu.org/PR106102 +--- a/gcc/cp/mapper-client.cc ++++ b/gcc/cp/mapper-client.cc +@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see + #define INCLUDE_STRING + #define INCLUDE_VECTOR + #define INCLUDE_MAP ++#define INCLUDE_MEMORY + #include "system.h" + + #include "line-map.h" +--- a/gcc/cp/mapper-resolver.cc ++++ b/gcc/cp/mapper-resolver.cc +@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see + #define INCLUDE_VECTOR + #define INCLUDE_ALGORITHM + #define INCLUDE_MAP ++#define INCLUDE_MEMORY + #include "system.h" + + // We don't want or need to be aware of networking +--- a/gcc/cp/module.cc ++++ b/gcc/cp/module.cc +@@ -206,6 +206,7 @@ Classes used: + + #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ + #include "config.h" ++#define INCLUDE_MEMORY + #define INCLUDE_STRING + #define INCLUDE_VECTOR + #include "system.h" +--- a/libcc1/libcc1plugin.cc ++++ b/libcc1/libcc1plugin.cc +@@ -31,6 +31,7 @@ + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + ++#define INCLUDE_MEMORY + #include "gcc-plugin.h" + #include "system.h" + #include "coretypes.h" +--- a/libcc1/libcp1plugin.cc ++++ b/libcc1/libcp1plugin.cc +@@ -32,6 +32,7 @@ + #undef PACKAGE_TARNAME + #undef PACKAGE_VERSION + ++#define INCLUDE_MEMORY + #include "gcc-plugin.h" + #include "system.h" + #include "coretypes.h" diff --git a/pkgs/development/compilers/gcc/12/PR106102-musl-poison-jit.patch b/pkgs/development/compilers/gcc/12/PR106102-musl-poison-jit.patch new file mode 100644 index 0000000000000..e4ff25be512cf --- /dev/null +++ b/pkgs/development/compilers/gcc/12/PR106102-musl-poison-jit.patch @@ -0,0 +1,67 @@ +https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=49d508065bdd36fb1a9b6aad9666b1edb5e06474 +https://gcc.gnu.org/PR106102 +--- a/gcc/jit/jit-playback.cc ++++ b/gcc/jit/jit-playback.cc +@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" ++#define INCLUDE_PTHREAD_H + #include "system.h" + #include "coretypes.h" + #include "target.h" +@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see + #include "diagnostic.h" + #include "stmt.h" + +-#include +- + #include "jit-playback.h" + #include "jit-result.h" + #include "jit-builtins.h" +--- a/gcc/jit/jit-recording.cc ++++ b/gcc/jit/jit-recording.cc +@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" ++#define INCLUDE_PTHREAD_H + #include "system.h" + #include "coretypes.h" + #include "tm.h" + #include "pretty-print.h" + #include "toplev.h" + +-#include + + #include "jit-builtins.h" + #include "jit-recording.h" +--- a/gcc/jit/libgccjit.cc ++++ b/gcc/jit/libgccjit.cc +@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see + . */ + + #include "config.h" ++#define INCLUDE_PTHREAD_H + #include "system.h" + #include "coretypes.h" + #include "timevar.h" + #include "typed-splay-tree.h" + #include "cppbuiltin.h" +-#include + + #include "libgccjit.h" + #include "jit-recording.h" +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -753,6 +753,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); + #endif + #endif + ++#ifdef INCLUDE_PTHREAD_H ++#include ++#endif ++ + #ifdef INCLUDE_ISL + #ifdef HAVE_isl + #include diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index 13d040fc4957c..20bc9dcf44bb9 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -69,6 +69,9 @@ let majorVersion = "12"; ../gnat-cflags-11.patch ../gcc-12-gfortran-driving.patch ../ppc-musl.patch + # Backports. Should be removed with 12.2.0 release: + ./PR106102-musl-poison-cpp.patch + ./PR106102-musl-poison-jit.patch ] ++ optional (stdenv.isDarwin && stdenv.isAarch64) (fetchpatch { url = "https://github.com/fxcoudert/gcc/compare/releases/gcc-11.1.0...gcc-11.1.0-arm-20210504.diff"; sha256 = "sha256-JqCGJAfbOxSmkNyq49aFHteK/RFsCSLQrL9mzUCnaD0="; -- cgit 1.4.1