Message ID | 20230311202705.3135051-1-sam@gentoo.org |
---|---|
State | Dropped |
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 10B2C3858417 for <patchwork@sourceware.org>; Sat, 11 Mar 2023 20:27:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10B2C3858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678566460; bh=W5V36rT029onwa9VZ4gghMB6BFYfSvEgTH9OI/Oxqo4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=oTSVLmMNSuF1br+VUzmvSZbj3voqK4nnA0ZdYjJGYqOMDiHSc8ds1AIIKcIYMXMJN fCiRjUORd+6UxsjTpZLsjeEmCguXxy+j5nvUyi65LSnhz3cg7mw21kIz+Am5XWEm28 aKiAJpH483x/s0goRQm5OGvqsNi8FU8zusy4oFkw= 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 4D0DC3858D1E for <gcc-patches@gcc.gnu.org>; Sat, 11 Mar 2023 20:27:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D0DC3858D1E 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 v2] RISC-V: Avoid calloc() poisoning on musl Date: Sat, 11 Mar 2023 20:27:05 +0000 Message-Id: <20230311202705.3135051-1-sam@gentoo.org> X-Mailer: git-send-email 2.39.2 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 |
[v2] RISC-V: Avoid calloc() poisoning on musl
|
|
Commit Message
Sam James
March 11, 2023, 8:27 p.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
adding <pthread.h> include.
v2: fix changelog.
Signed-off-by: Sam James <sam@gentoo.org>
---
gcc/ChangeLog | 5 +++++
gcc/config/riscv/genrvv-type-indexer.cc | 1 +
2 files changed, 6 insertions(+)
Comments
On Sat, Mar 11, 2023 at 12:27 PM 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. > > gcc/ChangeLog: > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > adding <pthread.h> include. Is 100% not the correct fix and will break if you are doing a cross compiler building on mingw to riscv. You should add/handle INCLUDE_SSTREAM to system.h instead and then define INCLUDE_SSTREAM in genrvv-type-indexer.cc. In fact, INCLUDE_PTHREAD_H support should be removed since it is no longer being used for the jit front-end (that was moved over to std::mutex instead). Thanks, Andrew > > v2: fix changelog. > > Signed-off-by: Sam James <sam@gentoo.org> > --- > gcc/ChangeLog | 5 +++++ > gcc/config/riscv/genrvv-type-indexer.cc | 1 + > 2 files changed, 6 insertions(+) > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > index c9e557ce833..f8a1c37f76e 100644 > --- a/gcc/ChangeLog > +++ b/gcc/ChangeLog > @@ -1,3 +1,8 @@ > +2023-03-11 Sam James <sam@gentoo.org> > + > + * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > + adding <pthread.h> include. > + > 2023-03-10 Jakub Jelinek <jakub@redhat.com> > > PR target/107703 > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc > index 0ef1d766002..b286ec84132 100644 > --- a/gcc/config/riscv/genrvv-type-indexer.cc > +++ b/gcc/config/riscv/genrvv-type-indexer.cc > @@ -14,6 +14,7 @@ along with GCC; see the file COPYING3. If not see > <http://www.gnu.org/licenses/>. */ > > #include "bconfig.h" > +#define INCLUDE_PTHREAD_H > #include "system.h" > #include "errors.h" > > -- > 2.39.2 >
On Sat, Mar 11, 2023 at 12:32 PM Andrew Pinski <pinskia@gmail.com> wrote: > > On Sat, Mar 11, 2023 at 12:27 PM 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. > > > > gcc/ChangeLog: > > * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > > adding <pthread.h> include. > > > Is 100% not the correct fix and will break if you are doing a cross > compiler building on mingw to riscv. > > You should add/handle INCLUDE_SSTREAM to system.h instead and then > define INCLUDE_SSTREAM in genrvv-type-indexer.cc. > In fact, INCLUDE_PTHREAD_H support should be removed since it is no > longer being used for the jit front-end (that was moved over to > std::mutex instead). One other note, you don't need to have the changelog change in the commit, only in the commit message as the changelog is automatically updated daily from the commits Thanks, Andrew > > Thanks, > Andrew > > > > > v2: fix changelog. > > > > Signed-off-by: Sam James <sam@gentoo.org> > > --- > > gcc/ChangeLog | 5 +++++ > > gcc/config/riscv/genrvv-type-indexer.cc | 1 + > > 2 files changed, 6 insertions(+) > > > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > > index c9e557ce833..f8a1c37f76e 100644 > > --- a/gcc/ChangeLog > > +++ b/gcc/ChangeLog > > @@ -1,3 +1,8 @@ > > +2023-03-11 Sam James <sam@gentoo.org> > > + > > + * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by > > + adding <pthread.h> include. > > + > > 2023-03-10 Jakub Jelinek <jakub@redhat.com> > > > > PR target/107703 > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc > > index 0ef1d766002..b286ec84132 100644 > > --- a/gcc/config/riscv/genrvv-type-indexer.cc > > +++ b/gcc/config/riscv/genrvv-type-indexer.cc > > @@ -14,6 +14,7 @@ along with GCC; see the file COPYING3. If not see > > <http://www.gnu.org/licenses/>. */ > > > > #include "bconfig.h" > > +#define INCLUDE_PTHREAD_H > > #include "system.h" > > #include "errors.h" > > > > -- > > 2.39.2 > >
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c9e557ce833..f8a1c37f76e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2023-03-11 Sam James <sam@gentoo.org> + + * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by + adding <pthread.h> include. + 2023-03-10 Jakub Jelinek <jakub@redhat.com> PR target/107703 diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc index 0ef1d766002..b286ec84132 100644 --- a/gcc/config/riscv/genrvv-type-indexer.cc +++ b/gcc/config/riscv/genrvv-type-indexer.cc @@ -14,6 +14,7 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ #include "bconfig.h" +#define INCLUDE_PTHREAD_H #include "system.h" #include "errors.h"