Failed to build Stockfish.js with Emscripten

68 views
Skip to first unread message

laurent bernabe

unread,
Jul 11, 2019, 5:41:58 AM7/11/19
to emscripten-discuss
Hi,

I am aiming at building a custom version of StockfishJS in order to use it with React-Native.

I am using 
  • Kubuntu 19.04 64 bits
  • a recent version a Emscripten SDK (downloaded today) : not the incoming, but the standard version

So, I started to install emscripten sdk and try to build it in a standard way :
  1. I went inside src subfolder of the repository sources
  2. Launched the command 

    make build ARCH
    =wasm COMP=emscripten

    .

But it fails, the errors are joined in the output.txt.

The main error is 

shared:ERROR: '/home/laurent-bernabe/Programmes/emsdk/node/8.9.1_64bit/bin/node /home/laurent-bernabe/Programmes/emsdk/fastcomp/emscripten/src/compiler.js /tmp/tmpbZp3OW.txt /home/laurent-bernabe/Programmes/emsdk/fastcomp/ems
cripten/src/library_pthread_stub.js'
failed (1)



Thanks in advance,

Regards
output.txt
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

laurent bernabe

unread,
Jul 11, 2019, 6:02:01 AM7/11/19
to emscripten-discuss
Here are the relevant scripts of Stockfish.js project, relating to emscripten building, joined with this message.

Thanks in advance, regards
Makefile
post.js.txt
pre.js.txt
build.js.txt

Mehdi Sabwat

unread,
Jul 11, 2019, 7:13:12 AM7/11/19
to emscripten-discuss
Hi,

Not sure what you mean by "standard version" for emsdk can I see the output of ./emsdk list?

Did you correctly set your env to point to the right sdk version?

I found this https://github.com/tdlib/td/issues/612, it seems it is the same issue.

It seems it is a work in progress, https://github.com/emscripten-core/emscripten/issues/8856, there is a workaround in the issue by adding this flag
 "-s EXPORTED_FUNCTIONS=['__cxa_begin_catch']"
to your compilation line.

I hope this helps,

Regards

laurent bernabe

unread,
Jul 11, 2019, 7:33:57 AM7/11/19
to emscripten-discuss
Hi, thank you for your answer,

By standard version, I meant neither incoming nor lastest commit of emscripten

the result of
./emsdk list

is joint in the emsdk_config.txt file.

Also I'm having a look at the issue you pointed me to, and trying to solve it with either solution (addind flag -s EXPORTED_FUNCTIONS=['__cxa_begin_catch'], or testing the incoming commit  2aeae94

I'll also report the results of my tries here.
emsdk_config.txt

laurent bernabe

unread,
Jul 11, 2019, 7:47:01 AM7/11/19
to emscripten-discuss
As for adding the flag
 "-s EXPORTED_FUNCTIONS=['__cxa_begin_catch']"
to the compilation command, it did not work either.

This how I processed to add this flag: editing the Makefile file (result joint in this message) in the emscripten section for wasm (lines 293 & 294)

And I've joint the result in this message, where you can see the added flag in several lines.

The error is given as 
shared:ERROR: undefined exported function: "__cxa_begin_catch"


So I still have to experiment the other option : I mean testing with the particular commit of the incoming branch.
Makefile.txt
output.txt

Floh

unread,
Jul 11, 2019, 8:12:49 AM7/11/19
to emscripten-discuss
This is the relevant error from the attached error log:

> error: undefined symbol: __cxa_uncaught_exception


Cheers,
-Floh.

Mehdi Sabwat

unread,
Jul 11, 2019, 8:26:36 AM7/11/19
to emscripten-discuss
works with latest-upstream and removing fno-exceptions:

diff --git a/src/Makefile b/src/Makefile
index
7d4d3014..acbbd65e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -177,7 +177,7 @@ ifeq ($(STATIC),1)
        CXXFLAGS
+= -static
 endif
 
-CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++11 $(EXTRACXXFLAGS)
+CXXFLAGS += -Wall -Wcast-qual -std=c++11 $(EXTRACXXFLAGS)
 DEPENDFLAGS
+= -std=c++11
 LDFLAGS
+= $(EXTRALDFLAGS)
 



laurent bernabe

unread,
Jul 11, 2019, 8:32:03 AM7/11/19
to emscripten-discuss
Yes thank you,

for that purpose, I am downloading and installing latest versions of clang-tool and sdk incoming.
It is taking long, so I'll post results of retrying whenever installations are done.

Regards

laurent bernabe

unread,
Jul 11, 2019, 11:07:00 AM7/11/19
to emscripten-discuss
I don't understand, as emsdk does not seem to have any Makefile

Mehdi Sabwat

unread,
Jul 11, 2019, 11:09:17 AM7/11/19
to emscripte...@googlegroups.com
This is your Makefile we are talking about. The one located in stockfish.js src/

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/edb690d1-04b6-425b-983b-8225dc5c9dbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

laurent bernabe

unread,
Jul 11, 2019, 11:14:54 AM7/11/19
to emscripten-discuss
Ok thanks,

will apply modifications and try build again

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

laurent bernabe

unread,
Jul 11, 2019, 11:23:49 AM7/11/19
to emscripten-discuss
Ok, I managed to build it.

In fact I missed to apply the patch of Mehdi Sabwat some posts above

Thank you all again for your helps.

Regards
Reply all
Reply to author
Forward
0 new messages