browsermt / bergamot-translator

Cross platform C++ library focusing on optimized machine translation on the consumer-grade device.
http://browser.mt
Mozilla Public License 2.0
327 stars 36 forks source link

Build native fix, line 87 on CMakeList.txt #469

Open CristobalRR opened 6 months ago

CristobalRR commented 6 months ago

For the native build, Marian demand to be compiled with BLAS and CBLAS on the system, other wise it always will dump this error during run time: ... Error: Marian must be compiled with a BLAS library Error: Aborted from void sgemm(bool, b.... ... Aborted (core dumped) build-native/app/bergamot --log-level debug ...

so to make marian locate BLAS and CBLAS succesfuly, i had to check the CMakeList.txt, it took me a while to realize that SET(USE_STATIC_LIBS ON CACHE BOOL "Link statically against non-system libs") was blocking marian but after commenting the line it run nice.

this test was done under debian and arch on wsl, i doubt it was a wsl only error. if im not the only one suffering from this bug i propose to move this line to the: if (USE_WASM_COMPATIBLE_SOURCE) on line 89 if it is needed for the wasm build.

XapaJIaMnu commented 5 months ago

So, historically we ship static builds because it makes it easier to distribute among machines when working on clusters, and when compiling and shipping as a binary to an end user. Obviously it's not necessary when running on one's own machine but nevertheless here we are.

Your problem is that the distros you mention did not ship static version of the cblas (I'm pretty sure for arch I got it to work using openblas).

I don't think I want to change the default behaviour because someone may rely on it but you don't need to change any code, just when configuring do:

cmake .. -DUSE_STATIC_LIBS=OFF

Hope that helps. Perhaps adding this in the readme is a good idea.