Skip to content

[feature] Add wasm64 arch #17693

@stevenwdv

Description

@stevenwdv

What is your suggestion?

Currently, 32-bit wasm (WebAssembly) is supported in settings.yml, but wasm64 is missing. I tried just compiling with -sMEMORY=64 in cflags/cxxflags/exelinkflags/sharedlinkflags, but then got the following error once linking to my own executable:

/home/swdv/emsdk/upstream/emscripten/em++ -sMEMORY64=1 [...] /home/swdv/.conan2/p/b/boosta13dc00a72eaf/p/lib/libboost_iostreams.a [...] :
wasm-ld: error: /home/swdv/.conan2/p/b/boosta13dc00a72eaf/p/lib/libboost_iostreams.a(file_descriptor.o):
    wasm32 object file can't be linked in wasm64 mode

This seems to be caused by the boost recipe, that I use, passing the wrong address-model to b2, apparently causing modules to still be compiled as 32-bit:

Requirements
    boost/1.86.0#ce76e7477e466d7d8cbcf738c5d64175
[...]
boost/1.86.0: WARN: Patching user-config.jam
boost/1.86.0: WARN: 
using "emscripten" :  :  "em++" : 
<cxxflags>"-sMEMORY64=1" <cflags>"-sMEMORY64=1" <linkflags>"-sMEMORY64=1"  ;
boost/1.86.0: Cross building, detecting compiler...
boost/1.86.0: Cross building flags: []
boost/1.86.0: WARN: b2 -q address-model=32 --layout=system --user-config=/home/swdv/.conan2/p/boostcfb011e43f97d/s/src/tools/build/user-config.jam -sNO_ZLIB=1 -sNO_BZIP2=1 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv threading=multi visibility=hidden link=static variant=debug --with-atomic --with-chrono --with-container --with-date_time --with-exception --with-filesystem --with-iostreams --with-log --with-random --with-regex --with-system --with-thread toolset=emscripten cxxstd=2a define=BOOST_DLL_USE_STD_FS=1 pch=on linkflags="" cxxflags="-fPIC" install --prefix=/home/swdv/.conan2/p/b/boost44d6ff027eed3/p -j12 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/swdv/.conan2/p/b/boost44d6ff027eed3/b/build-debug"
boost/1.86.0: RUN: b2 [see above...]
notice: found boost-build.jam at /home/swdv/.conan2/p/boostcfb011e43f97d/s/src/boost-build.jam
notice: loading B2 from /home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/build-system.jam
notice: Searching '/etc' '/home/swdv' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/util' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/tools' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/options' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/contrib' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/build' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/swdv' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/util' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/tools' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/options' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/contrib' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2/build' '/home/swdv/.conan2/p/b20717b8c0763fa/p/bin/.b2'.
notice: Loading explicitly specified user configuration file:
    /home/swdv/.conan2/p/boostcfb011e43f97d/s/src/tools/build/user-config.jam
notice: Searching '/home/swdv/.conan2/p/boostcfb011e43f97d/s/src/tools/build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/home/swdv/.conan2/p/boostcfb011e43f97d/s/src/tools/build'.
notice: will use 'em++' for emscripten, condition <toolset>emscripten-4.0.1
notice: [emscripten-cfg] <toolset>emscripten-4.0.1 :: emcc :: em++
notice: [emscripten-cfg] <toolset>emscripten-4.0.1 :: archiver :: emar
notice: [emscripten-cfg] <toolset>emscripten-4.0.1 :: nodejs version is 22
node: bad option: --experimental-wasm-threads
notice: [emscripten-cfg] <toolset>emscripten-4.0.1 :: nodejs :: node
notice: [openssl] Using pre-installed library
notice: [openssl] Condition
notice: using boost library auto_config <layout>system
notice: iostreams: not using zlib compression 
notice: iostreams: not using bzip compression 
notice: iostreams: not using lzma compression 
notice: iostreams: not using zstd compression 
notice: [python-cfg] Configuring python...
notice: [python-cfg] Checking interpreter command "python"...
notice: [python-cfg] running command 'python -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...does not invoke a working interpreter
notice: [python-cfg] Python headers and libraries not found.
Performing configuration checks

    - default address-model    : 64-bit [1]
    - default architecture     : none [1]
    - default address-model    : 64-bit [2]
[...]

This is caused by _b2_address_model returning 32 in the boost recipe:

https://github.com/conan-io/conan-center-index/blob/a9b270f9d2052e193ce3c0a6c4e2fda0b0ac5ade/recipes/boost/all/conanfile.py#L1185-L1189

I tried adding boost/*:extra_b2_flags='address-model=64' but it doesn't seem to properly override address-model=32.

Adding wasm64 and updating the boost recipe could solve this. If I can make a suggestion, I also think there should be a centralized function returning the address model, to avoid having to update similar logic in multiple recipes.

I don't know if Conan should also automatically pass -sMEMORY=64 or something.

Setup

Version info

$ conan version
version: 2.11.0
conan_path: /home/swdv/.local/bin/conan
python
  version: 3.10.13
  sys_version: 3.10.13 (main, Sep  5 2023, 06:03:44) [GCC 11.4.0]
  sys_executable: /home/swdv/.local/pipx/venvs/conan/bin/python
  is_frozen: False
  architecture: x86_64
system
  version: #202405300957~1736980680~22.04~44ea8a9 SMP PREEMPT_DYNAMIC Thu J
  platform: Linux-6.9.3-76060903-generic-x86_64-with-glibc2.35
  system: Linux
  release: 6.9.3-76060903-generic
  cpu: x86_64
$ ~/emsdk/emsdk list --uses
The *recommended* precompiled SDK download is 4.0.1 (5ff495a591978fdf8a16f2d172be3616f3150d1e).
[...]

All recent (non-legacy) installable versions are:
         4.0.1    INSTALLED
[...]

The additional following precompiled SDKs are also available for download:
    *    sdk-releases-5ff495a591978fdf8a16f2d172be3616f3150d1e-64bit    INSTALLED
          - node-20.18.0-64bit       
          - releases-5ff495a591978fdf8a16f2d172be3616f3150d1e-64bit
[...]
$ em++ --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.1 (89ce854a99238d04116a3d9b5afe241eec90c6c3)
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.
$ ~/emsdk/upstream/bin/clang --version
clang version 20.0.0git (https:/github.com/llvm/llvm-project a32e36faf84bd7da3df0c7d50bb9020568128417)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/swdv/emsdk/upstream/bin

Profile

[settings]
arch=wasm
build_type=Debug
compiler=clang
compiler.cppstd=20
compiler.version=19
os=Emscripten

[conf]
tools.build:compiler_executables={'c':'emcc', 'cpp':'em++'}
tools.cmake.cmaketoolchain:user_toolchain=['/home/swdv/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake']
tools.build:cflags=['-sMEMORY64=1']
tools.build:cxxflags=['-sMEMORY64=1']
tools.build:exelinkflags=['-sMEMORY64=1']
tools.build:sharedlinkflags=['-sMEMORY64=1']

[buildenv]
_EMCC_CCACHE=1

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions