Created attachment 35149 [details] Reproducer Hello, When disabling standard headers inclusion, it is impossible to use GCC intrinsics: $ ./release/usr/local/bin/gcc -mavx -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include -S repro.c In file included from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/xmmintrin.h:38:0, from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/x86intrin.h:34, from repro.c:2: /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/mm_malloc.h:27:20: fatal error: stdlib.h: No such file or directory compilation terminated. This is because `mm_malloc.h' depends on malloc () / free () calls. Maybe remove this dependence?
IMHO a user error, if you use -nostdinc, you are responsible for letting the compiler know where to find all the needed includes.
(In reply to Jakub Jelinek from comment #1) > IMHO a user error, if you use -nostdinc, you are responsible for letting the > compiler know where to find all the needed includes. Yes, but for my case, these header is not needed. Moreover, as far as I understand <stdlib.h> inclusion was added for compatibility with ICC only. Maybe, somehow check if this header is available and include <mm_malloc.h> into <x86intrin.h> only if it is.
*** Bug 102231 has been marked as a duplicate of this bug. ***
Since you closed PR102231 (which has a lot more detail), let me paste that here: <xmmintrin.h> includes <mm_malloc.h> unconditionally Instead, it should do something like #if __STDC_HOSTED__ #include <mm_malloc.h> #endif as Clang does, because <mm_malloc.h> only exists on hosted environments (which is good, because it itself uses <stdlib.h>, etc.) A few intrinsics that use stuff from <mm_malloc.h> need the same treatment. (apparently <mm_malloc.h> *is* created by GCC, but in the source tree it is pmm_malloc.h and gmm_malloc.h).
We could avoid the stdlib.h include for pmm_alloc.h through __builtin_malloc/__builtin_free and __SIZE_TYPE__. But yes, maybe not defining _mm_malloc/_mm_free at all for non-__STDC_HOSTED__ is better.
And the "somehow" is now possible too, we can use __has_include(<stdlib.h>).
(In reply to Jakub Jelinek from comment #6) > And the "somehow" is now possible too, we can use __has_include(<stdlib.h>). Including it with -ffreestanding in effect is always wrong. Even if the header exists it may not be what you expected.