Skip to content

llvm versions we use doesn't build with the latest Xcode #4210

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

Open
yamt opened this issue Apr 24, 2025 · 2 comments · May be fixed by #4213
Open

llvm versions we use doesn't build with the latest Xcode #4210

yamt opened this issue Apr 24, 2025 · 2 comments · May be fixed by #4213

Comments

@yamt
Copy link
Collaborator

yamt commented Apr 24, 2025

llvm (lldb) versions used by wamr doen't build with latest Xcode
because Xcode dropped std:char_traits:
https://developer.apple.com/documentation/xcode-release-notes/xcode-16_3-release-notes
(search "The base template for std::char_traits has been removed" in the page)

llvm 18 and later has this fixed:
llvm/llvm-project@68744ff
llvm/llvm-project@7549cde

cd wamr-compiler
./build_llvm_xtensa.sh --project clang lldb
In file included from /Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:13:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/chrono:1002:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/vector:325:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_bool.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_integral.h:21:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_output.h:22:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/parser_std_format_spec.h:39:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:821:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
  821 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:634:34: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here
  634 |       std::basic_string<uint8_t> zeros(reg_info.byte_size, '\0');
      |                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from /Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:13:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/chrono:1001:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__type_traits/is_convertible.h:22:99: note: in instantiation of template class 'std::basic_string_view<unsigned char>' requested here
   22 | struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
      |                                                                                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:746:29: note: in instantiation of template class 'std::is_convertible<const unsigned int &, std::basic_string_view<unsigned char>>' requested here
  746 |     : public _BoolConstant< is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
      |                             ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:1162:27: note: in instantiation of template class 'std::__can_be_converted_to_string_view<unsigned char, std::char_traits<unsigned char>, unsigned int>' requested here
 1162 |             __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
      |                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:1166:42: note: while substituting prior template arguments into non-type template parameter [with _Tp = uint32_t]
 1166 |   _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1167 |       : __r_(__default_init_tag(), __a) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1168 |     __self_view __sv = __t;
      |     ~~~~~~~~~~~~~~~~~~~~~~~
 1169 |     __init(__sv.data(), __sv.size());
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1170 |   }
      |   ~
/Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:634:34: note: while substituting deduced template arguments into function template 'basic_string' [with _Tp = uint32_t, $1 = (no value)]
  634 |       std::basic_string<uint8_t> zeros(reg_info.byte_size, '\0');
      |                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from /Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:13:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/chrono:1002:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/vector:325:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_bool.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_integral.h:21:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_output.h:22:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/parser_std_format_spec.h:39:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:2392:3: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
 2392 |   traits_type::assign(std::__to_address(__p), __n, __c);
      |   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:1091:5: note: in instantiation of member function 'std::basic_string<unsigned char>::__init' requested here
 1091 |     __init(__n, __c);
      |     ^
/Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:634:34: note: in instantiation of member function 'std::basic_string<unsigned char>::basic_string' requested here
  634 |       std::basic_string<uint8_t> zeros(reg_info.byte_size, '\0');
      |                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
In file included from /Volumes/PortableSSD/llvm-xtensa/wasm-micro-runtime/core/deps/llvm/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:13:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/chrono:1002:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/vector:325:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_bool.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_integral.h:21:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/formatter_output.h:22:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__format/parser_std_format_spec.h:39:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/string:2393:3: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
 2393 |   traits_type::assign(__p[__n], value_type());
      |   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^
4 errors generated.
[2849/5061] Building CXX object tools/...ssGDBRemote.dir/ProcessGDBRemote.cpp.o
ninja: build stopped: subcommand failed.
@yamt
Copy link
Collaborator Author

yamt commented Apr 24, 2025

possible fixes:
a. bump llvm to 18 or later
b. patch llvm locally

@lum1n0us
Copy link
Collaborator

I prefer bump llvm.

yamt added a commit to yamt/wasm-micro-runtime that referenced this issue Apr 25, 2025
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue Apr 27, 2025
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue May 1, 2025
@lum1n0us lum1n0us linked a pull request May 5, 2025 that will close this issue
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue May 6, 2025
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue May 6, 2025
cf. bytecodealliance#4210

why 19, not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project
while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue May 7, 2025
cf. bytecodealliance#4210

why 19, not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project
while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.
@yamt yamt linked a pull request May 7, 2025 that will close this issue
yamt added a commit to yamt/wasm-micro-runtime that referenced this issue May 8, 2025
cf. bytecodealliance#4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.
lum1n0us pushed a commit that referenced this issue May 9, 2025
* build-scripts/build_llvm.py: bump to llvm 18

cf. #4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.

* spec-test-script/runtest.py: --size-level=0 for x86-64

with the recent version of LLVM, wamrc --size-level=1 often
generates R_X86_64_32S relocations which fail on load with
the infamous error:

"relocation truncated to fit R_X86_64_32S failed"

it seems that these relocations are often for jump tables.

this commit workarounds it with --size-level=0.

an alternative is to disable jump tables. (although it seems that
jump tables are not the only source of these relocations.)

cf. #3035

it might be better to do this in wamrc itself. however, currently
target info is not available there in case of native compilation.
related: #3356

* wamr-compiler: size_level=0 for sgx mode

cf. #3035
sjamesr pushed a commit to sjamesr/wasm-micro-runtime that referenced this issue May 13, 2025
* build-scripts/build_llvm.py: bump to llvm 18

cf. bytecodealliance#4210

why not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project

why not 19?
because of a bug in the xtensa fork of llvm:
espressif/llvm-project#112

while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.

* spec-test-script/runtest.py: --size-level=0 for x86-64

with the recent version of LLVM, wamrc --size-level=1 often
generates R_X86_64_32S relocations which fail on load with
the infamous error:

"relocation truncated to fit R_X86_64_32S failed"

it seems that these relocations are often for jump tables.

this commit workarounds it with --size-level=0.

an alternative is to disable jump tables. (although it seems that
jump tables are not the only source of these relocations.)

cf. bytecodealliance#3035

it might be better to do this in wamrc itself. however, currently
target info is not available there in case of native compilation.
related: bytecodealliance#3356

* wamr-compiler: size_level=0 for sgx mode

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

Successfully merging a pull request may close this issue.

2 participants