public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6662] RISC-V: Avoid calloc() poisoning on musl
@ 2023-03-14 13:47 Kito Cheng
  0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2023-03-14 13:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0e6f87835ccabfe84afe412583544ff6e6292352

commit r13-6662-g0e6f87835ccabfe84afe412583544ff6e6292352
Author: Sam James <sam@gentoo.org>
Date:   Tue Mar 14 00:23:53 2023 +0000

    RISC-V: Avoid calloc() poisoning on musl
    
    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>

Diff:
---
 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>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-14 13:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 13:47 [gcc r13-6662] RISC-V: Avoid calloc() poisoning on musl Kito Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).