-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add Wasm32 as target for cross compiling #2404
base: main
Are you sure you want to change the base?
Conversation
To enable Emscripten builds, we need to fence off a couple of elements that creates unrecoverable errors during build process.
This adds Wasm32 as target together with Emscripten setup to enable cross compiling of or-tools into wasm.
What's blocking WASM support right now? Is this dead? |
mostly lack of human ressource (i.e. lack of time) to work on it + fear of the technical debt increase to maintain it. BTW I'm not against it, on the contrary I'd love to have an ortools-lite running on the edge on client side web browser... |
Wish I could help on the build errors - Seems like there's some simple permissions error somewhere? |
I have an immediate need for this. What is the blocker? This is how Z3 does it, they provide not just a WASM build but also a JS interface. I agree this should be effectively an or-tools-lite in the default build, you should have to pass some extra flag to build a really fat binary. Minimal viable commit is defining a JSON for an or-tools graph format and having it pass some unit tests? |
My 2 cents, We have a job to test emscripten build using: Lines 660 to 698 in ef7bb07
Dockerfile: https://github.com/google/or-tools/blob/stable/cmake/docker/web/Dockerfile or-tools/cmake/docker/web/Dockerfile Lines 18 to 25 in ef7bb07
Need to compare/test with this PR... |
@@ -265,6 +265,25 @@ QEMU_ARGS+=( -L "${SYSROOT_DIR}" ) | |||
QEMU_ARGS+=( -E LD_PRELOAD="${SYSROOT_DIR}/usr/lib/libstdc++.so.6:${SYSROOT_DIR}/lib/libgcc_s.so.1" ) | |||
} | |||
|
|||
function expand_wasm_config() { | |||
local -r EMSDK_VERSION=2.0.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last Tag as of 2024 June 07
https://github.com/emscripten-core/emsdk/releases/tag/3.1.61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Mizux,
Is it planned for next release or will it take time? Also, is this command work with stable branch:
emcmake cmake -S . -B build -DBUILD_DEPS=ON -DBUILD_PYTHON=ON
I tried after making changes in cross_compile.sh and I am getting error as:
Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES Development Development.Module Development.Embed) (found version "3.11.9")
However, I don't see such error when using just cmake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't get it, what did you try to do/expect ?
BUILD_PYTHON
is used to generate automatically python wrapper on top of the C++ library to have access to ortools in python (which is just a wrapper on top of the native library, since we won't reimplement ortools in pure Python/Java nor .Net).
On the other side, AFAIK, emcmake
is used to transpile C++ code into wasm byte code to have a "browser compatible" source code so there is no point to try to build a python wrapper on top of this wasm library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, I recently pointed @airen1986 to this issue from pyodide/pyodide#5013. If configured correctly, Pyodide would allow runtime for a Python interface for this WASM library through an Emscripten-compiled Python extension module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I guess I understand what you want to do:
0. This is not something we support
- currently our wrapper is generated by swig which is currently use to build 64bit code -> don't know how it work with WASM32 ptr size etc...
- IIRC emcmake is working by injecting a CMake cross toolchain thus my bet is the Toolchainfile do not provide a python thus the issue.
- I would suggest to play with my pet project: https://github.com/Mizux/python-native which should have the same cmake stuff than or-tools so once you have something work there it should be easier to patch/fixup or-tools and dev iteration should be faster IMHO...
sorry this comment is little bit dry, will try to reformulate if you want...
@@ -403,6 +423,9 @@ function main() { | |||
ppc) | |||
expand_bootlin_config | |||
declare -r QEMU_ARCH=ppc ;; | |||
wasm32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for myself, emscripten generate wasm32 by default
ref: https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
This PR adds Wasm32 as target for cross compiling, Emscripten setup, and fences off some Emscripten-incompatible elements.
See Feature request #1670