Issue 135529
Summary Unable to build libcxx targeting Windows with -DLIBCXX_ENABLE_LOCALIZATION=OFF
Labels libc++
Assignees
Reporter void2012
    Hi! I want to build my own libc++.a for llvm-mingw with as less bloat as possible. I want to disable RTTI, filesystem, exceptions and locale support. Building the library with disabling the former three options does work, however disabling the localization too(`-DLIBCXX_ENABLE_LOCALIZATION=OFF`) is broken because it fails to find to `__widen_from_utf8` and `__narrow_to_utf8` during the building of filesystem. Another question is why is the filesystem still being built even whenever I have explicitly disabled it? 

The error log:
```
In file included from C:/build/llvm-project/libcxx/src/filesystem/path.cpp:10:
In file included from C:/build/llvm-project/runtimes/build-i686/include/c++/v1/filesystem:543:
In file included from C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/directory_entry.h:19:
In file included from C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/filesystem_error.h:14:
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/path.h:332:11: error: no template named '__narrow_to_utf8'
  332 |   typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
      | ^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/path.h:333:11: error: no template named '__widen_from_utf8'
  333 |   typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener;
      | ^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/path.h:338:16: error: called object type '_Narrower' (aka 'int') is not a function or functio
n pointer
  338 |     _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size());
      | ~~~~~~~~~~~^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/path.h:373:11: error: no template named '__narrow_to_utf8'
  373 |   typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
      | ^
In file included from C:/build/llvm-project/libcxx/src/filesystem/path.cpp:10:
In file included from C:/build/llvm-project/runtimes/build-i686/include/c++/v1/filesystem:557:
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/u8path.h:45:16: error: no template named '__widen_from_utf8'
   45 |   using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
      | ^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/u8path.h:48:3: error: use of undeclared identifier '_CVT'
   48 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
 | ^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/u8path.h:69:16: error: no template named '__widen_from_utf8'
   69 |   using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>;
      | ^
C:/build/llvm-project/runtimes/build-i686/include/c++/v1/__filesystem/u8path.h:72:3: error: use of undeclared identifier '_CVT'
   72 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size());
 |   ^
8 errors generated.
```
Flags passed to the cmake:
```
-DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_INSTALL_PREFIX="$PREFIX/$arch-w64-mingw32" \
 -DLLVM_ENABLE_RUNTIMES="libcxxabi;libcxx" \
 -DLIBCXXABI_USE_LLVM_UNWINDER=FALSE \
    -DLIBCXX_ENABLE_FILESYSTEM=OFF \
    -DLIBCXX_ENABLE_LOCALIZATION=OFF \
 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
    -DLIBCXX_ENABLE_RTTI=OFF \
 -DLIBCXX_ENABLE_WIDE_CHARACTERS=ON\
    -DLIBCXX_HAS_PTHREAD_API=ON \
 -DLIBCXX_HAS_WIN32_THREAD_API=OFF \
    -DLIBCXX_USE_COMPILER_RT=OFF \
 -DLIBCXXABI_USE_COMPILER_RT=OFF \
    -DLIBCXXABI_HAS_PTHREAD_API=ON \
 -DLIBCXX_ENABLE_SHARED=$BUILD_SHARED \
 -DLIBCXX_ENABLE_STATIC=$BUILD_STATIC \
 -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
    -DLIBCXX_CXX_ABI=libcxxabi \
    -DLIBCXX_LIBDIR_SUFFIX="" \
    -DLIBCXX_INCLUDE_TESTS=FALSE \
 -DLIBCXX_INSTALL_MODULES=ON \
 -DLIBCXX_INSTALL_MODULES_DIR="$PREFIX/share/libc++/v1" \
 -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
    -DLIBCXXABI_ENABLE_SHARED=OFF \
    -DLIBCXXABI_LIBDIR_SUFFIX="" \
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to