ggerganov / llama.cpp

LLM inference in C/C++
MIT License
67.28k stars 9.67k forks source link

Bug: Compilation failure swift build on Windows #8739

Closed bdashore3 closed 1 month ago

bdashore3 commented 3 months ago

What happened?

I'm trying to build the Swift package of llama.cpp on Windows using Swift 5.10. However, the build fails with errors stating that some return types are part of a C++ 14 extension. I decided to switch the cxx standard in Package.swift to C++ 14, which yielded a different set of errors in the logs field.

I expected the build to succeed with no issues so I can continue building my application.

I'm not too familiar with C++ build tooling, so I'd appreciate the help and would be happy to provide more verbose logs if needed.

System info:

Name and Version

Commit 4730fac

What operating system are you seeing the problem on?

Windows

Relevant log output

MARK: With c++ 11 standard:
Building for debugging...
In file included from D:\swift-executable\.build\checkouts\llama.cpp\src\unicode.cpp:5:
In file included from D:\swift-executable\.build\checkouts\llama.cpp\src/unicode.h:4:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\string:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xstring:14:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xmemory:15:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:11:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\__msvc_iter_core.hpp:10:
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\utility:162:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
_NODISCARD constexpr auto&& _Tuple_get(tuple<_Types...>&& _Tuple) noexcept;
                     ^
In file included from D:\swift-executable\.build\checkouts\llama.cpp\src\unicode.cpp:5:
In file included from D:\swift-executable\.build\checkouts\llama.cpp\src/unicode.h:4:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\string:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xstring:14:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xmemory:15:
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:544:15: error: deduced return types are a C++14 extension
    constexpr decltype(auto) operator()(_Args&&... _Vals) { // forward function call operator
              ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:556:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
_NODISCARD constexpr auto _Pass_fn(_Fn& _Func) noexcept {
                     ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1152:16: error: constexpr function's return type 'void' is not a literal type
constexpr void _Adl_verify_range(const _Iter& _First, const _Sentinel& _Last) {
               ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1174:22: error: deduced return types are a C++14 extension
_NODISCARD constexpr decltype(auto) _Get_unwrapped(_Iter&& _It) noexcept(
                     ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1202:22: error: deduced return types are a C++14 extension
_NODISCARD constexpr decltype(auto) _Get_unwrapped_unverified(_Iter&& _It) {
                     ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1241:22: error: deduced return types are a C++14 extension
_NODISCARD constexpr decltype(auto) _Get_unwrapped_n(_Iter&& _It, const _Diff _Off) {
                     ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1275:16: error: constexpr function's return type 'void' is not a literal type
constexpr void _Seek_wrapped(_Iter& _It, _UIter&& _UIt) {
               ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1336:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
_NODISCARD constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) {
                     ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1341:16: error: no viable conversion from returned value of type '_Distance_unknown' to function return type 'int'
        return _Distance_unknown{};
               ^~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1637:27: error: constexpr function's return type 'void' is not a literal type
    friend constexpr void _Verify_range(
                          ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1643:20: error: constexpr function's return type 'void' is not a literal type
    constexpr void _Verify_offset(const difference_type _Off) const noexcept {
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:1662:20: error: constexpr function's return type 'void' is not a literal type
    constexpr void _Seek_to(const reverse_iterator<_Src>& _It) noexcept(noexcept(current._Seek_to(_It.current))) {
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4094:18: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
    _CONSTEXPR17 auto operator++(int) noexcept(
                 ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4198:27: error: constexpr function's return type 'void' is not a literal type
    friend constexpr void _Verify_range(const move_iterator& _First, const move_iterator<_Iter2>& _Last) noexcept {
                          ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4211:20: error: constexpr function's return type 'void' is not a literal type
    constexpr void _Verify_offset(const difference_type _Off) const noexcept {
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4229:20: error: constexpr function's return type 'void' is not a literal type
    constexpr void _Seek_to(const move_iterator<_Src>& _It) noexcept(noexcept(_Current._Seek_to(_It._Get_current()))) {
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4233:20: error: constexpr function's return type 'void' is not a literal type
    constexpr void _Seek_to(move_iterator<_Src>&& _It) noexcept(
                   ^
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\xutility:4391:22: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
_NODISCARD constexpr auto _To_address(const _Iter& _Val) noexcept {
                     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
[0/27] Compiling llama src\unicode.cpp

MARK: With c++ 14 standard:

Function has token parameter but isn't an intrinsic
  %targetBlock4953 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.8"(ptr %_Myend4.i.i.i.i634, ptr %260, token %259, ptr %cpts.i.i) #34, !dbg !23113
Function has token parameter but isn't an intrinsic
  %targetBlock4951 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.7"(ptr %_Myend.i.i.i.i, ptr %263, token %262, ptr %ref.tmp.i) #34, !dbg !23136
Function has token parameter but isn't an intrinsic
  %targetBlock4957 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.10"(ptr %_Myend4.i.i.i92.i, ptr %562, token %561, ptr %cpts.i71.i) #34, !dbg !24686
Function has token parameter but isn't an intrinsic
  %targetBlock4955 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.9"(ptr %_Myend.i.i.i77.i, ptr %565, token %564, ptr %ref.tmp9.i) #34, !dbg !24698
Function has token parameter but isn't an intrinsic
  %targetBlock4949 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.6"(ptr %match.i.sroa.15.3, ptr %match.i.sroa.52338.3, token %686) #34, !dbg !25889
Function has token parameter but isn't an intrinsic
  %targetBlock4947 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.5"(ptr %_Myend4.i.i.i.i199.i, ptr %698, token %697, ptr %_Matches.i.i.i) #34, !dbg !26024
Function has token parameter but isn't an intrinsic
  %targetBlock4945 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.4"(ptr %_Myend.i.i.i, ptr %701, token %700, ptr %ref.tmp343) #34, !dbg !26040
Function has token parameter but isn't an intrinsic
  %targetBlock4943 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.3"(ptr %match.i1094.sroa.15.3, ptr %match.i1094.sroa.52352.3, token %905) #34, !dbg !27978
Function has token parameter but isn't an intrinsic
  %targetBlock4941 = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.2"(ptr %_Myend4.i.i.i.i203.i, ptr %917, token %916, ptr %_Matches.i.i.i1117) #34, !dbg !28072
Function has token parameter but isn't an intrinsic
  %targetBlock = call i1 @"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z.cold.1"(ptr %_Myend.i.i.i1101, ptr %920, token %919, ptr %ref.tmp389) #34, !dbg !28088
in function ?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z
fatal error: error in backend: Broken function found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\\Users\\kingbri\\AppData\\Local\\Programs\\Swift\\Toolchains\\5.10.1+Asserts\\usr\\bin\\clang.exe -target x86_64-unknown-windows-msvc -O0 -DSWIFT_PACKAGE=1 -DDEBUG=1 -fblocks -I D:\\swift-executable\\.build\\checkouts\\llama.cpp\\spm-headers -Wno-shorten-64-to-32 -O3 -DNDEBUG -fno-objc-arc -fvectorize -ffp-model=fast -fno-finite-math-only -D_MT -D_DLL -Xclang --dependent-lib=msvcrt -gdwarf -gdwarf -MD -MT dependencies -MF D:\\swift-executable\\.build\\x86_64-unknown-windows-msvc\\debug\\llama.build\\src\\unicode.cpp.d -std=gnu++20 -c D:\\swift-executable\\.build\\checkouts\\llama.cpp\\src\\unicode.cpp -o D:\\swift-executable\\.build\\x86_64-unknown-windows-msvc\\debug\\llama.build\\src\\unicode.cpp.o
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'D:\swift-executable\.build\checkouts\llama.cpp\src\unicode.cpp'.
4.      Running pass 'Module Verifier' on function '@"?unicode_regex_split@@YA?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@AEBV12@@Z"'
Exception Code: 0xE0000046
 #0 0x00007fff4e63f39c (C:\WINDOWS\System32\KERNELBASE.dll+0x5f39c)
 #1 0x00007ff78ba6316a (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x16e316a)
 #2 0x00007ff78ba66a33 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x16e6a33)
 #3 0x00007ff78a405c70 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x85c70)
 #4 0x00007ff78ba37356 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x16b7356)
 #5 0x00007ff78ba374f1 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x16b74f1)
 #6 0x00007ff78b4f5c20 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1175c20)
 #7 0x00007ff78b3e5689 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1065689)
 #8 0x00007ff78b3e58e0 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x10658e0)
 #9 0x00007ff78b3e5b97 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1065b97)
#10 0x00007ff78b3e5347 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1065347)
#11 0x00007ff78be3ca35 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1abca35)
#12 0x00007ff78be3bb36 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1abbb36)
#13 0x00007ff78be3c43d (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1abc43d)
#14 0x00007ff78e801aa8 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x4481aa8)
#15 0x00007ff78d364d47 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x2fe4d47)
#16 0x00007ff78c54c9e0 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x21cc9e0)
#17 0x00007ff78e80050b (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x448050b)
#18 0x00007ff78c54c7ce (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x21cc7ce)
#19 0x00007ff78c4ffa83 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x217fa83)
#20 0x00007ff78c5d2bcb (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x2252bcb)
#21 0x00007ff78a406a98 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x86a98)
#22 0x00007ff78a3fb88c (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x7b88c)
#23 0x00007ff78c3ff34a (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x207f34a)
#24 0x00007ff78ba6323f (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x16e323f)
#25 0x00007ff78c3ffa18 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x207fa18)
#26 0x00007ff78c376d91 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1ff6d91)
#27 0x00007ff78c376f40 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1ff6f40)
#28 0x00007ff78c35c790 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x1fdc790)
#29 0x00007ff78a3fe71a (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x7e71a)
#30 0x00007ff78e3fa414 (C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\clang.exe+0x407a414)
#31 0x00007fff508f257d (C:\WINDOWS\System32\KERNEL32.DLL+0x1257d)
#32 0x00007fff5126af28 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x5af28)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 16.0.0
Target: x86_64-unknown-windows-msvc
Thread model: posix
InstalledDir: C:\Users\kingbri\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: C:\Users\kingbri\AppData\Local\Temp\unicode-10fbbc.cpp
clang: note: diagnostic msg: C:\Users\kingbri\AppData\Local\Temp\unicode-10fbbc.sh
clang: note: diagnostic msg:

********************
[0/27] Compiling llama src\unicode.cpp
bdashore3 commented 3 months ago

Nevermind, it looks like I was able to fix it by finding some other examples. Specifically https://github.com/bazelbuild/rules_swift/pull/831

Made a PR in #8742

In addition, C++ 14 and higher is required for windows as older versions don't support some features that are include in llama.cpp's codebase.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 14 days since being marked as stale.