8

I'm building a native musl compiler (GCC 8.3.0) with a cross musl compiler (same version) and I'm getting this error:

In file included from /usr/local/x86_64-cros-linux-musl/include/pthread.h:30,
                 from /usr/local/x86_64-cros-linux-musl/lib/gcc/x86_64-cros-linux-musl/8.3.0/include/c++/x86_64-cros-linux-musl/bits/gthr-default.h:35,
                 from /usr/local/x86_64-cros-linux-musl/lib/gcc/x86_64-cros-linux-musl/8.3.0/include/c++/x86_64-cros-linux-musl/bits/gthr.h:148,
                 from /usr/local/x86_64-cros-linux-musl/lib/gcc/x86_64-cros-linux-musl/8.3.0/include/c++/ext/atomicity.h:35,
                 from /usr/local/x86_64-cros-linux-musl/lib/gcc/x86_64-cros-linux-musl/8.3.0/include/c++/bits/basic_string.h:39,
                 from /usr/local/x86_64-cros-linux-musl/lib/gcc/x86_64-cros-linux-musl/8.3.0/include/c++/string:52,
                 from ../../gcc-8.3.0/gcc/brig/brigfrontend/brig-to-generic.h:25,
                 from ../../gcc-8.3.0/gcc/brig/brig-lang.c:46:
/usr/local/x86_64-cros-linux-musl/include/sched.h:76:7: error: attempt to use poisoned "calloc"
 void *calloc(size_t, size_t);
       ^
/usr/local/x86_64-cros-linux-musl/include/sched.h:116:36: error: attempt to use poisoned "calloc"
 #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
                                    ^

Any ideas on how to circumvent this?

Details:

target/host triple: x86_64-linux-musl

musl version: 1.1.21

I've applied the musl patches here: http://port70.net/~nsz/musl/gcc-8.2.0/

And I've run this command while in the source directory:

sed -e '/m64=/s/lib64/lib/' -i gcc/config/i386/t-linux64
S.S. Anne
  • 15,171
  • 8
  • 38
  • 76

2 Answers2

4

So I'm going to just go ahead and assume that #pragma poison calloc is in your header files rather than in system header files.

Recommended general solution: include all system headers before using #pragma poison; this can get tricky when multiple program headers but it really needs to be done.

The alternative is to just up and remove #pragma poison from the source code and the safeguard with it.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • 1
    Yeah, it's in `libcpp/system.h`. Musl does some trickery with defining prototypes in multiple places, so I guess I'll just `#include ` beforehand and be done with it. Thanks. – S.S. Anne Mar 09 '19 at 14:23
-2

I have had similar problems with malloc when building gcc, I fixed it by changing the malloc calls to 'xmalloc', I did a grep and there is a 'xcalloc' available.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23