Skip to content

Commit 4e0a009

Browse files
committed
Merge tag 'version_117' into fwasm-exceptions
2 parents 22a248b + c62a0c9 commit 4e0a009

File tree

948 files changed

+102931
-65521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

948 files changed

+102931
-65521
lines changed

.clang-format

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ BinPackParameters: false
1212
Language: JavaScript
1313
DisableFormat: true
1414
---
15+
Language: Json
16+
BasedOnStyle: LLVM
17+
---

.github/workflows/ci.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,20 @@ jobs:
151151
- uses: actions/checkout@v1
152152
with:
153153
submodules: true
154+
- name: install clang
155+
uses: egor-tensin/setup-clang@v1
156+
with:
157+
# Clang 15 seems to avoid asan flakes that 14 has (#6116).
158+
version: 15
159+
platform: x64
154160
- name: install ninja
155161
run: sudo apt-get install ninja-build
156162
- name: install Python dev dependencies
157163
run: pip3 install -r requirements-dev.txt
158164
- name: cmake
159165
run: |
160166
mkdir -p out
161-
cmake -S . -B out -G Ninja -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS"
167+
cmake -S . -B out -G Ninja -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 -DCMAKE_C_FLAGS="$COMPILER_FLAGS" -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS"
162168
- name: build
163169
run: cmake --build out
164170
- name: test
@@ -189,7 +195,7 @@ jobs:
189195
./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja
190196
191197
- name: install python dev dependencies
192-
run: ./alpine.sh pip3 install -r requirements-dev.txt
198+
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
193199

194200
- name: cmake
195201
run: |
@@ -349,7 +355,8 @@ jobs:
349355
# Duplicates build-asan. Please keep in sync
350356
build-cxx20:
351357
name: c++20
352-
runs-on: ubuntu-latest
358+
# Make sure we can still build on older Ubuntu
359+
runs-on: ubuntu-20.04
353360
env:
354361
CC: "gcc"
355362
CXX: "g++"

.github/workflows/create_release.yml

+78-3
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,34 @@ jobs:
106106
build-alpine:
107107
name: alpine
108108
runs-on: ubuntu-latest
109+
strategy:
110+
matrix:
111+
docker_platform: [amd64, arm64]
109112
steps:
110113
- uses: actions/setup-python@v1
111114
with:
112115
python-version: '3.x'
113116
- uses: actions/checkout@v1
114117
with:
115118
submodules: true
119+
- name: Set up QEMU
120+
uses: docker/setup-qemu-action@v3
121+
if: matrix.docker_platform != 'amd64'
122+
116123
- name: start docker
117124
run: |
118-
docker run -w /src -dit --name alpine -v $PWD:/src node:lts-alpine
125+
docker run -w /src -dit --platform=linux/${{ matrix.docker_platform }} --name alpine -v $PWD:/src node:lts-alpine
119126
echo 'docker exec alpine "$@";' > ./alpine.sh
120127
chmod +x ./alpine.sh
121128
129+
122130
- name: install packages
123131
run: |
124132
./alpine.sh apk update
125133
./alpine.sh apk add build-base cmake git python3 clang ninja py3-pip
126134
127135
- name: install python dev dependencies
128-
run: ./alpine.sh pip3 install -r requirements-dev.txt
136+
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
129137

130138
- name: cmake
131139
run: |
@@ -142,7 +150,8 @@ jobs:
142150
id: archive
143151
run: |
144152
VERSION=$GITHUB_REF_NAME
145-
PKGNAME="binaryen-$VERSION-x86_64-linux"
153+
ARCH=$(./alpine.sh uname -m)
154+
PKGNAME="binaryen-$VERSION-$ARCH-linux"
146155
TARBALL=$PKGNAME.tar.gz
147156
SHASUM=$PKGNAME.tar.gz.sha256
148157
./alpine.sh find install/ -type f -perm -u=x -exec strip {} +
@@ -159,3 +168,69 @@ jobs:
159168
files: |
160169
${{ steps.archive.outputs.tarball }}
161170
${{ steps.archive.outputs.shasum }}
171+
172+
# Build using Emscripten to JavaScript+WebAssembly.
173+
build-node:
174+
name: node
175+
runs-on: ubuntu-latest
176+
defaults:
177+
run:
178+
shell: bash
179+
steps:
180+
- uses: actions/setup-python@v1
181+
with:
182+
python-version: '3.x'
183+
- uses: actions/checkout@v1
184+
with:
185+
submodules: true
186+
- name: install ninja
187+
run: sudo apt-get install ninja-build
188+
- name: emsdk install
189+
run: |
190+
mkdir $HOME/emsdk
191+
git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk
192+
$HOME/emsdk/emsdk update-tags
193+
$HOME/emsdk/emsdk install tot
194+
$HOME/emsdk/emsdk activate tot
195+
- name: update path
196+
run: echo "PATH=$PATH:$HOME/emsdk" >> $GITHUB_ENV
197+
198+
# Configure with wasm EH and pthreads for maximal performance.
199+
- name: cmake
200+
run: |
201+
source $HOME/emsdk/emsdk_env.sh
202+
emcmake cmake -S . -B out -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=out/install -DEMSCRIPTEN_ENABLE_WASM_EH=ON -DEMSCRIPTEN_ENABLE_PTHREADS=ON
203+
204+
# Build wasm-opt for now TODO add other tools as desired
205+
- name: build
206+
run: ninja -C out wasm-opt
207+
208+
# Minimal smoke test: roundtrip a file.
209+
# TODO: Add more testing here, but the full test suite is overkill as there
210+
# is a 0.5 second cost to each run of wasm-opt.js
211+
- name: test
212+
run: |
213+
node out/bin/wasm-opt.js test/hello_world.wat --print > out/t.wat
214+
diff test/hello_world.wat out/t.wat
215+
216+
- name: archive
217+
id: archive
218+
run: |
219+
VERSION=$GITHUB_REF_NAME
220+
PKGNAME="binaryen-$VERSION-node"
221+
TARBALL=$PKGNAME.tar.gz
222+
SHASUM=$PKGNAME.tar.gz.sha256
223+
mkdir binaryen-$VERSION
224+
cp out/bin/wasm-opt* binaryen-$VERSION/
225+
tar -czf $TARBALL binaryen-$VERSION
226+
cmake -E sha256sum $TARBALL > $SHASUM
227+
echo "::set-output name=tarball::$TARBALL"
228+
echo "::set-output name=shasum::$SHASUM"
229+
230+
- name: upload tarball
231+
uses: softprops/action-gh-release@v1
232+
with:
233+
draft: true
234+
files: |
235+
${{ steps.archive.outputs.tarball }}
236+
${{ steps.archive.outputs.shasum }}

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ full changeset diff at the end of each section.
1515
Current Trunk
1616
-------------
1717

18+
v117
19+
----
20+
21+
- Add a WebAssembly build to release (#6351)
22+
- Add Linux aarch64 build to release (#6334).
23+
- The text format for tuple instructions now requires immediates. For example,
24+
to make a tuple of two elements, use `tuple.make 2` (#6169) (#6172) (#6170).
25+
- The text format for `if` expressions now requires `then` and `else` to
26+
introduce the two branch arms, matching the spec (#6201).
27+
- Fuzzer: Remove --emit-js-shell logic and reuse fuzz_shell.js instead (#6310).
28+
- [EH] Add --experimental-new-eh option to wasm-opt (#6270) (#6210).
29+
- Add StringLowering pass, from stringref to imported-strings (#6271).
30+
- C API: Add BinaryenFunctionAppendVar (#6213).
31+
- Add J2CL optimization pass (#6151).
32+
- Add no-inline IR annotation, and passes to set it based on function name
33+
(#6146).
34+
- C API: Add BinaryenTableGetType and BinaryenTableSetType (#6137).
35+
- Add an Unsubtyping optimization (#5982).
36+
- Compute full transitive closure in GlobalEffects (#5992).
37+
- Add passes to finalize or unfinalize types (#5944).
38+
- Add a tuple optimization pass (#5937).
39+
1840
v116
1941
----
2042

CMakeLists.txt

+49-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.10.2)
77
# to reduce this for compatability with emsdk.
88
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
99

10-
project(binaryen LANGUAGES C CXX VERSION 116)
10+
project(binaryen LANGUAGES C CXX VERSION 117)
1111
include(GNUInstallDirs)
1212

1313
# The C++ standard whose features are required to build Binaryen.
@@ -46,9 +46,15 @@ option(BUILD_EMSCRIPTEN_TOOLS_ONLY "Build only tools needed by emscripten" OFF)
4646
# Turn this on to build binaryen.js as ES5, with additional compatibility configuration for js_of_ocaml.
4747
option(JS_OF_OCAML "Build binaryen.js for js_of_ocaml" OFF)
4848

49+
# Turn this on to compile binaryen toolchain utilities for the browser.
50+
option(BUILD_FOR_BROWSER "Build binaryen toolchain utilities for the browser" OFF)
51+
4952
# Turn this on to use the Wasm EH feature instead of emscripten EH in the wasm/BinaryenJS builds
5053
option(EMSCRIPTEN_ENABLE_WASM_EH "Enable Wasm EH feature in emscripten build" OFF)
5154

55+
# Turn this on to use pthreads feature in the wasm/BinaryenJS builds
56+
option(EMSCRIPTEN_ENABLE_PTHREADS "Enable pthreads in emscripten build" OFF)
57+
5258
# For git users, attempt to generate a more useful version string
5359
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
5460
find_package(Git QUIET REQUIRED)
@@ -280,6 +286,11 @@ else()
280286
add_compile_flag("-Wimplicit-fallthrough")
281287
add_compile_flag("-Wnon-virtual-dtor")
282288

289+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
290+
# Google style requires this, so make sure we compile cleanly with it.
291+
add_compile_flag("-Wctad-maybe-unsupported")
292+
endif()
293+
283294
if(WIN32)
284295
add_compile_flag("-D_GNU_SOURCE")
285296
add_compile_flag("-D__STDC_FORMAT_MACROS")
@@ -319,7 +330,6 @@ if(EMSCRIPTEN)
319330
endif()
320331

321332
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
322-
add_link_flag("-sSINGLE_FILE")
323333
# Extra check that cmake has set -O3 in its release flags.
324334
# This is really as an assertion that cmake is behaving as we expect.
325335
if(NOT CMAKE_CXX_FLAGS_RELEASE_INIT MATCHES "-O3")
@@ -328,17 +338,42 @@ if(EMSCRIPTEN)
328338
endif()
329339

330340
add_link_flag("-sALLOW_MEMORY_GROWTH")
341+
add_link_flag("-sSTACK_SIZE=5MB")
331342
if(EMSCRIPTEN_ENABLE_WASM_EH)
332343
add_compile_flag("-fwasm-exceptions")
333344
else()
334345
add_compile_flag("-sDISABLE_EXCEPTION_CATCHING=0")
335346
add_link_flag("-sDISABLE_EXCEPTION_CATCHING=0")
336347
endif()
337-
# make the tools immediately usable on Node.js
338-
add_link_flag("-sNODERAWFS")
339-
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
340-
add_nondebug_compile_flag("-flto")
341-
endif()
348+
if(EMSCRIPTEN_ENABLE_PTHREADS)
349+
add_compile_flag("-pthread")
350+
add_link_flag("-pthread")
351+
# Use mimalloc to avoid a 5x slowdown:
352+
# https://github.com/emscripten-core/emscripten/issues/15727#issuecomment-1960295018
353+
add_link_flag("-sMALLOC=mimalloc")
354+
# Disable the warning on pthreads+memory growth (we are not much affected by
355+
# it as there is little wasm-JS transfer of data, almost all work is inside
356+
# the wasm).
357+
add_link_flag("-Wno-pthreads-mem-growth")
358+
endif()
359+
# In the browser, there is no natural place to provide commandline arguments
360+
# for a commandline tool, so let the user run the main entry point themselves
361+
# and pass in the arguments there.
362+
if(BUILD_FOR_BROWSER)
363+
add_link_flag("-sENVIRONMENT=web,worker")
364+
add_link_flag("-sINVOKE_RUN=0")
365+
add_link_flag("-sEXPORTED_RUNTIME_METHODS=run,callMain,FS")
366+
add_link_flag("-sMODULARIZE")
367+
add_link_flag("-sEXPORT_ES6")
368+
add_link_flag("-sFILESYSTEM")
369+
add_link_flag("-sFORCE_FILESYSTEM")
370+
else()
371+
# On Node.js, make the tools immediately usable.
372+
add_link_flag("-sNODERAWFS")
373+
endif()
374+
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
375+
add_nondebug_compile_flag("-flto")
376+
endif()
342377

343378
# clang doesn't print colored diagnostics when invoked from Ninja
344379
if(UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
@@ -439,14 +474,16 @@ if(EMSCRIPTEN)
439474
target_link_libraries(binaryen_wasm "-sFILESYSTEM")
440475
target_link_libraries(binaryen_wasm "-sEXPORT_NAME=Binaryen")
441476
target_link_libraries(binaryen_wasm "-sNODERAWFS=0")
477+
# Emit a single file for convenience of people using binaryen.js as a library,
478+
# so they only need to distribute a single file.
479+
target_link_libraries(binaryen_wasm "-sSINGLE_FILE")
442480
target_link_libraries(binaryen_wasm "-sEXPORT_ES6")
443-
target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=allocateUTF8OnStack,stringToAscii")
481+
target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
444482
target_link_libraries(binaryen_wasm "-sEXPORTED_FUNCTIONS=_malloc,_free")
445483
target_link_libraries(binaryen_wasm "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
446484
target_link_libraries(binaryen_wasm "-msign-ext")
447485
target_link_libraries(binaryen_wasm "-mbulk-memory")
448486
target_link_libraries(binaryen_wasm optimized "--closure=1")
449-
target_link_libraries(binaryen_wasm optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6\"")
450487
# TODO: Fix closure warnings! (#5062)
451488
target_link_libraries(binaryen_wasm optimized "-Wno-error=closure")
452489
target_link_libraries(binaryen_wasm optimized "-flto")
@@ -472,14 +509,15 @@ if(EMSCRIPTEN)
472509
target_link_libraries(binaryen_js "-sFILESYSTEM=1")
473510
endif()
474511
target_link_libraries(binaryen_js "-sNODERAWFS=0")
512+
target_link_libraries(binaryen_js "-sSINGLE_FILE")
475513
target_link_libraries(binaryen_js "-sEXPORT_NAME=Binaryen")
476514
# Currently, js_of_ocaml can only process ES5 code
477515
if(JS_OF_OCAML)
478516
target_link_libraries(binaryen_js "-sEXPORT_ES6=0")
479517
else()
480518
target_link_libraries(binaryen_js "-sEXPORT_ES6=1")
481519
endif()
482-
target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=allocateUTF8OnStack,stringToAscii")
520+
target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
483521
target_link_libraries(binaryen_js "-sEXPORTED_FUNCTIONS=_malloc,_free")
484522
target_link_libraries(binaryen_js "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
485523
# js_of_ocaml needs a specified variable with special comment to provide the library to consumers
@@ -489,9 +527,7 @@ if(EMSCRIPTEN)
489527
target_link_libraries(binaryen_js optimized "--closure=1")
490528
# Currently, js_of_ocaml can only process ES5 code
491529
if(JS_OF_OCAML)
492-
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT5\"")
493-
else()
494-
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6\"")
530+
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_out=ECMASCRIPT5\"")
495531
endif()
496532
# TODO: Fix closure warnings! (#5062)
497533
target_link_libraries(binaryen_js optimized "-Wno-error=closure")

0 commit comments

Comments
 (0)