Trying to build a cross-compiler for build == host == x86_64-linux-musl (Alpine Linux 3.15) and target == aarch64-apple-darwin leads to the following build error: [12:57:48] libtool: compile: x86_64-linux-musl-g++ -DHAVE_CONFIG_H -I. -I/workspace/srcdir/gcc-darwin-arm64/libcc1 -I /workspace/srcdir/gcc-darwin-arm64/libcc1/../include -I /workspace/srcdir/gcc-darwin-arm64/libcc1/../libgcc -I ../gcc -I/workspace/srcdir/gcc-darwin-arm64/libcc1/../gcc -I /workspace/srcdir/gcc-darwin-arm64/libcc1/../gcc/c -I/workspace/srcdir/gcc_build/./gmp -I/workspace/srcdir/gcc-darwin-arm64/gmp -I/workspace/srcdir/gcc_build/./mpfr/src -I/workspace/srcdir/gcc-darwin-arm64/mpfr/src -I/workspace/srcdir/gcc-darwin-arm64/mpc/src -I /workspace/srcdir/gcc-darwin-arm64/libcc1/../gcc/c-family -I /workspace/srcdir/gcc-darwin-arm64/libcc1/../libcpp/include -W -Wall -fvisibility=hidden -fcf-protection -g -O2 -MT libcc1plugin.lo -MD -MP -MF .deps/libcc1plugin.Tpo -c /workspace/srcdir/gcc-darwin-arm64/libcc1/libcc1plugin.cc -fPIC -DPIC -o .libs/libcc1plugin.o [12:57:49] In file included from /usr/include/pthread.h:30, [12:57:49] from /usr/include/c++/10.3.1/x86_64-alpine-linux-musl/bits/gthr-default.h:35, [12:57:49] from /usr/include/c++/10.3.1/x86_64-alpine-linux-musl/bits/gthr.h:148, [12:57:49] from /usr/include/c++/10.3.1/ext/atomicity.h:35, [12:57:49] from /usr/include/c++/10.3.1/memory:75, [12:57:49] from /workspace/srcdir/gcc-darwin-arm64/libcc1/deleter.hh:23, [12:57:49] from /workspace/srcdir/gcc-darwin-arm64/libcc1/rpc.hh:25, [12:57:49] from /workspace/srcdir/gcc-darwin-arm64/libcc1/libcc1plugin.cc:67: [12:57:49] /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc" [12:57:49] 84 | void *calloc(size_t, size_t); [12:57:49] | ^ [12:57:49] /usr/include/sched.h:124:36: error: attempt to use poisoned "calloc" [12:57:49] 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) [12:57:49] | ^ This was reported on the Iain Sandoe's GCC branch, but appears to be generic (i.e., not specific to aarch64 at all). It seems like it's an issue with musl headers, and there has been a similar issue reported in libgccjit before, at gentoo: https://bugs.gentoo.org/828580 (for which Alpine is shipping a patch: https://git.alpinelinux.org/aports/tree/main/gcc/0039-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch?id=dae75528cea4d8ea8e110dd4a2fbd454cc686d15)
Should have added a link to the original report: https://github.com/iains/gcc-darwin-arm64/issues/84
Created attachment 52568 [details] Patch for poisoned calloc on Musl systems Following the example of https://git.alpinelinux.org/aports/tree/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch, reported in https://bugs.gentoo.org/828580, I wrote the attached patch for libcc1, which seems to solve the issue for me.
Similar? to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105632
> libcc1/libcc1plugin.cc (In reply to Mosè Giordano from comment #2) > Created attachment 52568 [details] > Patch for poisoned calloc on Musl systems > > Following the example of > https://git.alpinelinux.org/aports/tree/main/gcc/0042-Fix-attempt-to-use- > poisoned-calloc-error-in-libgccji.patch, reported in > https://bugs.gentoo.org/828580, I wrote the attached patch for libcc1, which > seems to solve the issue for me. I think the change looks reasonable. Should be fixed by "c++: avoid <memory> poisoning on musl [PR106102]" patch from PR106102 in master and gcc-12 branches. Can you give it a try?