Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Fix build wasm in latest emsdk #1227

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vaaaaanquish
Copy link

Overview

Fix: #1166

Execution

In local OSX.

$ docker pull emscripten/emsdk
$ docker run -it emscripten/emsdk bash

In Container.

$ em++ --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.30 (f782b50a7f8dded7cd0e2c7ee4fed41ab743f5c0)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# --- checkout this PR ---
$ git clone https://github.com/vaaaaanquish/fastText.git
$ git checkout patch-build-wasm
$ make wasm
...
$ ls webassembly/
README.md  doc  fasttext.js  fasttext_wasm.cc  fasttext_wasm.js  fasttext_wasm.wasm

@facebook-github-bot
Copy link
Contributor

Hi @vaaaaanquish!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@vaaaaanquish
Copy link
Author

CLA signed

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@searleser97
Copy link

This change didn't work on v2.0.31 of emscripten

@vaaaaanquish
Copy link
Author

This change didn't work on v2.0.31 of emscripten
I will check...😅

@fgma
Copy link

fgma commented Dec 15, 2022

This works against latest emscripten release using the image from dockerhub to build fasttext:

--- a/Makefile
+++ b/Makefile
@@ -73,7 +73,9 @@ clean:
 
 
 EMCXX = em++
-EMCXXFLAGS = --bind --std=c++11 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPostRun', 'FS']" -s "DISABLE_EXCEPTION_CATCHING=0" -s "EXCEPTION_DEBUG=1" -s "FORCE_FILESYSTEM=1" -s "MODULARIZE=1" -s "EXPORT_ES6=1" -s 'EXPORT_NAME="FastTextModule"' -Isrc/
+EMCXXFLAGS_BASE = --bind --std=c++11 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s "EXPORTED_RUNTIME_METHODS=['addOnPostRun', 'FS']" -s "DISABLE_EXCEPTION_CATCHING=0" -s "EXCEPTION_DEBUG=1" -s "FORCE_FILESYSTEM=1" -s "MODULARIZE=1" -s "EXPORT_ES6=1" -s 'EXPORT_NAME="FastTextModule"' -Isrc/
+EMCXXFLAGS = $(EMCXXFLAGS_BASE) -r
+EMCXXFLAGS_JS = $(EMCXXFLAGS_BASE)
 EMOBJS = args.bc autotune.bc matrix.bc dictionary.bc loss.bc productquantizer.bc densematrix.bc quantmatrix.bc vector.bc model.bc utils.bc meter.bc fasttext.bc main.bc
 
 
@@ -120,6 +122,6 @@ fasttext.bc: src/fasttext.cc src/*.h
        $(EMCXX) $(EMCXXFLAGS)  src/fasttext.cc -o fasttext.bc
 
 webassembly/fasttext_wasm.js: $(EMOBJS) webassembly/fasttext_wasm.cc Makefile
-       $(EMCXX) $(EMCXXFLAGS) $(EMOBJS) -o webassembly/fasttext_wasm.js
+       $(EMCXX) $(EMCXXFLAGS_JS) $(EMOBJS) -o webassembly/fasttext_wasm.js

This will build without any warnings. Please update this PR and get it merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't make wasm
4 participants