[libcxx] r249738 - Split <ctype.h> out of <cctype>.

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 17:31:06 PDT 2015


On Tue, Oct 13, 2015 at 3:17 PM, Richard Smith via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> On Tue, Oct 13, 2015 at 2:10 PM, Adrian Prantl via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Hi Richard,
>>
>> this commit appears to break the module self-host on Darwin.
>>
>> When compiling the following program generated by clang’s own cmake
>> script:
>>
>> > #undef NDEBUG
>> > #include <cassert>
>> > #define NDEBUG
>> > #include <cassert>
>> > int main() { assert(this code is not compiled); }
>>
>> with clang++ -std=c++11 -fmodules -fcxx-modules test.cpp
>>
>
> (You don't need -fcxx-modules here.)
>
>
>> I get
>>
>> > While building module 'std' imported from /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20:
>> > While building module 'Darwin' imported from /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:39:
>> > In file included from <module-includes>:98:
>> > In file included from
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/wchar.h:92:
>> > In file included from
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/_wctype.h:57:
>
> > /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/ctype.h:33:10: fatal
>> error: cyclic dependency in module 'std': std -> Darwin -> std
>> > #include <__config>
>> >          ^
>> > While building module 'std' imported from /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20:
>> > In file included from <module-includes>:1:
>> > In file included from /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/algorithm:624:
>> > In file included from /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/initializer_list:47:
>> > /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/cstddef:39:10: fatal
>> error: could not build module 'Darwin'
>> > #include <stddef.h>
>> >  ~~~~~~~~^
>> > In file included from test.cpp:2:
>> > /Users/buildslave/adrian/
>> llvm.org/_build.ninja.release/bin/../include/c++/v1/cassert:20:10: fatal
>> error: could not build module 'std'
>> > #include <__config>
>> >  ~~~~~~~~^
>> > 3 errors generated.
>>
>> Let me know how I can help in diagnosing what’s going on here.
>>
>
> OK, I see what's wrong. Is this working any better for you in r250236?
>

We're still seeing:

While building module 'Darwin' imported from /usr/include/assert.h:42:
While building module 'std' imported from
/path/to/build_cmake/stage1/bin/../include/c++/v1/math.h:309:
In file included from <module-includes>:1:
In file included from
/path/to/build_cmake/stage1/bin/../include/c++/v1/algorithm:624:
In file included from
/path/to/build_cmake/stage1/bin/../include/c++/v1/initializer_list:47:
In file included from
/path/to/build_cmake/stage1/bin/../include/c++/v1/cstddef:43:
/path/to/build_cmake/stage1/bin/../include/c++/v1/stddef.h:46:15: fatal
error: cyclic dependency in module 'Darwin': Darwin -> std -> Darwin
#include_next <stddef.h>
              ^
While building module 'Darwin' imported from /usr/include/assert.h:42:
In file included from <module-includes>:80:
In file included from
/path/to/build_cmake/stage1/bin/../lib/clang/3.8.0/include/tgmath.h:29:
/path/to/build_cmake/stage1/bin/../include/c++/v1/math.h:309:10: fatal
error: could not build module 'std'
#include <type_traits>
 ~~~~~~~~^
In file included from modules.cpp:2:
In file included from
/path/to/build_cmake/stage1/bin/../include/c++/v1/cassert:21:
/usr/include/assert.h:42:10: fatal error: could not build module 'Darwin'
#include <sys/cdefs.h>
 ~~~~~~~~^
3 errors generated.


Looks like the system headers are being interposed.

-- Sean Silva


>
>
>> 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.
>>
>> -- adrian
>>
>> > On Oct 8, 2015, at 1:36 PM, Richard Smith via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>> >
>> > Author: rsmith
>> > Date: Thu Oct  8 15:36:30 2015
>> > New Revision: 249738
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=249738&view=rev
>> > Log:
>> > Split <ctype.h> out of <cctype>.
>> >
>> > Added:
>> >    libcxx/trunk/include/ctype.h
>> >      - copied, changed from r249736, libcxx/trunk/include/cctype
>> > Modified:
>> >    libcxx/trunk/include/cctype
>> >    libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
>> >
>> > Modified: libcxx/trunk/include/cctype
>> > URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cctype?rev=249738&r1=249737&r2=249738&view=diff
>> >
>> ==============================================================================
>> > --- libcxx/trunk/include/cctype (original)
>> > +++ libcxx/trunk/include/cctype Thu Oct  8 15:36:30 2015
>> > @@ -37,10 +37,6 @@ int toupper(int c);
>> >
>> > #include <__config>
>> > #include <ctype.h>
>> > -#if defined(_LIBCPP_MSVCRT)
>> > -#include "support/win32/support.h"
>> > -#include "support/win32/locale_win32.h"
>> > -#endif // _LIBCPP_MSVCRT
>> >
>> > #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
>> > #pragma GCC system_header
>> > @@ -48,33 +44,19 @@ int toupper(int c);
>> >
>> > _LIBCPP_BEGIN_NAMESPACE_STD
>> >
>> > -#undef isalnum
>> > using ::isalnum;
>> > -#undef isalpha
>> > using ::isalpha;
>> > -#undef isblank
>> > using ::isblank;
>> > -#undef iscntrl
>> > using ::iscntrl;
>> > -#undef isdigit
>> > using ::isdigit;
>> > -#undef isgraph
>> > using ::isgraph;
>> > -#undef islower
>> > using ::islower;
>> > -#undef isprint
>> > using ::isprint;
>> > -#undef ispunct
>> > using ::ispunct;
>> > -#undef isspace
>> > using ::isspace;
>> > -#undef isupper
>> > using ::isupper;
>> > -#undef isxdigit
>> > using ::isxdigit;
>> > -#undef tolower
>> > using ::tolower;
>> > -#undef toupper
>> > using ::toupper;
>> >
>> > _LIBCPP_END_NAMESPACE_STD
>> >
>> > Copied: libcxx/trunk/include/ctype.h (from r249736,
>> libcxx/trunk/include/cctype)
>> > URL:
>> 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
>> >
>> ==============================================================================
>> > --- libcxx/trunk/include/cctype (original)
>> > +++ libcxx/trunk/include/ctype.h Thu Oct  8 15:36:30 2015
>> > @@ -1,5 +1,5 @@
>> > // -*- C++ -*-
>> > -//===---------------------------- cctype
>> ----------------------------------===//
>> > +//===---------------------------- ctype.h
>> ---------------------------------===//
>> > //
>> > //                     The LLVM Compiler Infrastructure
>> > //
>> > @@ -8,14 +8,11 @@
>> > //
>> >
>> //===----------------------------------------------------------------------===//
>> >
>> > -#ifndef _LIBCPP_CCTYPE
>> > -#define _LIBCPP_CCTYPE
>> > +#ifndef _LIBCPP_CTYPE_H
>> > +#define _LIBCPP_CTYPE_H
>> >
>> > /*
>> > -    cctype synopsis
>> > -
>> > -namespace std
>> > -{
>> > +    ctype.h synopsis
>> >
>> > int isalnum(int c);
>> > int isalpha(int c);
>> > @@ -31,52 +28,41 @@ int isupper(int c);
>> > int isxdigit(int c);
>> > int tolower(int c);
>> > int toupper(int c);
>> > -
>> > -}  // std
>> > */
>> >
>> > #include <__config>
>> > -#include <ctype.h>
>> > -#if defined(_LIBCPP_MSVCRT)
>> > -#include "support/win32/support.h"
>> > -#include "support/win32/locale_win32.h"
>> > -#endif // _LIBCPP_MSVCRT
>> > +#include_next <ctype.h>
>> >
>> > #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
>> > #pragma GCC system_header
>> > #endif
>> >
>> > -_LIBCPP_BEGIN_NAMESPACE_STD
>> > +#ifdef __cplusplus
>> > +
>> > +#if defined(_LIBCPP_MSVCRT)
>> > +// We support including .h headers inside 'extern "C"' contexts, so
>> switch
>> > +// back to C++ linkage before including these C++ headers.
>> > +extern "C++" {
>> > +  #include "support/win32/support.h"
>> > +  #include "support/win32/locale_win32.h"
>> > +}
>> > +#endif // _LIBCPP_MSVCRT
>> >
>> > #undef isalnum
>> > -using ::isalnum;
>> > #undef isalpha
>> > -using ::isalpha;
>> > #undef isblank
>> > -using ::isblank;
>> > #undef iscntrl
>> > -using ::iscntrl;
>> > #undef isdigit
>> > -using ::isdigit;
>> > #undef isgraph
>> > -using ::isgraph;
>> > #undef islower
>> > -using ::islower;
>> > #undef isprint
>> > -using ::isprint;
>> > #undef ispunct
>> > -using ::ispunct;
>> > #undef isspace
>> > -using ::isspace;
>> > #undef isupper
>> > -using ::isupper;
>> > #undef isxdigit
>> > -using ::isxdigit;
>> > #undef tolower
>> > -using ::tolower;
>> > #undef toupper
>> > -using ::toupper;
>> >
>> > -_LIBCPP_END_NAMESPACE_STD
>> > +#endif
>> >
>> > -#endif  // _LIBCPP_CCTYPE
>> > +#endif  // _LIBCPP_CTYPE_H
>> >
>> > Modified: libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp?rev=249738&r1=249737&r2=249738&view=diff
>> >
>> ==============================================================================
>> > --- libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp (original)
>> > +++ libcxx/trunk/test/std/strings/c.strings/cctype.pass.cpp Thu Oct  8
>> 15:36:30 2015
>> > @@ -86,18 +86,18 @@ int main()
>> >     static_assert((std::is_same<decltype(std::tolower(0)),
>> int>::value), "");
>> >     static_assert((std::is_same<decltype(std::toupper(0)),
>> int>::value), "");
>> >
>> > -    assert(isalnum('a'));
>> > -    assert(isalpha('a'));
>> > -    assert(isblank(' '));
>> > -    assert(!iscntrl(' '));
>> > -    assert(!isdigit('a'));
>> > -    assert(isgraph('a'));
>> > -    assert(islower('a'));
>> > -    assert(isprint('a'));
>> > -    assert(!ispunct('a'));
>> > -    assert(!isspace('a'));
>> > -    assert(!isupper('a'));
>> > -    assert(isxdigit('a'));
>> > -    assert(tolower('A') == 'a');
>> > -    assert(toupper('a') == 'A');
>> > +    assert(std::isalnum('a'));
>> > +    assert(std::isalpha('a'));
>> > +    assert(std::isblank(' '));
>> > +    assert(!std::iscntrl(' '));
>> > +    assert(!std::isdigit('a'));
>> > +    assert(std::isgraph('a'));
>> > +    assert(std::islower('a'));
>> > +    assert(std::isprint('a'));
>> > +    assert(!std::ispunct('a'));
>> > +    assert(!std::isspace('a'));
>> > +    assert(!std::isupper('a'));
>> > +    assert(std::isxdigit('a'));
>> > +    assert(std::tolower('A') == 'a');
>> > +    assert(std::toupper('a') == 'A');
>> > }
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151013/0e0d7f67/attachment-0001.html>


More information about the cfe-commits mailing list