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

Wasi_sdk does'nt work with Boost::filesystem #358

Open
frawamudi opened this issue Nov 3, 2023 · 4 comments
Open

Wasi_sdk does'nt work with Boost::filesystem #358

frawamudi opened this issue Nov 3, 2023 · 4 comments

Comments

@frawamudi
Copy link

Could it be because am using an older version 17 or there anything special that must be done to boost package before compiling for wasi.

Boost was built from source with the following bash script

#!/bin/sh

export WASI_SDK_PATH=/opt/wasi-sdk-17.0
export CC=${WASI_SDK_PATH}/bin/clang
export CXX=${WASI_SDK_PATH}/bin/clang++
export WASI_SYSROOT=/opt/wasi-sdk-17.0/share/wasi-sysroot

sudo ./bootstrap.sh --without-libraries=thread,atomic --with-toolset=clang threading=multi --prefix=${WASI_SYSROOT}

sudo ./b2 link=shared architecture=wasm -j4

sudo ./b2 install

this is the command i ran on the cammand line

$CXX -v -fstandalone-debug -D_WASI_EMULATED_PROCESS_CLOCKS -DBOOST_DISABLE_THREADS test.cpp -o tt.wasm -fno-exceptions -I${WASI_SDK_PATH}/share/wasi-sysroot/include/boost -L${WASI_SDK_PATH}/share/wasi-sysroot/lib -lboost_filesystem -lboost_system --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot

I get this error
wasm-ld: error: unknown file type: /opt/wasi-sdk-17.0/share/wasi-sysroot/lib/libboost_filesystem.a(operations.o)
looking at the error it seems libboost_filesystem.a built wasn;t compatable with WASI, is there any way this can be fixed?

@frawamudi frawamudi changed the title Wasi_sdk does'nt work with Boost::filesytem Wasi_sdk does'nt work with Boost::filesystem Nov 3, 2023
@sbc100
Copy link
Member

sbc100 commented Nov 3, 2023

I would try removing the sudo from your configure and build steps.. by default I think sudo doesn't preserve the environment so your CC/CXX/etc settings are likely being ignored.

@frawamudi
Copy link
Author

frawamudi commented Nov 4, 2023

Thanks
but got another error:

wasm-ld: error: unknown file type: /opt/wasi-sdk-17.0/share/wasi-sysroot/lib/libboost_filesystem.a(operations.o)
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

after executing this command:
$CXX -v -DBOOST_DISABLE_THREADS test.cpp -o tt.wasm -fno-exceptions -I${WASI_SDK_PATH}/share/wasi-sysroot/include/boost -L${WASI_SDK_PATH}/share/wasi-sysroot/lib -lboost_filesystem -lboost_system --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot

@sbc100
Copy link
Member

sbc100 commented Nov 5, 2023

It looks like that fie (/opt/wasi-sdk-17.0/share/wasi-sysroot/lib/libboost_filesystem.a(operations.o)) was not built with the wasi-sdk, but perhaps with the native compiler. Did you clean everything?

@frawamudi
Copy link
Author

It looks like that fie (/opt/wasi-sdk-17.0/share/wasi-sysroot/lib/libboost_filesystem.a(operations.o)) was not built with the wasi-sdk, but perhaps with the native compiler. Did you clean everything?

yes i did, even tookout the whole wasi-sdk-17.0 folder. it turns out boost build systems ships some built intoolsetthat boost already recognize like gcc, clang, arm etc which are set of Jam files (Boost way of a config or toolchain file), but does have builting toolset for bulding boost for wasi using wasi compilier!

for example executing the --with-toolset=clang tells boost to use clang compiler.

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

2 participants