[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.
Raphael Isemann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 22 13:38:52 PST 2019
teemperor abandoned this revision.
teemperor added a comment.
So, the idea of going back to the headers and see if we can potentially remove mm_malloc from the modulemap didn't work out (mostly because a lot of headers include it indirectly).
However, when going back to the original issue i noticed that the stdlib.h that's at fault is the one from stdlibc++, not the glibc one. In fact, the issue becomes more clear when re-adding cstdlib to my stl modulemap:
. /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/stdlib.h
While building module 'stl11' imported from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/stdlib.h:36:
While building module '_Builtin_intrinsics' imported from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu/bits/opt_random.h:34:
In file included from <module-includes>:2:
In file included from /usr/lib/clang/7.0.1/include/immintrin.h:32:
In file included from /usr/lib/clang/7.0.1/include/xmmintrin.h:39:
In file included from /usr/lib/clang/7.0.1/include/mm_malloc.h:27:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/stdlib.h:36:11: fatal error: cyclic dependency in module 'stl11': stl11 -> _Builtin_intrinsics
-> stl11
# include <cstdlib>
^
While building module 'stl11' imported from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/stdlib.h:36:
In file included from <module-includes>:52:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/random:50:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/x86_64-pc-linux-gnu/bits/opt_random.h:34:10: fatal error: could not build module
'_Builtin_intrinsics'
#include <pmmintrin.h>
~~~~~~~~^
In file included from test.cpp:2:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/stdlib.h:36:11: fatal error: could not build module 'stl11'
# include <cstdlib>
~~~~~~~~^
3 errors generated.
So to summarize: including stdlib.h (or cstdlib) is triggering our stl module to build, which in turn causes our `random` module to trigger which includes mm_malloc indirectly. If we move cstdlib and stdlib.h in their own modules we break the cyclic dependency. It's not optimal but I think it's less hacky than this patch or any of the other workarounds we came up with so far.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D43871/new/
https://reviews.llvm.org/D43871
More information about the cfe-commits
mailing list