From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7819) id 46FEB38485BD; Wed, 29 Jun 2022 18:17:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46FEB38485BD MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Sergei Trofimovich To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1350] jit: avoid calloc() poisoning on musl [PR106102] X-Act-Checkin: gcc X-Git-Author: Sergei Trofimovich X-Git-Refname: refs/heads/master X-Git-Oldrev: b8f284d3673004dffae714b56ed663467c2a52a7 X-Git-Newrev: 49d508065bdd36fb1a9b6aad9666b1edb5e06474 Message-Id: <20220629181723.46FEB38485BD@sourceware.org> Date: Wed, 29 Jun 2022 18:17:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2022 18:17:23 -0000 https://gcc.gnu.org/g:49d508065bdd36fb1a9b6aad9666b1edb5e06474 commit r13-1350-g49d508065bdd36fb1a9b6aad9666b1edb5e06474 Author: Sergei Trofimovich Date: Mon Jun 27 23:42:44 2022 +0100 jit: avoid calloc() poisoning on musl [PR106102] On musl uses calloc() (via ). jit/ includes it directly and exposes use of poisoned calloc(): /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44: /<>/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 moves inclusion to "system.h" under new INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. gcc/ PR c++/106102 * system.h: Introduce INCLUDE_PTHREAD_H macros to include . gcc/jit/ PR c++/106102 * jit-playback.cc: Include via "system.h" to avoid calloc() poisoning. * jit-recording.cc: Ditto. * libgccjit.cc: Ditto. Diff: --- gcc/jit/jit-playback.cc | 3 +-- gcc/jit/jit-recording.cc | 2 +- gcc/jit/libgccjit.cc | 2 +- gcc/system.h | 4 ++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 6be6bdf8dea..79714132b91 100644 --- 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" diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc index 697dee66e73..f78daed2d71 100644 --- 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" diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc index 0e76097b4ba..ca862662777 100644 --- 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" diff --git a/gcc/system.h b/gcc/system.h index 67158b70c78..f8d42ff6815 100644 --- 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