Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Build break in LLVM v19 #3045

Open
fs-eire opened this issue Jan 16, 2025 · 14 comments
Open

[Bug]: Build break in LLVM v19 #3045

fs-eire opened this issue Jan 16, 2025 · 14 comments

Comments

@fs-eire
Copy link

fs-eire commented Jan 16, 2025

What Operating System(s) are you seeing this problem on?

Other (plase, specify in the Steps to Reproduce)

dlib version

19.24.6

Python version

No response

Compiler

clang 19

Expected Behavior

Build pass.

Current Behavior

/sysroot/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/_deps/dlib-src/dlib/matrix/../unicode/unicode.h:718:19: note: in instantiation of template class 'std::basic_string<unsigned int>' requested here
  718 |     const ustring convert_to_utf32 (
      |                   ^
/sysroot/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;

in unicode/unicode.h, unichar is defined to uint32, and std::char_traits<unichar> is used but the template instantiation failed because LLVM libc++ v19 deprecated this behavior:

The base template for std::char_traits has been removed in LLVM 19. If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t or a custom character type for which you specialized std::char_traits, your code will stop working. The Standard does not mandate that a base template is provided, and such a base template is bound to be incorrect for some types, which could currently cause unexpected behavior while going undetected.

https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals

Simply replacing using unichar = uint32; to using unichar = char32_t; does not fix this build error because it causes other code to fail (eg serialize.h)

Steps to Reproduce

Build with Clang 19

Anything else?

No response

@arrufat
Copy link
Contributor

arrufat commented Jan 16, 2025

I've just tried to build dlib and imglab, which makes use of the Unicode stuff, with Clang 19.1.6 without issues. How are you building?

CC=clang CXX=clang++ cmake -B build -G Ninja
cmake --build build

@fs-eire
Copy link
Author

fs-eire commented Jan 17, 2025

I am using Emscripten v4.0.0 to build ONNXRuntime, while dlib is an indirect dependency.

I checked the toolset version. The LLVM binaries version is 322eb1a92e6d4266184060346616fa0dbe39e731:

The versions of compiler-rt, libcxx, libcxxabi, and libunwind is 19.1.6 according to ChangeLog.

Full build log is here.

@akulabs8
Copy link

I am new here, any help which I can provide?

@fs-eire
Copy link
Author

fs-eire commented Jan 19, 2025

If you would like to help, please follow the steps below:

  • clone onnxruntime and checkout branch fs-eire/emsdk-4.0.1
  • setup build environment
    • install Cmake >= 3.26
    • install python >= 3.9
    • install node.js >= 20
    • pip install -r requirements-dev.txt
    • pip install ninja
  • build with commandline:
    • (UNIX): ./build.sh --parallel --config Debug --build_wasm --enable_wasm_simd --enable_wasm_threads --use_extensions --cmake_extra_defines onnxruntime_WEBASSEMBLY_DEFAULT_EXTENSION_FLAGS=ON --target onnxruntime_webassembly --skip_tests
    • (Windows): build.bat --parallel --config Debug --build_wasm --enable_wasm_simd --enable_wasm_threads --use_extensions --cmake_extra_defines onnxruntime_WEBASSEMBLY_DEFAULT_EXTENSION_FLAGS=ON --target onnxruntime_webassembly --skip_tests

The DLib source will be located at build/Debug/_deps/dlib-src

You should be able to see the build error.

Please let me know if you have any questions regarding setting up environment.

@akulabs8
Copy link

@fs-eire hey thanks for the steps, I will take a look today and get back ..

@michel-mexique
Copy link

Hi ! 🙂 Getting the same issue here while trying the following with Emscripten

emcc threads/thread_pool_extension.cpp -I../ -c -o thread_pool_extension.o -s USE_PTHREADS=1 -matomics -mbulk-memory

emcc global_optimization/global_function_search.cpp -I../ -c -o global_function_search.o  -s USE_PTHREADS=1 -matomics -mbulk-memory

Which gives

/content/dlib/dlib/dlib
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:820:42: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
threads/../binary_search_tree/../unicode/unicode.h:718:19: note: in
      instantiation of template class 'std::basic_string<unsigned int>' requested here
  718 |     const ustring convert_to_utf32 (
      |                   ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:15:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/concepts.h:16:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/format_parse_context.h:16:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string_view:300:42: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
threads/../binary_search_tree/../unicode/unicode.h:727:16: note: in
      instantiation of template class 'std::basic_string_view<unsigned int>' requested here
  727 |         return temp;
      |                ^
threads/../binary_search_tree/../unicode/unicode.h:727:16: note: while
      substituting deduced template arguments into function template 'basic_string'
      [with $0 = (no value)]
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2861:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2861 |     traits_type::assign(std::__to_address(__p) + __sz, __n, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3302:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::append' requested here
 3302 |     append(__n - __sz, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
threads/../binary_search_tree/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2864:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2864 |     traits_type::assign(__p[__sz], value_type());
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2535:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2535 |     traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2556:3: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__grow_by' requested
      here
 2556 |   __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add);
      |   ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2858:7: note: 
      in instantiation of member function 'std::basic_string<unsigned
      int>::__grow_by_without_replace' requested here
 2858 |       __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
      |       ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3302:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::append' requested here
 3302 |     append(__n - __sz, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
threads/../binary_search_tree/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2538:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2538 |     traits_type::copy(
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from threads/thread_pool_extension.cpp:6:
In file included from threads/thread_pool_extension.h:8:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/thread:93:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__thread/formatter.h:18:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2221:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2221 |     traits_type::assign(__p[__newsz], value_type());
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2134:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__null_terminate_at'
      requested here
 2134 |     __null_terminate_at(std::__to_address(__get_pointer()), __pos);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3304:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__erase_to_end'
      requested here
 3304 |     __erase_to_end(__n);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
threads/../binary_search_tree/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
7 errors generated.
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:820:42: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
  820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
global_optimization/../matrix/../unicode/unicode.h:718:19: note: in
      instantiation of template class 'std::basic_string<unsigned int>' requested here
  718 |     const ustring convert_to_utf32 (
      |                   ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:16:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/concepts.h:16:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/format_parse_context.h:16:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string_view:300:42: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
global_optimization/../matrix/../unicode/unicode.h:727:16: note: in
      instantiation of template class 'std::basic_string_view<unsigned int>' requested here
  727 |         return temp;
      |                ^
global_optimization/../matrix/../unicode/unicode.h:727:16: note: while
      substituting deduced template arguments into function template 'basic_string'
      [with $0 = (no value)]
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2861:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2861 |     traits_type::assign(std::__to_address(__p) + __sz, __n, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3302:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::append' requested here
 3302 |     append(__n - __sz, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
global_optimization/../matrix/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2864:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2864 |     traits_type::assign(__p[__sz], value_type());
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2535:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2535 |     traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2556:3: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__grow_by' requested
      here
 2556 |   __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add);
      |   ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2858:7: note: 
      in instantiation of member function 'std::basic_string<unsigned
      int>::__grow_by_without_replace' requested here
 2858 |       __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
      |       ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3302:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::append' requested here
 3302 |     append(__n - __sz, __c);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
global_optimization/../matrix/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2538:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2538 |     traits_type::copy(
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from global_optimization/global_function_search.cpp:2:
In file included from global_optimization/global_function_search.h:7:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/vector:325:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_bool.h:19:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_integral.h:21:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/formatter_output.h:22:
In file included from /content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__format/parser_std_format_spec.h:39:
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2221:5: error: 
      implicit instantiation of undefined template 'std::char_traits<unsigned int>'
 2221 |     traits_type::assign(__p[__newsz], value_type());
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:2134:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__null_terminate_at'
      requested here
 2134 |     __null_terminate_at(std::__to_address(__get_pointer()), __pos);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:3304:5: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::__erase_to_end'
      requested here
 3304 |     __erase_to_end(__n);
      |     ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/string:1303:84: note: 
      in instantiation of member function 'std::basic_string<unsigned int>::resize' requested here
 1303 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__...
      |                                                                                    ^
global_optimization/../matrix/../serialize.h:1963:14: note: in instantiation of
      member function 'std::basic_string<unsigned int>::resize' requested here
 1963 |         item.resize(size);
      |              ^
/content/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1/__fwd/string.h:23:29: note: 
      template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
7 errors generated

I tried rolling back the repo to the last commit where i tried this and it worked 44689c1, but this seems to fail as well with the same errors. So I believe this issue is related to Emscripten.

@fs-eire
Copy link
Author

fs-eire commented Jan 21, 2025

I tried rolling back the repo to the last commit where i tried this and it worked 44689c1, but this seems to fail as well with the same errors.

@michel-mexique do you mean that an older version of emscripten can compile dlib successfully, or do you mean that emscripten v4.0.1 can compile an older version of dlib successfully?

@michel-mexique
Copy link

michel-mexique commented Jan 21, 2025

I failed to compile an older version of dlib (that worked before) on the latest version of emscripten so maybe try rolling back versions of emscripten ?

@fs-eire
Copy link
Author

fs-eire commented Jan 21, 2025

This is expected.

I think latest EMSDK uses newer LLVM so this is why it fails. The reason in one sentence is:

dlib uses std::char_traits<unsigned int> and this is deprecated in LLVM 19.

You can check the description of this issue for more details.

@michel-mexique
Copy link

Yes seems to be related to release of emscripten 4.0.0 on Jan 14.

Will roll back to 3.1.74. Thank you !

@michel-mexique
Copy link

Well, latest dlib compiles on emscripten 3.1.74. No idea how to fix this long term but that will do for today.

@fs-eire
Copy link
Author

fs-eire commented Jan 21, 2025

Rolling back the version to 3.1.74 is not a "fix". It is a "workaround", but unfortunately this workaround does not work for me. I need to use latest EMSDK in onnxruntime build, because version v4.0.1 contains a compiler fix that is needed in onnxruntime.

In my understanding, a correct fix should be updating the code of dlib to avoid using invalid types. According to specs, std::char_traits<unsigned int> is not one of the standard template specification. So instead of blaming the compiler, a more reasonable way is to replace the usage by a supported type (maybe std::char_traits<char32_t> in the context)

I know this may not be easy to fix and WebAssembly may be not considered as a very important usage for dlib. But eventually this need to be fixed, as future version of other compiler may deprecate it too.

@davisking
Copy link
Owner

You can probably just find/replace it to char32_t. Try that and see if it works for you (and send me a PR if it does) :)

@fs-eire
Copy link
Author

fs-eire commented Jan 27, 2025

I tried that, but as explained in the issue summary:

Simply replacing using unichar = uint32; to using unichar = char32_t; does not fix this build error because it causes other code to fail (eg serialize.h)

It is not easy as a one liner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants