Message ID | 20230314002354.367655-1-sam@gentoo.org |
---|---|
State | Committed |
Commit | 0e6f87835ccabfe84afe412583544ff6e6292352 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 292B43858C60 for <patchwork@sourceware.org>; Tue, 14 Mar 2023 00:24:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 292B43858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678753477; bh=QHNSB2dgmJWPwejcxBbs/CMcwu734f3j1i3IMQDaeS4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=YuBYI9YOzWMZTUtuPGyLxC7HTcUU2sbyKdmRCGbATIG655vRZKTI7jRJuXGIaYvyo MDsapMEB/50FRGKoxbIFN0Yxa/E0akIqAzPzWdT/6InsRv+d5Io2fFtC4pR0AvpOLP Ha1w1NQpOGn2VnvRtuVinfe0msrWGLAUCqtj2fq8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 941673858D32 for <gcc-patches@gcc.gnu.org>; Tue, 14 Mar 2023 00:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 941673858D32 To: gcc-patches@gcc.gnu.org Cc: Kito Cheng <kito.cheng@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Andrew Waterman <andrew@sifive.com>, Jim Wilson <jim.wilson.gcc@gmail.com>, Ju-Zhe Zhong <juzhe.zhong@rivai.ai>, Sam James <sam@gentoo.org> Subject: [PATCH v4 1/2] RISC-V: Avoid calloc() poisoning on musl Date: Tue, 14 Mar 2023 00:23:53 +0000 Message-Id: <20230314002354.367655-1-sam@gentoo.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Sam James via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Sam James <sam@gentoo.org> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
[v4,1/2] RISC-V: Avoid calloc() poisoning on musl
|
|
Commit Message
Sam James
March 14, 2023, 12:23 a.m. UTC
This fixes errors like:
```
In file included from /usr/include/pthread.h:30,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38,
from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38,
from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22:
/usr/include/sched.h:84:7: error: attempt to use poisoned "calloc"
84 | void *calloc(size_t, size_t);
| ^
/usr/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)))
| ^
make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1
```
See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474,
which was fixed in PR106102.
gcc/ChangeLog:
* config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by
including <sstream> earlier.
* system.h: Add INCLUDE_SSTREAM.
Signed-off-by: Sam James <sam@gentoo.org>
---
gcc/config/riscv/genrvv-type-indexer.cc | 2 +-
gcc/system.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
Comments
On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > This fixes errors like: > ``` > In file included from /usr/include/pthread.h:30, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38, > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38, > from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22: > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" > 84 | void *calloc(size_t, size_t); > | ^ > /usr/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))) > | ^ > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1 > ``` > > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474, > which was fixed in PR106102. The system.h change is OK > gcc/ChangeLog: > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > including <sstream> earlier. > * system.h: Add INCLUDE_SSTREAM. > > Signed-off-by: Sam James <sam@gentoo.org> > --- > gcc/config/riscv/genrvv-type-indexer.cc | 2 +- > gcc/system.h | 4 ++++ > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc > index 0ef1d766002..e677b55290c 100644 > --- a/gcc/config/riscv/genrvv-type-indexer.cc > +++ b/gcc/config/riscv/genrvv-type-indexer.cc > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see > <http://www.gnu.org/licenses/>. */ > > #include "bconfig.h" > +#define INCLUDE_SSTREAM > #include "system.h" > #include "errors.h" > > #include "coretypes.h" > > -#include <sstream> > #include <assert.h> > #include <math.h> > > diff --git a/gcc/system.h b/gcc/system.h > index 64cd5a49258..cf45db3f97e 100644 > --- a/gcc/system.h > +++ b/gcc/system.h > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); > # include <mutex> > #endif > > +#ifdef INCLUDE_SSTREAM > +# include <sstream> > +#endif > + > #ifdef INCLUDE_MALLOC_H > #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) > #include <malloc.h> > -- > 2.40.0 >
RISC-V part is ok, and I assume you didn't have write access so I'm gonna push that since the system.h change also got approved :) On Tue, Mar 14, 2023 at 5:07 PM Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > This fixes errors like: > > ``` > > In file included from /usr/include/pthread.h:30, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38, > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38, > > from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22: > > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" > > 84 | void *calloc(size_t, size_t); > > | ^ > > /usr/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))) > > | ^ > > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1 > > ``` > > > > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474, > > which was fixed in PR106102. > > The system.h change is OK > > > gcc/ChangeLog: > > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > > including <sstream> earlier. > > * system.h: Add INCLUDE_SSTREAM. > > > > Signed-off-by: Sam James <sam@gentoo.org> > > --- > > gcc/config/riscv/genrvv-type-indexer.cc | 2 +- > > gcc/system.h | 4 ++++ > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc > > index 0ef1d766002..e677b55290c 100644 > > --- a/gcc/config/riscv/genrvv-type-indexer.cc > > +++ b/gcc/config/riscv/genrvv-type-indexer.cc > > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see > > <http://www.gnu.org/licenses/>. */ > > > > #include "bconfig.h" > > +#define INCLUDE_SSTREAM > > #include "system.h" > > #include "errors.h" > > > > #include "coretypes.h" > > > > -#include <sstream> > > #include <assert.h> > > #include <math.h> > > > > diff --git a/gcc/system.h b/gcc/system.h > > index 64cd5a49258..cf45db3f97e 100644 > > --- a/gcc/system.h > > +++ b/gcc/system.h > > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); > > # include <mutex> > > #endif > > > > +#ifdef INCLUDE_SSTREAM > > +# include <sstream> > > +#endif > > + > > #ifdef INCLUDE_MALLOC_H > > #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) > > #include <malloc.h> > > -- > > 2.40.0 > >
committed to trunk, thanks :) On Tue, Mar 14, 2023 at 9:44 PM Kito Cheng <kito.cheng@gmail.com> wrote: > > RISC-V part is ok, and I assume you didn't have write access so I'm > gonna push that since the system.h change also got approved :) > > On Tue, Mar 14, 2023 at 5:07 PM Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > This fixes errors like: > > > ``` > > > In file included from /usr/include/pthread.h:30, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38, > > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38, > > > from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22: > > > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" > > > 84 | void *calloc(size_t, size_t); > > > | ^ > > > /usr/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))) > > > | ^ > > > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1 > > > ``` > > > > > > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474, > > > which was fixed in PR106102. > > > > The system.h change is OK > > > > > gcc/ChangeLog: > > > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > > > including <sstream> earlier. > > > * system.h: Add INCLUDE_SSTREAM. > > > > > > Signed-off-by: Sam James <sam@gentoo.org> > > > --- > > > gcc/config/riscv/genrvv-type-indexer.cc | 2 +- > > > gcc/system.h | 4 ++++ > > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > > > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc > > > index 0ef1d766002..e677b55290c 100644 > > > --- a/gcc/config/riscv/genrvv-type-indexer.cc > > > +++ b/gcc/config/riscv/genrvv-type-indexer.cc > > > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see > > > <http://www.gnu.org/licenses/>. */ > > > > > > #include "bconfig.h" > > > +#define INCLUDE_SSTREAM > > > #include "system.h" > > > #include "errors.h" > > > > > > #include "coretypes.h" > > > > > > -#include <sstream> > > > #include <assert.h> > > > #include <math.h> > > > > > > diff --git a/gcc/system.h b/gcc/system.h > > > index 64cd5a49258..cf45db3f97e 100644 > > > --- a/gcc/system.h > > > +++ b/gcc/system.h > > > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); > > > # include <mutex> > > > #endif > > > > > > +#ifdef INCLUDE_SSTREAM > > > +# include <sstream> > > > +#endif > > > + > > > #ifdef INCLUDE_MALLOC_H > > > #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) > > > #include <malloc.h> > > > -- > > > 2.40.0 > > >
Kito Cheng <kito.cheng@gmail.com> writes: > RISC-V part is ok, and I assume you didn't have write access so I'm > gonna push that since the system.h change also got approved :) > > On Tue, Mar 14, 2023 at 5:07 PM Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches >> <gcc-patches@gcc.gnu.org> wrote: >> > >> > This fixes errors like: >> > ``` >> > In file included from /usr/include/pthread.h:30, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38, >> > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38, >> > from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22: >> > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" >> > 84 | void *calloc(size_t, size_t); >> > | ^ >> > /usr/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))) >> > | ^ >> > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1 >> > ``` >> > >> > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474, >> > which was fixed in PR106102. >> >> The system.h change is OK Thanks Richard. Are you able to commit this for me? best, sam >> >> > gcc/ChangeLog: >> > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by >> > including <sstream> earlier. >> > * system.h: Add INCLUDE_SSTREAM. >> > >> > Signed-off-by: Sam James <sam@gentoo.org> >> > --- >> > gcc/config/riscv/genrvv-type-indexer.cc | 2 +- >> > gcc/system.h | 4 ++++ >> > 2 files changed, 5 insertions(+), 1 deletion(-) >> > >> > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc >> > index 0ef1d766002..e677b55290c 100644 >> > --- a/gcc/config/riscv/genrvv-type-indexer.cc >> > +++ b/gcc/config/riscv/genrvv-type-indexer.cc >> > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see >> > <http://www.gnu.org/licenses/>. */ >> > >> > #include "bconfig.h" >> > +#define INCLUDE_SSTREAM >> > #include "system.h" >> > #include "errors.h" >> > >> > #include "coretypes.h" >> > >> > -#include <sstream> >> > #include <assert.h> >> > #include <math.h> >> > >> > diff --git a/gcc/system.h b/gcc/system.h >> > index 64cd5a49258..cf45db3f97e 100644 >> > --- a/gcc/system.h >> > +++ b/gcc/system.h >> > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); >> > # include <mutex> >> > #endif >> > >> > +#ifdef INCLUDE_SSTREAM >> > +# include <sstream> >> > +#endif >> > + >> > #ifdef INCLUDE_MALLOC_H >> > #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) >> > #include <malloc.h> >> > -- >> > 2.40.0 >> >
Kito Cheng <kito.cheng@gmail.com> writes: > committed to trunk, thanks :) > > On Tue, Mar 14, 2023 at 9:44 PM Kito Cheng <kito.cheng@gmail.com> wrote: >> >> RISC-V part is ok, and I assume you didn't have write access so I'm >> gonna push that since the system.h change also got approved :) Thanks a bunch! :) >> >> On Tue, Mar 14, 2023 at 5:07 PM Richard Biener via Gcc-patches >> <gcc-patches@gcc.gnu.org> wrote: >> > >> > On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches >> > <gcc-patches@gcc.gnu.org> wrote: >> > > >> > > This fixes errors like: >> > > ``` >> > > In file included from /usr/include/pthread.h:30, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38, >> > > from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38, >> > > from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22: >> > > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" >> > > 84 | void *calloc(size_t, size_t); >> > > | ^ >> > > /usr/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))) >> > > | ^ >> > > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1 >> > > ``` >> > > >> > > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474, >> > > which was fixed in PR106102. >> > >> > The system.h change is OK >> > >> > > gcc/ChangeLog: >> > > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by >> > > including <sstream> earlier. >> > > * system.h: Add INCLUDE_SSTREAM. >> > > >> > > Signed-off-by: Sam James <sam@gentoo.org> >> > > --- >> > > gcc/config/riscv/genrvv-type-indexer.cc | 2 +- >> > > gcc/system.h | 4 ++++ >> > > 2 files changed, 5 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc >> > > index 0ef1d766002..e677b55290c 100644 >> > > --- a/gcc/config/riscv/genrvv-type-indexer.cc >> > > +++ b/gcc/config/riscv/genrvv-type-indexer.cc >> > > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see >> > > <http://www.gnu.org/licenses/>. */ >> > > >> > > #include "bconfig.h" >> > > +#define INCLUDE_SSTREAM >> > > #include "system.h" >> > > #include "errors.h" >> > > >> > > #include "coretypes.h" >> > > >> > > -#include <sstream> >> > > #include <assert.h> >> > > #include <math.h> >> > > >> > > diff --git a/gcc/system.h b/gcc/system.h >> > > index 64cd5a49258..cf45db3f97e 100644 >> > > --- a/gcc/system.h >> > > +++ b/gcc/system.h >> > > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); >> > > # include <mutex> >> > > #endif >> > > >> > > +#ifdef INCLUDE_SSTREAM >> > > +# include <sstream> >> > > +#endif >> > > + >> > > #ifdef INCLUDE_MALLOC_H >> > > #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) >> > > #include <malloc.h> >> > > -- >> > > 2.40.0 >> > >
diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc index 0ef1d766002..e677b55290c 100644 --- a/gcc/config/riscv/genrvv-type-indexer.cc +++ b/gcc/config/riscv/genrvv-type-indexer.cc @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #include "bconfig.h" +#define INCLUDE_SSTREAM #include "system.h" #include "errors.h" #include "coretypes.h" -#include <sstream> #include <assert.h> #include <math.h> diff --git a/gcc/system.h b/gcc/system.h index 64cd5a49258..cf45db3f97e 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); # include <mutex> #endif +#ifdef INCLUDE_SSTREAM +# include <sstream> +#endif + #ifdef INCLUDE_MALLOC_H #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) #include <malloc.h>