google / gemma.cpp

lightweight, standalone C++ inference engine for Google's Gemma models.
Apache License 2.0
5.93k stars 502 forks source link

Compiling under mingw with clang error.. #193

Closed 0wwafa closed 2 months ago

0wwafa commented 4 months ago
~/gemma.cpp$ cmake --build build -j 4
[79/81] Linking CXX executable benchmark.exe
FAILED: benchmark.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\clang64\bin\clang++.exe -O3 -DNDEBUG  CMakeFiles/b
enchmark.dir/benchmark.cc.obj -o benchmark.exe -Wl,--out-implib,libbenchmark.dll.a -Wl,--major-image
-version,0,--minor-image-version,0  libgemma.a  _deps/highway-build/libhwy.a  _deps/highway-build/li
bhwy_contrib.a  _deps/highway-build/libhwy.a  _deps/sentencepiece-build/src/libsentencepiece.a  -lpt
hread  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvap
i32 && cd ."
ld.lld: error: undefined symbol: WakeByAddressAll
>>> referenced by CMakeFiles/benchmark.dir/benchmark.cc.obj:(main)
>>> referenced by CMakeFiles/benchmark.dir/benchmark.cc.obj:(hwy::ThreadPool::~ThreadPool())
>>> referenced by libgemma.a(gemma.cc.obj):(gcpp::GenerateGemma(gcpp::Gemma&, unsigned long long, un
signed long long, float, std::__1::vector<int, std::__1::allocator<int>> const&, unsigned long long,
 gcpp::KVCache&, hwy::ThreadPool&, hwy::ThreadPool&, std::__1::function<bool (int, float)> const&, s
td::__1::function<bool (int)> const&, std::__1::mersenne_twister_engine<unsigned int, 32ull, 624ull,
 397ull, 31ull, 2567483615u, 11ull, 4294967295u, 7ull, 2636928640u, 15ull, 4022730752u, 18ull, 18124
33253u>&, int))
>>> referenced 230 more times

ld.lld: error: undefined symbol: WaitOnAddress
>>> referenced by CMakeFiles/benchmark.dir/benchmark.cc.obj:(hwy::BlockUntilDifferent(unsigned int,
std::__1::atomic<unsigned int>&))
>>> referenced by libgemma.a(gemma.cc.obj):(hwy::BlockUntilDifferent(unsigned int, std::__1::atomic<
unsigned int>&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[80/81] Linking CXX executable compress_weights.exe
FAILED: compress_weights.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\clang64\bin\clang++.exe -O3 -DNDEBUG  CMakeFiles/c
ompress_weights.dir/compress_weights.cc.obj -o compress_weights.exe -Wl,--out-implib,libcompress_wei
ghts.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libgemma.a  _deps/highway-build/libh
wy.a  _deps/highway-build/libhwy_contrib.a  _deps/highway-build/libhwy.a  _deps/sentencepiece-build/
src/libsentencepiece.a  -lpthread  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut
32 -luuid -lcomdlg32 -ladvapi32 && cd ."
ld.lld: error: undefined symbol: WakeByAddressAll
>>> referenced by CMakeFiles/compress_weights.dir/compress_weights.cc.obj:(hwy::ThreadPool::~ThreadP
ool())
>>> referenced by libgemma.a(gemma.cc.obj):(gcpp::GenerateGemma(gcpp::Gemma&, unsigned long long, un
signed long long, float, std::__1::vector<int, std::__1::allocator<int>> const&, unsigned long long,
 gcpp::KVCache&, hwy::ThreadPool&, hwy::ThreadPool&, std::__1::function<bool (int, float)> const&, s
td::__1::function<bool (int)> const&, std::__1::mersenne_twister_engine<unsigned int, 32ull, 624ull,
 397ull, 31ull, 2567483615u, 11ull, 4294967295u, 7ull, 2636928640u, 15ull, 4022730752u, 18ull, 18124
33253u>&, int))
>>> referenced by libgemma.a(gemma.cc.obj):(gcpp::GenerateGemma(gcpp::Gemma&, unsigned long long, un
signed long long, float, std::__1::vector<int, std::__1::allocator<int>> const&, unsigned long long,
 gcpp::KVCache&, hwy::ThreadPool&, hwy::ThreadPool&, std::__1::function<bool (int, float)> const&, s
td::__1::function<bool (int)> const&, std::__1::mersenne_twister_engine<unsigned int, 32ull, 624ull,
 397ull, 31ull, 2567483615u, 11ull, 4294967295u, 7ull, 2636928640u, 15ull, 4022730752u, 18ull, 18124
33253u>&, int))
>>> referenced 229 more times

ld.lld: error: undefined symbol: WaitOnAddress
>>> referenced by CMakeFiles/compress_weights.dir/compress_weights.cc.obj:(hwy::BlockUntilDifferent(
unsigned int, std::__1::atomic<unsigned int>&))
>>> referenced by libgemma.a(gemma.cc.obj):(hwy::BlockUntilDifferent(unsigned int, std::__1::atomic<
unsigned int>&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[81/81] Linking CXX executable gemma.exe
FAILED: gemma.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\clang64\bin\clang++.exe -O3 -DNDEBUG  CMakeFiles/g
emma.dir/run.cc.obj -o gemma.exe -Wl,--out-implib,libgemma.dll.a -Wl,--major-image-version,0,--minor
-image-version,0  libgemma.a  _deps/highway-build/libhwy.a  _deps/highway-build/libhwy_contrib.a  _d
eps/highway-build/libhwy.a  _deps/sentencepiece-build/src/libsentencepiece.a  -lpthread  -lkernel32
-luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
ld.lld: error: undefined symbol: WakeByAddressAll
>>> referenced by CMakeFiles/gemma.dir/run.cc.obj:(gcpp::Run(gcpp::LoaderArgs&, gcpp::InferenceArgs&
, gcpp::AppArgs&))
>>> referenced by CMakeFiles/gemma.dir/run.cc.obj:(hwy::ThreadPool::~ThreadPool())
>>> referenced by libgemma.a(gemma.cc.obj):(gcpp::GenerateGemma(gcpp::Gemma&, unsigned long long, un
signed long long, float, std::__1::vector<int, std::__1::allocator<int>> const&, unsigned long long,
 gcpp::KVCache&, hwy::ThreadPool&, hwy::ThreadPool&, std::__1::function<bool (int, float)> const&, s
td::__1::function<bool (int)> const&, std::__1::mersenne_twister_engine<unsigned int, 32ull, 624ull,
 397ull, 31ull, 2567483615u, 11ull, 4294967295u, 7ull, 2636928640u, 15ull, 4022730752u, 18ull, 18124
33253u>&, int))
>>> referenced 230 more times

ld.lld: error: undefined symbol: WaitOnAddress
>>> referenced by CMakeFiles/gemma.dir/run.cc.obj:(hwy::BlockUntilDifferent(unsigned int, std::__1::
atomic<unsigned int>&))
>>> referenced by libgemma.a(gemma.cc.obj):(hwy::BlockUntilDifferent(unsigned int, std::__1::atomic<
unsigned int>&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
jan-wassenberg commented 4 months ago

Hi, thanks for reaching out. When building on Windows, we require the Futex APIs added in Windows Server 2012 / Windows 8. You can work around this by defining HWY_DISABLE_FUTEX, then also building with C++20 enabled, or also defining HWY_FUTEX_SLEEP, but performance may be poor in the latter case. Hope this helps!

0wwafa commented 4 months ago

So? I should build it on linux?

jan-wassenberg commented 4 months ago

Linux is also a good option, that's our main platform :)

KumarGitesh2024 commented 3 months ago

Hi @0wwafa Could you please confirm, if you are able to build it on linux platform?

0wwafa commented 3 months ago

Hi @0wwafa Could you please confirm, if you are able to build it on linux platform?

When I have time I'll check it on google colab. That's one of the best benchmark since it's a very small machine and CPU only :D

jan-wassenberg commented 2 months ago

Closing for now, please reopen if there's any issue on Colab :)