-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Open
kjartanm
wants to merge
5
commits into
google:main
Choose a base branch
from
kjartanm:Enable-Emscripten-builds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−1
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2398e79
Fence off Emscripten-incompatible elements
d3d6fb7
Add Emscripten setup and Wasm32 as target
66e0f02
Move Emscripten setup
231bebb
Reverse _EMSCRIPTEN_ test, add wasm32 in usage()
f787823
Merge branch 'main' into Enable-Emscripten-builds
Mizux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
local -r EMSDK_URL=https://github.com/emscripten-core/emsdk/archive/${EMSDK_VERSION}.tar.gz | ||
local -r EMSDK_RELATIVE_DIR="emsdk-${EMSDK_VERSION}" | ||
local -r EMSDK="${ARCHIVE_DIR}/${EMSDK_RELATIVE_DIR}" | ||
if [ ! -d "${EMSDK}" ]; then | ||
echo "Fetching emscripten" | ||
unpack "${EMSDK_URL}" "${EMSDK_RELATIVE_DIR}" | ||
echo "Installing Emscripten ..." | ||
${EMSDK}/emsdk install ${EMSDK_VERSION} | ||
|
||
echo "Activating Emscripten ..." | ||
${EMSDK}/emsdk activate ${EMSDK_VERSION} | ||
fi | ||
|
||
declare -r TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake | ||
CMAKE_ADDITIONAL_ARGS+=( -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF) | ||
} | ||
|
||
function build() { | ||
cd "${PROJECT_DIR}" || exit 2 | ||
set -x | ||
|
@@ -323,6 +342,7 @@ DESCRIPTION | |
\t\tmips64 mips64el (codespace) | ||
\t\tppc (bootlin) | ||
\t\tppc64 ppc64le (bootlin) | ||
\t\twasm32 (emscripten) | ||
|
||
OPTIONS | ||
\t-h --help: show this help text | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. note for myself, emscripten generate wasm32 by default |
||
expand_wasm_config | ||
declare -r QEMU_ARCH=DISABLED ;; | ||
*) | ||
>&2 echo "Unknown TARGET '${TARGET}'..." | ||
exit 1 ;; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
sorry this comment is little bit dry, will try to reformulate if you want...