Skip to content

Commit 71b369d

Browse files
authored
Update Emscripten version to 3.1.21 (#5636)
* 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
1 parent 4d8cf56 commit 71b369d

File tree

8 files changed

+60
-31
lines changed

8 files changed

+60
-31
lines changed

.circleci/config.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

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

3535
# GDevelop.js dependencies
3636
- restore_cache:
@@ -107,7 +107,7 @@ jobs:
107107

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

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

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

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

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

205207
- save_cache:
206208
paths:

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tasks:
1414
init: |
1515
sudo apt-get update
1616
sudo apt install cmake python-is-python3 python3-distutils -y
17-
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
17+
git clone https://github.com/juj/emsdk.git && cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
1818
cd GDevelop.js
1919
npm install
2020
source ../emsdk/emsdk_env.sh && npm run build -- --dev

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ install:
3939
- cd ..
4040
# Install Emscripten (for GDevelop.js)
4141
- git clone https://github.com/juj/emsdk.git
42-
- cd emsdk && ./emsdk install 1.39.6 && ./emsdk activate 1.39.6 && cd ..
42+
- cd emsdk && ./emsdk install 3.1.21 && ./emsdk activate 3.1.21 && cd ..
4343
# Install GDevelop.js dependencies
4444
- cd GDevelop.js && npm install && cd ..
4545
# Build GDevelop.js

GDevelop.js/CMakeLists.txt

+23-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ if(NOT EMSCRIPTEN)
1212
endif()
1313

1414
# Compilation flags (https://emscripten.org/docs/tools_reference/emcc.html):
15-
add_compile_options(-O2) # Optimizations during compilation
16-
#add_compile_options(-g --profiling) # Uncomment for debugging + profiling support
15+
add_compile_options(-O3 -flto) # Optimizations during compilation
16+
# add_compile_options(-fwasm-exceptions) # Enable exceptions
17+
if(NOT DISABLE_EMSCRIPTEN_LINK_OPTIMIZATIONS)
18+
add_compile_options(-flto) # The compiler needs to know if there will be link time optimisations
19+
endif()
20+
21+
# Compiler debugging options
22+
#
23+
# add_compile_options(-fsanitize=address) # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable linking below!
24+
# add_compile_options(-fsanitize=undefined) # Uncomment to auto-detect occurences of undefined behavior - also enable linking below!
25+
# add_compile_options(-g) # Uncomment for debugging support
1726
# add_compile_options(--profiling) # Uncomment for profiling support
1827

1928
# Common directories:
@@ -64,7 +73,7 @@ if(DISABLE_EMSCRIPTEN_LINK_OPTIMIZATIONS)
6473
message(STATUS "Disabling optimization at link time for (slightly) faster build")
6574
target_link_libraries(GD "-O0")
6675
else()
67-
target_link_libraries(GD "-O2")
76+
target_link_libraries(GD "-O3 -flto")
6877
endif()
6978
target_link_libraries(GD "--post-js ${GD_base_dir}/GDevelop.js/Bindings/glue.js")
7079
target_link_libraries(GD "--post-js ${GD_base_dir}/GDevelop.js/Bindings/postjs.js")
@@ -73,7 +82,17 @@ target_link_libraries(GD "-s EXPORT_NAME=\"initializeGDevelopJs\"") # Global fun
7382
target_link_libraries(GD "-s TOTAL_MEMORY=48MB") # Get some initial memory size that is a bit bigger than the default.
7483
target_link_libraries(GD "-s ALLOW_MEMORY_GROWTH=1")
7584
target_link_libraries(GD "-s ERROR_ON_UNDEFINED_SYMBOLS=0")
76-
target_link_libraries(GD "-s \"EXTRA_EXPORTED_RUNTIME_METHODS=['addOnPreMain', 'calledRun', 'UTF8ToString']\"")
85+
target_link_libraries(GD "-s \"EXPORTED_FUNCTIONS=['_free']\"")
86+
87+
# Linker debugging options
88+
#
89+
# target_link_libraries(GD "-s DEMANGLE_SUPPORT=1") # Demangle stack traces
90+
# target_link_libraries(GD "-s ASSERTIONS=1") # Basic runtime memory allocation checks (necessary for wasm exceptions stack traces)
91+
# target_link_libraries(GD "-s ASSERTIONS=2 -s SAFE_HEAP=1") # Uncomment to do runtime checks for memory allocations and access errors
92+
# target_link_libraries(GD "-fsanitize=address") # Uncomment to auto-detect occurences of memory bugs (memory leak, use after free, overflows, ...) - also enable compiling above!
93+
# target_link_libraries(GD "-fsanitize=undefined") # Uncomment to auto-detect occurences of undefined behavior - also enable compiling above!
94+
# target_link_libraries(--cpuprofiler) # Uncomment for interactive performance profiling
95+
# target_link_libraries(--memoryprofiler) # Uncomment for interactive memory profiling
7796

7897
# Even if we're building an "executable", prefix it by lib as it's used as a library.
7998
set_target_properties(GD PROPERTIES PREFIX "lib")

GDevelop.js/Gruntfile.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function (grunt) {
1010
const buildOutputPath = '../Binaries/embuild/GDevelop.js/';
1111
const buildPath = '../Binaries/embuild';
1212

13-
let cmakeBinary = 'emconfigure cmake';
13+
let cmakeBinary = 'emcmake cmake';
1414
let cmakeGeneratorArgs = [];
1515
let makeBinary = 'emmake make';
1616
let makeArgs = ['-j 4'];
@@ -44,11 +44,11 @@ module.exports = function (grunt) {
4444

4545
// Find CMake in usual folders or fallback to PATH.
4646
if (fs.existsSync('C:\\Program Files\\CMake\\bin\\cmake.exe')) {
47-
cmakeBinary = 'emconfigure "C:\\Program Files\\CMake\\bin\\cmake"';
47+
cmakeBinary = 'emcmake "C:\\Program Files\\CMake\\bin\\cmake"';
4848
} else if (
4949
fs.existsSync('C:\\Program Files (x86)\\CMake\\bin\\cmake.exe')
5050
) {
51-
cmakeBinary = 'emconfigure "C:\\Program Files (x86)\\CMake\\bin\\cmake"';
51+
cmakeBinary = 'emcmake "C:\\Program Files (x86)\\CMake\\bin\\cmake"';
5252
} else {
5353
console.log(
5454
"⚠️ Can't find CMake in its usual Program Files folder. Make sure you have cmake in your PATH instead."

GDevelop.js/README.md

+18-10
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@ This is the port of GDevelop core classes to WebAssembly+JavaScript. This allows
99
> 👋 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.
1010
1111
- Prerequisite tools installed:
12+
1213
- [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).
1314
- [Node.js](https://nodejs.org/). (We recommend using [nvm](https://github.com/nvm-sh/nvm) to be able to switch between Node versions easily).
1415
- Python (via [pyenv](https://github.com/pyenv/pyenv) for versions management).
1516

16-
- 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):
17+
- 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):
1718

18-
| Linux/macOS | Windows |
19-
| -------------------------------------------- | -------------------------------------------- |
20-
| `git clone https://github.com/juj/emsdk.git` | `git clone https://github.com/juj/emsdk.git` |
21-
| `cd emsdk` | `cd emsdk` |
22-
| `git pull` | `git pull` |
23-
| `./emsdk install 1.39.6` | `emsdk install 1.39.6` |
24-
| `./emsdk activate 1.39.6` | `emsdk activate 1.39.6` |
25-
| `source ./emsdk_env.sh` | `emsdk_env.bat` |
19+
```bash
20+
git clone https://github.com/emscripten-core/emsdk/
21+
cd emsdk
22+
git pull
23+
./emsdk install 3.1.21
24+
./emsdk activate 3.1.21
25+
```
2626

2727
> ⚠️ 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.
2828
29-
- Launch the build from GDevelop.js folder:
29+
- 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:
30+
31+
| Linux/macOS | Windows (Powershell) | Windows (cmd.exe) |
32+
| ----------------------- | -------------------- | ----------------- |
33+
| `source ./emsdk_env.sh` | `./emsdk_env.ps1` | `./emsdk_env.bat` |
34+
35+
- With the emscripten environement loaded into your terminal, launch the build from GDevelop.js folder:
3036

3137
```bash
3238
cd GDevelop.js
@@ -38,6 +44,8 @@ npm run build
3844
3945
> ℹ️ Output is created in _/path/to/GD/Binaries/embuild/GDevelop.js/_ and also copied to GDevelop 5 IDE (`newIDE` folder).
4046
47+
> ℹ️ You only need to run `npm install` the first time you make a build.
48+
4149
-> ⏱ 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.
4250

4351
- You can then launch GDevelop 5 that will use your build of GDevelop.js:

GDevelop.js/ninja/ninja.exe

44 KB
Binary file not shown.

appveyor.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ init:
1919
install:
2020
# Build GDevelop.js (and run tests to ensure it works).
2121
# (in a subshell to avoid Emscripten polluting the Node.js and npm version for the rest of the build)
22-
# Also install setuptools as our old version of Emscripten uses distutils which was removed in Python 3.12.
23-
# setuptools will make distutils available again (but we should migrate to a newer Emscripten version).
2422
- cmd: >-
2523
cd GDevelop.js
2624
@@ -30,16 +28,18 @@ install:
3028
3129
cd emsdk
3230
33-
emsdk install 1.39.6
34-
35-
CMD /C "emsdk activate 1.39.6 && pip install setuptools && cd .. && npm run build"
36-
31+
emsdk install 3.1.21
3732
33+
CMD /C "emsdk activate 3.1.21 && cd .. && npm run build"
3834
3935
cd ..\..
4036
41-
# Build GDevelop IDE
37+
# Build GDevelop IDE.
38+
# Also install setuptools as something requires distutils in electron-app, and it was removed in Python 3.12.
39+
# setuptools will make distutils available again (but we should migrate our packages probably).
4240
- cmd: >-
41+
pip install setuptools
42+
4343
cd newIDE\app
4444
4545
npm -v && npm install

0 commit comments

Comments
 (0)