Pages

Monday, 14 October 2024

静态博客程序emscripten

 

Download and install

Note

You can also build Emscripten from source if you prefer that to downloading binaries using the emsdk.

Tip

if you’d like to install emscripten using the unofficial packages instead of the officially supported emsdk, see the bottom of the page.

Verifying the installation

The easiest way to verify the installation is to compile some code using Emscripten.

You can jump ahead to the Emscripten Tutorial, but if you have any problems building you should run through the basic tests and troubleshooting instructions in Verifying the Emscripten Development Environment.

Updating the SDK

Tip

You only need to install the SDK once! After that you can update to the latest SDK at any time using Emscripten SDK (emsdk).

Type the following in a command prompt

# Fetch the latest registry of available tools.
./emsdk update

# Download and install the latest SDK tools.
./emsdk install latest

# Set up the compiler configuration to point to the "latest" SDK.
./emsdk activate latest

# Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

The package manager can do many other maintenance tasks ranging from fetching specific old versions of the SDK through to using the versions of the tools on GitHub (or even your own fork). Check out all the possibilities in the “How to” guides.

from https://emscripten.org/docs/getting_started/downloads.html

-----------------------------------------------------------------------------------------------

Building Emscripten from Source

Building Emscripten yourself is an alternative to getting binaries using the emsdk.

Emscripten itself is written in Python and JavaScript so it does not need to be compiled. However, after checkout you will need to perform various steps before it can be used (e.g. npm install). The bootstrap script in the top level of the repository takes care of running these steps and emcc will error out if it detects that bootstrap needs to be run.

In addition to the main emscripten repository you will also need to checkout and build LLVM and Binaryen (as detailed below). After compiling these, you will need to edit your .emscripten file to point to their corresponding locations.

Use the main branches of each of these repositories, or check the Packaging instructions to identify precise commits used in a specific release.

Building LLVM

Build LLVM from the git repo. Include clang and wasm-ld (using something like -DLLVM_ENABLE_PROJECTS='lld;clang') and the Wasm backend (which is included by default; just don’t disable it), following that project’s instructions. For example, something like this can work:

mkdir build
cd build/
cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='lld;clang' -DLLVM_TARGETS_TO_BUILD="host;WebAssembly" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF  # -DLLVM_ENABLE_ASSERTIONS=ON
cmake --build .

Then set the environment variable EM_LLVM_ROOT to <llvm_src>/build/bin (no need to install).

If you need to match the emsdk releases of LLVM, review the emscripten-release build and test scripts. Specifically src/build.py.

Please refer to the upstream docs for more detail.

Building Binaryen

See the Binaryen build instructions.

from https://emscripten.org/docs/building_from_source/index.html#installing-from-source
-------------------------------------------------------

https://emscripten.org/docs/getting_started/Tutorial.html

https://gitlab.com/pages/emscripten

https://github.com/emscripten-core/emscripten

No comments:

Post a Comment