[Bug c++/106102] gcc/cp/mapper-resolver.cc fails to build against musl: musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jun 29 18:17:24 GMT 2022


--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sergei Trofimovich <slyfox@gcc.gnu.org>:


commit r13-1350-g49d508065bdd36fb1a9b6aad9666b1edb5e06474
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Mon Jun 27 23:42:44 2022 +0100

    jit: avoid calloc() poisoning on musl [PR106102]

    On musl <pthread.h> uses calloc() (via <sched.h>). jit/ includes
    it directly and exposes use of poisoned calloc():

        /build/build/./prev-gcc/xg++ ...
        make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
        make[3]: *** Waiting for unfinished jobs....
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                         from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:
        /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use
poisoned "calloc"
           84 | void *calloc(size_t, size_t);
              |       ^
        /<<NIX>>/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 <pthread.h> inclusion to "system.h" under new
    INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit.


            PR c++/106102
            * system.h: Introduce INCLUDE_PTHREAD_H macros to include


            PR c++/106102
            * jit-playback.cc: Include <pthread.h> via "system.h" to avoid
            * jit-recording.cc: Ditto.
            * libgccjit.cc: Ditto.

More information about the Gcc-bugs mailing list