Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build boost library to emscripten #22767

Open
juanlanuzag opened this issue Oct 18, 2024 · 2 comments
Open

Build boost library to emscripten #22767

juanlanuzag opened this issue Oct 18, 2024 · 2 comments

Comments

@juanlanuzag
Copy link

juanlanuzag commented Oct 18, 2024

Hello, I am trying to port an existing program to wasm and this program uses boost program options.
I downloaded and boostrapped boost and I'm running
`
./b2 toolset=emscripten link=static threading=multi --with-program_options

I am getting the following warning for multiple files

emcc: warning: .bc output file suffix used without -flto or -emit-llvm.  Consider using .o extension since emcc will output an object file, not a bitcode file [-Wemcc]
emscripten.compile.c++ bin.v2/libs/program_options/build/emscripten-3.1.69/release/link-static/threading-multi/visibility-hidden/split.bc

and the following error

emscripten.archive bin.v2/libs/program_options/build/emscripten-3.1.69/release/link-static/threading-multi/visibility-hidden/libboost_program_options.bc
bin.v2/libs/program_options/build/emscripten-3.1.69/release/link-static/threading-multi/visibility-hidden/cmdline.bc:1:2: error: expected top-level entity
    1 | <U+0000>asm<U+0001><U+0000><U+0000><U+0000><U+0001>ƀ<80><80><U+0000><U+000B>`

Any idea what is this issue? Is my approach correct?

Version of emscripten/emsdk:

emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.69 (c55ff404dbe1eb9f263c48b584d5ba627224763a)
clang version 20.0.0git (https:/github.com/llvm/llvm-project 50866e84d1da8462aeb96607bf6d9e5bbd5869c5)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/myuser/emsdk/upstream/bin
@sbc100
Copy link
Collaborator

sbc100 commented Oct 18, 2024

Looks like the build system needs to be updated to switch from .bc to .o for the object file extension.

@manin
Copy link

manin commented Nov 12, 2024

You'll have to update "tools/build/src/tools/emscripten.jam". This is the diff for the boost version i'm using (1.79.0)

--- a/tools/build/src/tools/emscripten.jam
+++ b/tools/build/src/tools/emscripten.jam
@@ -6,6 +6,7 @@
 import feature ;
 import os ;
 import toolset ;
+import generators ;
 import common ;
 import gcc ;
 import type ;
@@ -49,10 +50,11 @@ toolset.inherit-flags emscripten : gcc
         <debug-symbols>off <debug-symbols>on
         <rtti>off <rtti>on
         ;
-
+generators.override builtin.lib-generator : emscripten.prebuilt ;
+generators.override emscripten.searched-lib-generator : searched-lib-generator ;
 type.set-generated-target-suffix EXE : <toolset>emscripten : "js" ;
-type.set-generated-target-suffix OBJ : <toolset>emscripten : "bc" ;
-type.set-generated-target-suffix STATIC_LIB : <toolset>emscripten : "bc" ;
+type.set-generated-target-suffix OBJ : <toolset>emscripten : "o" ;
+type.set-generated-target-suffix STATIC_LIB : <toolset>emscripten : "a" ;
 
 toolset.flags emscripten.compile OPTIONS <flags> ;
 toolset.flags emscripten.compile OPTIONS <cflags> ;
@@ -94,7 +96,7 @@ actions compile.c++
 
 actions archive
 {
-    "$(CONFIG_COMMAND)" $(AROPTIONS) -r -o "$(<)" "$(>)"
+    emar -r $(AROPTIONS) "$(<)" "$(>)"
 }
 
 toolset.flags emscripten.link USER_OPTIONS <linkflags> ;

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

No branches or pull requests

3 participants