Skip to content

Commit

Permalink
Update Emscripten version to 3.1.21 (#5636)
Browse files Browse the repository at this point in the history
* Any developer working on the C++ codebase should follow again the [README](https://github.com/4ian/GDevelop/tree/master/GDevelop.js) to install latest Emscripten version and re-compile C++.

Only show in developer changelog
  • Loading branch information
arthuro555 authored Nov 22, 2023
1 parent 4d8cf56 commit 71b369d
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 31 deletions.
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..

# GDevelop.js dependencies
- restore_cache:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:

- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..

- run:
name: Install system dependencies for Electron builder
Expand All @@ -127,7 +127,8 @@ jobs:
# Build GDevelop.js (and run tests to ensure it works)
- run:
name: Build GDevelop.js
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
# Use "--runInBand" as it's faster and avoid deadlocks on CircleCI Linux machines (probably because limited in processes number).
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test -- --runInBand && cd ..

# GDevelop IDE dependencies (after building GDevelop.js to avoid downloading a pre-built version)
- run:
Expand Down Expand Up @@ -184,7 +185,7 @@ jobs:

- run:
name: Install Emscripten (for GDevelop.js)
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
command: git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..

# GDevelop.js dependencies
- restore_cache:
Expand All @@ -200,7 +201,8 @@ jobs:
# Build GDevelop.js (and run tests to ensure it works)
- run:
name: Build GDevelop.js
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test && cd ..
# Use "--runInBand" as it's faster and avoid deadlocks on CircleCI Linux machines (probably because limited in processes number).
command: cd GDevelop.js && source ../emsdk/emsdk_env.sh && npm run build && npm test -- --runInBand && cd ..

- save_cache:
paths:
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tasks:
init: |
sudo apt-get update
sudo apt install cmake python-is-python3 python3-distutils -y
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
cd GDevelop.js
npm install
source ../emsdk/emsdk_env.sh && npm run build -- --dev
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install:
- cd ..
# Install Emscripten (for GDevelop.js)
- git clone https://github.com/juj/emsdk.git
- cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
- cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
# Install GDevelop.js dependencies
- cd GDevelop.js && npm install && cd ..
# Build GDevelop.js
Expand Down
27 changes: 23 additions & 4 deletions GDevelop.js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ if(NOT EMSCRIPTEN)
endif()

# Compilation flags (https://emscripten.org/docs/tools_reference/emcc.html):
add_compile_options(-O2) # Optimizations during compilation
#add_compile_options(-g --profiling) # Uncomment for debugging + profiling support
add_compile_options(-O3 -flto) # Optimizations during compilation
# add_compile_options(-fwasm-exceptions) # Enable exceptions
if(NOT DISABLE_EMSCRIPTEN_LINK_OPTIMIZATIONS)
add_compile_options(-flto) # The compiler needs to know if there will be link time optimisations
endif()

# Compiler debugging options
#
# add_compile_options(-fsanitize=address) # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable linking below!
# add_compile_options(-fsanitize=undefined) # Uncomment to auto-detect occurences of undefined behavior - also enable linking below!
# add_compile_options(-g) # Uncomment for debugging support
# add_compile_options(--profiling) # Uncomment for profiling support

# Common directories:
Expand Down Expand Up @@ -64,7 +73,7 @@ if(DISABLE_EMSCRIPTEN_LINK_OPTIMIZATIONS)
message(STATUS "Disabling optimization at link time for (slightly) faster build")
target_link_libraries(GD "-O0")
else()
target_link_libraries(GD "-O2")
target_link_libraries(GD "-O3 -flto")
endif()
target_link_libraries(GD "--post-js ${GD_base_dir}/GDevelop.js/Bindings/glue.js")
target_link_libraries(GD "--post-js ${GD_base_dir}/GDevelop.js/Bindings/postjs.js")
Expand All @@ -73,7 +82,17 @@ target_link_libraries(GD "-s EXPORT_NAME=\"initializeGDevelopJs\"") # Global fun
target_link_libraries(GD "-s TOTAL_MEMORY=48MB") # Get some initial memory size that is a bit bigger than the default.
target_link_libraries(GD "-s ALLOW_MEMORY_GROWTH=1")
target_link_libraries(GD "-s ERROR_ON_UNDEFINED_SYMBOLS=0")
target_link_libraries(GD "-s \"EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPreMain', 'calledRun', 'UTF8ToString']\"")
target_link_libraries(GD "-s \"EXPORTED_FUNCTIONS=['_free']\"")

# Linker debugging options
#
# target_link_libraries(GD "-s DEMANGLE_SUPPORT=1") # Demangle stack traces
# target_link_libraries(GD "-s ASSERTIONS=1") # Basic runtime memory allocation checks (necessary for wasm exceptions stack traces)
# target_link_libraries(GD "-s ASSERTIONS=2 -s SAFE_HEAP=1") # Uncomment to do runtime checks for memory allocations and access errors
# target_link_libraries(GD "-fsanitize=address") # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable compiling above!
# target_link_libraries(GD "-fsanitize=undefined") # Uncomment to auto-detect occurences of undefined behavior - also enable compiling above!
# target_link_libraries(--cpuprofiler) # Uncomment for interactive performance profiling
# target_link_libraries(--memoryprofiler) # Uncomment for interactive memory profiling

# Even if we're building an "executable", prefix it by lib as it's used as a library.
set_target_properties(GD PROPERTIES PREFIX "lib")
Expand Down
6 changes: 3 additions & 3 deletions GDevelop.js/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function (grunt) {
const buildOutputPath = '../Binaries/embuild/GDevelop.js/';
const buildPath = '../Binaries/embuild';

let cmakeBinary = 'emconfigure cmake';
let cmakeBinary = 'emcmake cmake';
let cmakeGeneratorArgs = [];
let makeBinary = 'emmake make';
let makeArgs = ['-j 4'];
Expand Down Expand Up @@ -44,11 +44,11 @@ module.exports = function (grunt) {

// Find CMake in usual folders or fallback to PATH.
if (fs.existsSync('C:\\Program Files\\CMake\\bin\\cmake.exe')) {
cmakeBinary = 'emconfigure "C:\\Program Files\\CMake\\bin\\cmake"';
cmakeBinary = 'emcmake "C:\\Program Files\\CMake\\bin\\cmake"';
} else if (
fs.existsSync('C:\\Program Files (x86)\\CMake\\bin\\cmake.exe')
) {
cmakeBinary = 'emconfigure "C:\\Program Files (x86)\\CMake\\bin\\cmake"';
cmakeBinary = 'emcmake "C:\\Program Files (x86)\\CMake\\bin\\cmake"';
} else {
console.log(
"⚠️ Can't find CMake in its usual Program Files folder. Make sure you have cmake in your PATH instead."
Expand Down
28 changes: 18 additions & 10 deletions GDevelop.js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,30 @@ This is the port of GDevelop core classes to WebAssembly+JavaScript. This allows
> 👋 Usually, if you're working on the GDevelop editor or extensions in JavaScript, you don't need to rebuild GDevelop.js. If you want to make changes in C++ extensions or classes, read this section.
- Prerequisite tools installed:

- [CMake 3.17+](http://www.cmake.org/) (3.5+ should work on Linux/macOS). On macOS, you can install it via Homebrew (recommended for Apple M1 Architectures).
- [Node.js](https://nodejs.org/). (We recommend using [nvm](https://github.com/nvm-sh/nvm) to be able to switch between Node versions easily).
- Python (via [pyenv](https://github.com/pyenv/pyenv) for versions management).

- Install [Emscripten](https://github.com/kripken/emscripten), as explained below or on the [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html):
- Install [Emscripten](https://github.com/kripken/emscripten) version `3.1.21`, as explained below or on the [Emscripten installation instructions](http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html):

| Linux/macOS | Windows |
| -------------------------------------------- | -------------------------------------------- |
| `git clone https://github.com/juj/emsdk.git` | `git clone https://github.com/juj/emsdk.git` |
| `cd emsdk` | `cd emsdk` |
| `git pull` | `git pull` |
| `./emsdk install 1.39.6` | `emsdk install 1.39.6` |
| `./emsdk activate 1.39.6` | `emsdk activate 1.39.6` |
| `source ./emsdk_env.sh` | `emsdk_env.bat` |
```bash
git clone https://github.com/emscripten-core/emsdk/
cd emsdk
git pull
./emsdk install 3.1.21
./emsdk activate 3.1.21
```

> ⚠️ If you are on Apple M1, this version of emsdk may not be available for this architecture and you will get an error when installing it, indicating a missing binary. If this is the case, a workaround is to modify the `emsdk.py` line 132 with `machine = 'x86_64'` to ensure a correct binary is downloaded.
- Launch the build from GDevelop.js folder:
- Whenever you try to build GDevelop.js in the future, you will have to load the emsdk environement into your terminal window again by running:

| Linux/macOS | Windows (Powershell) | Windows (cmd.exe) |
| ----------------------- | -------------------- | ----------------- |
| `source ./emsdk_env.sh` | `./emsdk_env.ps1` | `./emsdk_env.bat` |

- With the emscripten environement loaded into your terminal, launch the build from GDevelop.js folder:

```bash
cd GDevelop.js
Expand All @@ -38,6 +44,8 @@ npm run build
> ℹ️ Output is created in _/path/to/GD/Binaries/embuild/GDevelop.js/_ and also copied to GDevelop 5 IDE (`newIDE` folder).
> ℹ️ You only need to run `npm install` the first time you make a build.
-> ⏱ The linking (last step) of the build can be made a few seconds faster by specifying `-- --dev`. Be sure to remove it before building a release version, as this disable "link-time optimizations" of the generated WebAssembly module.

- You can then launch GDevelop 5 that will use your build of GDevelop.js:
Expand Down
Binary file modified GDevelop.js/ninja/ninja.exe
Binary file not shown.
14 changes: 7 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ init:
install:
# Build GDevelop.js (and run tests to ensure it works).
# (in a subshell to avoid Emscripten polluting the Node.js and npm version for the rest of the build)
# Also install setuptools as our old version of Emscripten uses distutils which was removed in Python 3.12.
# setuptools will make distutils available again (but we should migrate to a newer Emscripten version).
- cmd: >-
cd GDevelop.js
Expand All @@ -30,16 +28,18 @@ install:
cd emsdk
emsdk install 1.39.6
CMD /C "emsdk activate 1.39.6 && pip install setuptools && cd .. && npm run build"
emsdk install 3.1.21
CMD /C "emsdk activate 3.1.21 && cd .. && npm run build"
cd ..\..
# Build GDevelop IDE
# Build GDevelop IDE.
# Also install setuptools as something requires distutils in electron-app, and it was removed in Python 3.12.
# setuptools will make distutils available again (but we should migrate our packages probably).
- cmd: >-
pip install setuptools
cd newIDE\app
npm -v && npm install
Expand Down

0 comments on commit 71b369d

Please sign in to comment.