<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 14, 2015, at 3:32 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 14, 2015 at 2:03 PM, Adrian Prantl via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class="h5"><blockquote type="cite" class=""><div class="">On Oct 14, 2015, at 11:37 AM, Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>> wrote:</div><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" class=""><div class="">On Oct 13, 2015, at 7:43 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank" class="">richard@metafoo.co.uk</a>> wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 13, 2015 at 6:54 PM, Sean Silva<span class=""> </span><span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class="">On Tue, Oct 13, 2015 at 6:14 PM, Richard Smith<span class=""> </span><span dir="ltr" class=""><<a href="mailto:richard@metafoo.co.uk" target="_blank" class="">richard@metafoo.co.uk</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class="">On Tue, Oct 13, 2015 at 5:31 PM, Sean Silva<span class=""> </span><span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class="">On Tue, Oct 13, 2015 at 3:17 PM, Richard Smith via cfe-commits<span class=""> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Oct 13, 2015 at 2:10 PM, Adrian Prantl via cfe-commits<span class=""> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class=""> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Richard,<br class=""><br class="">this commit appears to break the module self-host on Darwin.<br class=""><br class="">When compiling the following program generated by clang’s own cmake script:<br class=""><br class="">> #undef NDEBUG<br class="">> #include <cassert><br class="">> #define NDEBUG<br class="">> #include <cassert><br class="">> int main() { assert(this code is not compiled); }<br class=""><br class="">with clang++ -std=c++11 -fmodules -fcxx-modules test.cpp<br class=""></blockquote><div class=""><br class=""></div></span><div class="">(You don't need -fcxx-modules here.)</div><span class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I get<br class=""><br class="">> While building module 'std' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/cassert:20" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20</a>:<br class="">> While building module 'Darwin' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/cstddef:39" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:39</a>:<br class="">> In file included from <module-includes>:98:<br class="">> In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/wchar.h:92:<br class="">> In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/_wctype.h:57:</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">> /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/ctype.h:33:10" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/ctype.h:33:10</a>: fatal error: cyclic dependency in module 'std': std -> Darwin -> std<br class="">> #include <__config><br class="">>          ^<br class="">> While building module 'std' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/cassert:20" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20</a>:<br class="">> In file included from <module-includes>:1:<br class="">> In file included from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/algorithm:624" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/algorithm:624</a>:<br class="">> In file included from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/initializer_list:47" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/initializer_list:47</a>:<br class="">> /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/cstddef:39:10" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:39:10</a>: fatal error: could not build module 'Darwin'<br class="">> #include <stddef.h><br class="">>  ~~~~~~~~^<br class="">> In file included from test.cpp:2:<br class="">> /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/cassert:20:10" rel="noreferrer" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20:10</a>: fatal error: could not build module 'std'<br class="">> #include <__config><br class="">>  ~~~~~~~~^<br class="">> 3 errors generated.<br class=""><br class="">Let me know how I can help in diagnosing what’s going on here.<br class=""></blockquote><div class=""><br class=""></div></span><div class="">OK, I see what's wrong. Is this working any better for you in r250236?</div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">We're still seeing:</div><div class=""><br class=""></div><div class=""><div class="">While building module 'Darwin' imported from /usr/include/assert.h:42:</div><div class="">While building module 'std' imported from /path/to/build_cmake/stage1/bin/../include/c++/v1/math.h:309:</div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">Argh, this is including <type_traits>, which is in the std module. Can you try removing the header "type_traits" line from the libc++ module map and see if that helps?</div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">I've run into this issue in the past, and I don't think that will fix it (see below). Just to be sure, here is the output with type_traits removed from the module map::</div><div class=""><br class=""></div><div class=""><span class=""><div class="">While building module 'Darwin' imported from /usr/include/assert.h:42:</div></span><div class="">While building module 'std' imported from /path/to/build_cmake/stage1/bin/../include/c++/v1/type_traits:211:</div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">That's an include of <cstddef>. We'd need to apply this workaround to that header too (but I think the buck stops there).</div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">After commenting out the cstddef module as well, the test case compiles again. Should I commit that and the type_traits change to libcxx, or are you working on a better fix?</div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">To answer my previous question, removing the type_traits module allows us to finish all the cmake checks, but it then fails when building the LLVM_Utils module:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">While building module 'LLVM_Utils' imported from ../lib/Support/APFloat.cpp:15:</div><span class=""><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from <module-includes>:1:</div></span><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/APFloat.h:20:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/APInt.h:19:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/ArrayRef.h:14:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/SmallVector.h:17:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class=""><b class="">../include/llvm/ADT/iterator_range.h:63:36: </b><span style="color:#c33720" class=""><b class="">error: </b></span><b class="">declaration of 'declval' must be imported from module 'Darwin.C.tgmath' before it is required</b></div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">iterator_range<decltype(begin(std::declval<T>()))> drop_begin(T &&t, int n) {</div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,189,38);font-size:11px" class=""><b class="">                                   ^</b></div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class=""><b class="">/Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/type_traits:700:1:" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/type_traits:700:1:</a> note: </b>previous declaration is here</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">declval() _NOEXCEPT;</div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,189,38);font-size:11px" class=""><b class="">^</b></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Can you try adding -fmodules-local-submodule-visibility to your CXXFLAGS?</div></div></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>Doing that results in an entirely different set of errors:</div><div><br class=""></div><div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'LLVM_Utils' imported from ../lib/Support/APFloat.cpp:15:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'std' imported from ../include/llvm/ADT/iterator_range.h:22:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'Darwin' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:</a></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from <module-includes>:2:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/cdefs.h:533:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_symbol_aliasing.h:29:3: </b><span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class=""><b class="">error: </b></span><b class="">"Never use</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">      <sys/_symbol_aliasing.h> directly. Use <sys/cdefs.h> instead."</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""># error "Never use <sys/_symbol_aliasing.h> directly.  Use <sys/cdefs.h> instead."</div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38); font-size: 11px;" class=""><b class="">  ^</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'LLVM_Utils' imported from ../lib/Support/APFloat.cpp:15:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'std' imported from ../include/llvm/ADT/iterator_range.h:22:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'Darwin' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:</a></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from <module-includes>:2:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/cdefs.h:599:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_posix_availability.h:29:3: </b><span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class=""><b class="">error: </b></span><b class="">"Never use</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">      <sys/_posix_availability.h> directly. Use <sys/cdefs.h> instead."</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""># error "Never use <sys/_posix_availability.h> directly.  Use <sys/cdefs.h> instead."</div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38); font-size: 11px;" class=""><b class="">  ^</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'LLVM_Utils' imported from ../lib/Support/APFloat.cpp:15:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'std' imported from ../include/llvm/ADT/iterator_range.h:22:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">While building module 'Darwin' imported from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:43:</a></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from <module-includes>:8:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/copyfile.h:36:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from /Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/bin/../lib/clang/3.8.0/include/stdint.h:63:" class="">llvm.org/_build.ninja.release/bin/../lib/clang/3.8.0/include/stdint.h:63:</a></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/stdint.h:53:</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/_types/_intptr_t.h:30:9: </b><span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class=""><b class="">error: </b></span><b class="">declaration of</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">      '__darwin_intptr_t' must be imported from module 'Darwin.machine._types' before it is required</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">typedef __darwin_intptr_t       intptr_t;</div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38); font-size: 11px;" class=""><b class="">        ^</b></div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class=""><b class="">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/i386/_types.h:49:16: note: </b>previous declaration is here</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">typedef long                    __darwin_intptr_t;</div><div style="margin: 0px; line-height: normal; font-family: Menlo; font-size: 11px;" class="">[...]</div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 189, 38); font-size: 11px;" class=""><b class="">                                ^</b></div><div class="">-- adrian</div></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">While building module 'LLVM_Utils' imported from ../lib/Support/APFloat.cpp:15:</div><span class=""><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from <module-includes>:1:</div></span><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/APFloat.h:20:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/APInt.h:19:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/ArrayRef.h:14:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/ADT/SmallVector.h:20:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">In file included from ../include/llvm/Support/MathExtras.h:21:</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class=""><b class="">/Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/type_traits:220:8:" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/type_traits:220:8:</a> </b><span style="color:#c33720" class=""><b class="">error: </b></span><b class="">redefinition of '__void_t'</b></div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">struct __void_t { typedef void type; };</div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,189,38);font-size:11px" class=""><b class="">       ^</b></div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class=""><b class="">/Users/buildslave/adrian/<a href="http://llvm.org/_build.ninja.release/include/c++/v1/type_traits:220:8:" target="_blank" class="">llvm.org/_build.ninja.release/bin/../include/c++/v1/type_traits:220:8:</a> note: </b>previous definition is here</div><div style="margin:0px;line-height:normal;font-family:Menlo;font-size:11px" class="">struct __void_t { typedef void type; };</div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,189,38);font-size:11px" class=""><b class="">       ^</b></div><div class="">If there is a way to prevent Clang from going into std when building Darwin, it looks like that’d be the way to go.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">There is no such way currently, but we could add one. The question is, is it OK that newer versions of libc++ would only work with newer versions of Clang if modules are enabled? I'm inclined to think this is fine, since Clang's modules support is still advertised as being experimental, but if (say) you or the Sony folks tell me you need new versions of libc++ to work with some already-shipped Clang binary then we'll need to reconsider.</div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class="h5">-- adrian<blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><span class=""><div class="">In file included from <module-includes>:1:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/algorithm:624:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/initializer_list:47:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/cstddef:43:</div><div class="">/path/to/build_cmake/stage1/bin/../include/c++/v1/stddef.h:46:15: fatal error: cyclic dependency in module 'Darwin': Darwin -> std -> Darwin</div><div class="">#include_next <stddef.h></div><div class="">             <span class=""> </span>^</div><div class="">While building module 'Darwin' imported from /usr/include/assert.h:42:</div><div class="">In file included from <module-includes>:80:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../lib/clang/3.8.0/include/tgmath.h:29:</div></span><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/math.h:309:</div><div class="">/path/to/build_cmake/stage1/bin/../include/c++/v1/type_traits:211:10: fatal error: could not build module 'std'</div><div class="">#include <cstddef></div><span class=""><div class=""> ~~~~~~~~^</div><div class="">In file included from modules.cpp:2:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/cassert:21:</div><div class="">/usr/include/assert.h:42:10: fatal error: could not build module 'Darwin'</div><div class="">#include <sys/cdefs.h></div><div class=""> ~~~~~~~~^</div><div class="">3 errors generated.</div></span></div><div class=""> </div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><span class=""><div class="">What we really need here is a way to get the Darwin blah.h headers to only include each other, and not find the libc++ headers. Do you need something that works with new libc++ and old Clang, or would a Clang feature to prevent the Darwin module from finding the std module's headers work for you?</div></span></div></div></div></blockquote><div class=""><br class=""></div><div class="">I've run into this issue in the wild with the modularized PS4 SDK, so I think that a clang feature that prevents this is the best fit. I think I may have already mentioned this to you at one of the socials but just to have it in writing here for everybody else, the root cause of the issue is that `-Imylib` will cause mylib/assert.h to be selected for `#include <assert.h>`, even when building the system module. Hence some random user header will end up as being part of the system module and the seed for problems has been planted.</div><div class=""><br class=""></div><div class="">If the random user header then ends up including code from a module that depends on the system module, then clang will go off and build this other module, which itself (say) depends on the system module, which triggers the recursive dependency error.</div><div class=""><br class=""></div><div class="">There's nothing special about system headers for this issue, but due to their position at the root of the dependency tree they seem to be the ones affected in practice. The fundamental problem is that some random header outside the module is interposing for the header listed in the module map. I think the feature basically needs to be about making the module more "hermetically sealed" in this scenario. Off the top of my head, maybe something like putting the module map's directory at the front of the search path for includes? That seems sort of hacky. Any ideas?</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">I was thinking: if we found the module map for a module in some include path, then we should build that module with only the directories from the header search path at or before that directory in the list of include dirs. That's probably a fairly simple change.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class=""><font color="#888888" class=""><div class="">-- Sean Silva</div></font></span><div class=""><div class=""><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><span class=""><div class="">In file included from <module-includes>:1:</div></span><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/algorithm:624:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/initializer_list:47:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/cstddef:43:</div><div class="">/path/to/build_cmake/stage1/bin/../include/c++/v1/stddef.h:46:15: fatal error: cyclic dependency in module 'Darwin': Darwin -> std -> Darwin</div><div class="">#include_next <stddef.h></div><div class="">             <span class=""> </span>^</div><div class="">While building module 'Darwin' imported from /usr/include/assert.h:42:</div><div class="">In file included from <module-includes>:80:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../lib/clang/3.8.0/include/tgmath.h:29:</div><div class="">/path/to/build_cmake/stage1/bin/../include/c++/v1/math.h:309:10: fatal error: could not build module 'std'</div><div class="">#include <type_traits></div><div class=""> ~~~~~~~~^</div><div class="">In file included from modules.cpp:2:</div><div class="">In file included from /path/to/build_cmake/stage1/bin/../include/c++/v1/cassert:21:</div><div class="">/usr/include/assert.h:42:10: fatal error: could not build module 'Darwin'</div><div class="">#include <sys/cdefs.h></div><div class=""> ~~~~~~~~^</div><div class="">3 errors generated.</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Looks like the system headers are being interposed.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></font></span><div class=""><div class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class=""><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Once this works, I’d like to to set up a green dragon bot that builds clang with LLVM_ENABLE_MODULES to catch similar problems earlier.<br class=""><br class="">-- adrian<br class=""><div class=""><div class=""><br class="">> On Oct 8, 2015, at 1:36 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class="">><br class="">> Author: rsmith<br class="">> Date: Thu Oct  8 15:36:30 2015<br class="">> New Revision: 249738<br class="">><br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project?rev=249738&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=249738&view=rev</a><br class="">> Log:<br class="">> Split <ctype.h> out of <cctype>.<br class="">><br class="">> Added:<br class="">>    libcxx/trunk/include/ctype.h<br class="">>      - copied, changed from r249736, libcxx/trunk/include/cctype<br class="">> Modified:<br class="">>    libcxx/trunk/include/cctype<br class="">>    libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp<br class="">><br class="">> Modified: libcxx/trunk/include/cctype<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cctype?rev=249738&r1=249737&r2=249738&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cctype?rev=249738&r1=249737&r2=249738&view=diff</a><br class="">> ==============================================================================<br class="">> --- libcxx/trunk/include/cctype (original)<br class="">> +++ libcxx/trunk/include/cctype Thu Oct  8 15:36:30 2015<br class="">> @@ -37,10 +37,6 @@ int toupper(int c);<br class="">><br class="">> #include <__config><br class="">> #include <ctype.h><br class="">> -#if defined(_LIBCPP_MSVCRT)<br class="">> -#include "support/win32/support.h"<br class="">> -#include "support/win32/locale_win32.h"<br class="">> -#endif // _LIBCPP_MSVCRT<br class="">><br class="">> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)<br class="">> #pragma GCC system_header<br class="">> @@ -48,33 +44,19 @@ int toupper(int c);<br class="">><br class="">> _LIBCPP_BEGIN_NAMESPACE_STD<br class="">><br class="">> -#undef isalnum<br class="">> using ::isalnum;<br class="">> -#undef isalpha<br class="">> using ::isalpha;<br class="">> -#undef isblank<br class="">> using ::isblank;<br class="">> -#undef iscntrl<br class="">> using ::iscntrl;<br class="">> -#undef isdigit<br class="">> using ::isdigit;<br class="">> -#undef isgraph<br class="">> using ::isgraph;<br class="">> -#undef islower<br class="">> using ::islower;<br class="">> -#undef isprint<br class="">> using ::isprint;<br class="">> -#undef ispunct<br class="">> using ::ispunct;<br class="">> -#undef isspace<br class="">> using ::isspace;<br class="">> -#undef isupper<br class="">> using ::isupper;<br class="">> -#undef isxdigit<br class="">> using ::isxdigit;<br class="">> -#undef tolower<br class="">> using ::tolower;<br class="">> -#undef toupper<br class="">> using ::toupper;<br class="">><br class="">> _LIBCPP_END_NAMESPACE_STD<br class="">><br class="">> Copied: libcxx/trunk/include/ctype.h (from r249736, libcxx/trunk/include/cctype)<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?p2=libcxx/trunk/include/ctype.h&p1=libcxx/trunk/include/cctype&r1=249736&r2=249738&rev=249738&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ctype.h?p2=libcxx/trunk/include/ctype.h&p1=libcxx/trunk/include/cctype&r1=249736&r2=249738&rev=249738&view=diff</a><br class="">> ==============================================================================<br class="">> --- libcxx/trunk/include/cctype (original)<br class="">> +++ libcxx/trunk/include/ctype.h Thu Oct  8 15:36:30 2015<br class="">> @@ -1,5 +1,5 @@<br class="">> // -*- C++ -*-<br class="">> -//===---------------------------- cctype ----------------------------------===//<br class="">> +//===---------------------------- ctype.h ---------------------------------===//<br class="">> //<br class="">> //                     The LLVM Compiler Infrastructure<br class="">> //<br class="">> @@ -8,14 +8,11 @@<br class="">> //<br class="">> //===----------------------------------------------------------------------===//<br class="">><br class="">> -#ifndef _LIBCPP_CCTYPE<br class="">> -#define _LIBCPP_CCTYPE<br class="">> +#ifndef _LIBCPP_CTYPE_H<br class="">> +#define _LIBCPP_CTYPE_H<br class="">><br class="">> /*<br class="">> -    cctype synopsis<br class="">> -<br class="">> -namespace std<br class="">> -{<br class="">> +    ctype.h synopsis<br class="">><br class="">> int isalnum(int c);<br class="">> int isalpha(int c);<br class="">> @@ -31,52 +28,41 @@ int isupper(int c);<br class="">> int isxdigit(int c);<br class="">> int tolower(int c);<br class="">> int toupper(int c);<br class="">> -<br class="">> -}  // std<br class="">> */<br class="">><br class="">> #include <__config><br class="">> -#include <ctype.h><br class="">> -#if defined(_LIBCPP_MSVCRT)<br class="">> -#include "support/win32/support.h"<br class="">> -#include "support/win32/locale_win32.h"<br class="">> -#endif // _LIBCPP_MSVCRT<br class="">> +#include_next <ctype.h><br class="">><br class="">> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)<br class="">> #pragma GCC system_header<br class="">> #endif<br class="">><br class="">> -_LIBCPP_BEGIN_NAMESPACE_STD<br class="">> +#ifdef __cplusplus<br class="">> +<br class="">> +#if defined(_LIBCPP_MSVCRT)<br class="">> +// We support including .h headers inside 'extern "C"' contexts, so switch<br class="">> +// back to C++ linkage before including these C++ headers.<br class="">> +extern "C++" {<br class="">> +  #include "support/win32/support.h"<br class="">> +  #include "support/win32/locale_win32.h"<br class="">> +}<br class="">> +#endif // _LIBCPP_MSVCRT<br class="">><br class="">> #undef isalnum<br class="">> -using ::isalnum;<br class="">> #undef isalpha<br class="">> -using ::isalpha;<br class="">> #undef isblank<br class="">> -using ::isblank;<br class="">> #undef iscntrl<br class="">> -using ::iscntrl;<br class="">> #undef isdigit<br class="">> -using ::isdigit;<br class="">> #undef isgraph<br class="">> -using ::isgraph;<br class="">> #undef islower<br class="">> -using ::islower;<br class="">> #undef isprint<br class="">> -using ::isprint;<br class="">> #undef ispunct<br class="">> -using ::ispunct;<br class="">> #undef isspace<br class="">> -using ::isspace;<br class="">> #undef isupper<br class="">> -using ::isupper;<br class="">> #undef isxdigit<br class="">> -using ::isxdigit;<br class="">> #undef tolower<br class="">> -using ::tolower;<br class="">> #undef toupper<br class="">> -using ::toupper;<br class="">><br class="">> -_LIBCPP_END_NAMESPACE_STD<br class="">> +#endif<br class="">><br class="">> -#endif  // _LIBCPP_CCTYPE<br class="">> +#endif  // _LIBCPP_CTYPE_H<br class="">><br class="">> Modified: libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp<br class="">> URL:<span class=""> </span><a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=249738&r1=249737&r2=249738&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=249738&r1=249737&r2=249738&view=diff</a><br class="">> ==============================================================================<br class="">> --- libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp (original)<br class="">> +++ libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp Thu Oct  8 15:36:30 2015<br class="">> @@ -86,18 +86,18 @@ int main()<br class="">>     static_assert((std::is_same<decltype(std::tolower(0)), int>::value), "");<br class="">>     static_assert((std::is_same<decltype(std::toupper(0)), int>::value), "");<br class="">><br class="">> -    assert(isalnum('a'));<br class="">> -    assert(isalpha('a'));<br class="">> -    assert(isblank(' '));<br class="">> -    assert(!iscntrl(' '));<br class="">> -    assert(!isdigit('a'));<br class="">> -    assert(isgraph('a'));<br class="">> -    assert(islower('a'));<br class="">> -    assert(isprint('a'));<br class="">> -    assert(!ispunct('a'));<br class="">> -    assert(!isspace('a'));<br class="">> -    assert(!isupper('a'));<br class="">> -    assert(isxdigit('a'));<br class="">> -    assert(tolower('A') == 'a');<br class="">> -    assert(toupper('a') == 'A');<br class="">> +    assert(std::isalnum('a'));<br class="">> +    assert(std::isalpha('a'));<br class="">> +    assert(std::isblank(' '));<br class="">> +    assert(!std::iscntrl(' '));<br class="">> +    assert(!std::isdigit('a'));<br class="">> +    assert(std::isgraph('a'));<br class="">> +    assert(std::islower('a'));<br class="">> +    assert(std::isprint('a'));<br class="">> +    assert(!std::ispunct('a'));<br class="">> +    assert(!std::isspace('a'));<br class="">> +    assert(!std::isupper('a'));<br class="">> +    assert(std::isxdigit('a'));<br class="">> +    assert(std::tolower('A') == 'a');<br class="">> +    assert(std::toupper('a') == 'A');<br class="">> }<br class="">><br class="">><br class="">> _______________________________________________<br class="">> cfe-commits mailing list<br class="">><span class=""> </span><a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class="">><span class=""> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class=""></div></div></blockquote></div></div></div><br class=""></div></div><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a></blockquote></div></div></div></div></div></blockquote></div></div></div></div></div></blockquote></div></div></div></div></div></blockquote></div></div></div></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">cfe-commits mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><a href="mailto:cfe-commits@lists.llvm.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" class="">cfe-commits@lists.llvm.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a></div></blockquote></div></div></div><br class=""></div><br class="">_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>