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

Emscripten arm64 > 3.1.26 cannot build certain libboost libraries #21793

Open
NorrinRadd opened this issue Apr 21, 2024 · 5 comments
Open

Emscripten arm64 > 3.1.26 cannot build certain libboost libraries #21793

NorrinRadd opened this issue Apr 21, 2024 · 5 comments

Comments

@NorrinRadd
Copy link

NorrinRadd commented Apr 21, 2024

Version of emscripten/emsdk:
Failing: 3.1.27 through 3.1.57
Passing: 3.1.10 through 3.1.26

Failing command line in full:
My goal is to build boost single threaded, so as not to require content isolation (COOP and COEP) when running within a browser.
Tested with libboost src from 1.79 through 1.85.
Within boost rootdir:

./bootstrap.sh \
  --with-libraries=system,thread,chrono,serialization,regex```

cat "import os ; \
local EMSCRIPTEN = [ os.environ EMSCRIPTEN ] ; \
 \
using clang : emscripten \
: \
	emcc -v -s USE_ZLIB=1 -s USE_PTHREADS=0 \
: \
	<root>$(EMSCRIPTEN) \
	<archiver>$(EMSCRIPTEN)/emar \
	<ranlib>$(EMSCRIPTEN)/emranlib \
	<linker>$(EMSCRIPTEN)/emlink \
	<cxxflags>-std=c++11 \
; \
 \
 \
import type : change-generated-target-suffix ; \
type.change-generated-target-suffix EXE : <toolset-clang:version>emscripten : js ;" >>  project-config.jam

rm -rf ./output
mkdir -p ./output

./b2 -q -a -j 10    \
  toolset=clang-emscripten    \
  threading=single            \
  link=static                 \
  optimization=space          \
  variant=release             \
  cxxflags=-no-pthread        \
  stage                       \
  --stagedir=./output
  
unset NO_BZIP2

Output

 /Users/user/code/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/Users/user/code/emsdk/upstream/emscripten/cache/sysroot -DEMSCRIPTEN -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -v -x c++ -fvisibility-inlines-hidden -std=c++11 -Os -Wall -fvisibility=hidden -Wno-inline -Wextra -Wno-long-long -Wno-unused-parameter -Wno-variadic-macros -Wunused-function -no-pthread -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I. -c libs/thread/src/pthread/once.cpp -o bin.v2/libs/thread/build/clang-darwin-emscripten/release/link-static/optimization-space/threadapi-pthread/threading-multi/visibility-hidden/pthread/once.o
clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/user/code/emsdk/upstream/bin
 (in-process)
 "/Users/user/code/emsdk/upstream/bin/clang-19" -cc1 -triple wasm32-unknown-emscripten -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name once.cpp -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/Users/user/code/monero-ts/external/monero-cpp/external/boost-sdk -v -fcoverage-compilation-dir=/Users/user/code/monero-ts/external/monero-cpp/external/boost-sdk -resource-dir /Users/user/code/emsdk/upstream/lib/clang/19 -D EMSCRIPTEN -D BOOST_ALL_NO_LIB=1 -D BOOST_THREAD_BUILD_LIB=1 -D BOOST_THREAD_DONT_USE_CHRONO -D BOOST_THREAD_POSIX -D NDEBUG -I . -isysroot /Users/user/code/emsdk/upstream/emscripten/cache/sysroot -internal-isystem /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1 -internal-isystem /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1 -internal-isystem /Users/user/code/emsdk/upstream/lib/clang/19/include -internal-isystem /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include -Os -Wall -Wno-inline -Wextra -Wno-long-long -Wno-unused-parameter -Wno-variadic-macros -Wunused-function -std=c++11 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fignore-exceptions -fexceptions -vectorize-loops -vectorize-slp -iwithsysroot/include/fakesdl -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o bin.v2/libs/thread/build/clang-darwin-emscripten/release/link-static/optimization-space/threadapi-pthread/threading-multi/visibility-hidden/pthread/once.o -x c++ libs/thread/src/pthread/once.cpp
clang -cc1 version 19.0.0git based upon LLVM 19.0.0git default target x86_64-apple-darwin22.4.0
ignoring nonexistent directory "/Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 .
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/compat
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
 /Users/user/code/emsdk/upstream/lib/clang/19/include
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
In file included from libs/thread/src/pthread/once.cpp:6:
In file included from ./boost/thread/detail/config.hpp:13:
In file included from ./boost/thread/detail/platform.hpp:17:
./boost/config/requires_threads.hpp:47:5: error: "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
   47 | #   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
      |     ^
1 error generated.

    "emcc" "-v" "-s" "USE_ZLIB=1" "-s" "USE_PTHREADS=0" -x c++ -fvisibility-inlines-hidden -std=c++11 -Os -Wall -fvisibility=hidden -Wno-inline -Wextra -Wno-long-long -Wno-unused-parameter -Wno-variadic-macros -Wunused-function -no-pthread -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I"."  -c -o "bin.v2/libs/thread/build/clang-darwin-emscripten/release/link-static/optimization-space/threadapi-pthread/threading-multi/visibility-hidden/pthread/once.o" "libs/thread/src/pthread/once.cpp"
@sbc100 sbc100 changed the title Enscripten arm64 > 3.1.26 cannot build certain libboost libraries Emscripten arm64 > 3.1.26 cannot build certain libboost libraries Apr 21, 2024
@sbc100
Copy link
Collaborator

sbc100 commented Apr 21, 2024

It looks like the ./boost/config/requires_threads.hpp header in boost requires threading support. In fact that whole point of that header seems to be to error out when threads are not supported, so it seems to be doing the correct thing here.

I does looks you probably want to be defining BOOST_DISABLE_THREADS in order to make a build without threading support. However, even with this defined that header will still produce an error. See https://github.com/dials/boost/blob/1c586c3c45f994f92c7270c01f64278a7bdf457d/boost/config/requires_threads.hpp#L29

So I guess that platform.hpp should not be including requires_threads.hpp when threads are disabled. Perhaps enabling BOOST_DISABLE_THREADS will fix that?

@NorrinRadd
Copy link
Author

@sbc100 our confusion is that emscripten 3.1.10 through 3.1.26 build them fine. That was a defect in emscripten?

So essentially boost cannot be used within a browser unless cors is restricted to origin?

@NorrinRadd
Copy link
Author

the symbol didnt work

ignoring nonexistent directory "/Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/ wasm32-emscripten/c++/v1"
ignoring nonexistent directory "/Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/ wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 .
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/compat
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include/c++/v1
 /Users/user/code/emsdk/upstream/lib/clang/19/include
 /Users/user/code/emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
In file included from libs/thread/src/pthread/thread.cpp:9:
In file included from ./boost/thread/detail/config.hpp:13:
In file included from ./boost/thread/detail/platform.hpp:17:
./boost/config/requires_threads.hpp:29:4: error: "Threading support unavaliable: it has been      explicitly disabled with BOOST_DISABLE_THREADS"
   29 | #  error "Threading support unavaliable: it has been explicitly disabled with             BOOST_DISABLE_THREADS"
      |    ^   
1 error generated.

@sbc100
Copy link
Collaborator

sbc100 commented Apr 23, 2024

Regarding that compile issue it looks like platform.hpp would need to be configured somehow to not include requires_threads.hpp. I assume that is possible, otherwise BOOST_DISABLE_THREADS wouldn't be a thing?

Regarding how you were able to compile with 3.1.10 through 3.1.26 that would require some more investigation. Emscripten has never supported threads without the COOP/COEP stuff enabled. My only guess is that perhaps with 3.1.10 through 3.1.26 boost was detecting that threads were not supported at build time and therefore not including requires_threads.hpp

@Kojoley
Copy link

Kojoley commented Apr 23, 2024

./bootstrap.sh \
  --with-libraries=system,thread,chrono,serialization,regex```

You are asking to build Boost.Thread but you are disabling threads support with threading=single cxxflags=-no-pthread. It makes no sense, the error message is legit.

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