如何在GCC中规避“尝试使用中毒的malloc / calloc”错误?

时间:2019-03-08 22:51:08

标签: c gcc musl

我正在使用交叉musl编译器(相同版本)构建本机musl编译器(GCC 8.3.0),但出现此错误:

t

关于如何规避此事的任何想法?

详细信息:

目标/主机三元组: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))) ^

音乐版本:x86_64-linux-musl

我在此处应用了肌肉补丁:http://port70.net/~nsz/musl/gcc-8.2.0/

我已经在源目录中运行了此命令:

1.1.21

1 个答案:

答案 0 :(得分:3)

所以我将继续假设#pragma poison calloc在您的头文件中,而不是在系统头文件中。

推荐的一般解决方案:在使用#pragma poison之前包括所有系统头文件;当有多个程序头时,这可能会很棘手,但这确实需要完成。

另一种选择是从源代码及其保护措施中删除#pragma poison