Skip to content

Commit

Permalink
Merge tag 'version_117' into fwasm-exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jun 10, 2024
2 parents 22a248b + c62a0c9 commit 4e0a009
Show file tree
Hide file tree
Showing 948 changed files with 102,931 additions and 65,521 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ BinPackParameters: false
Language: JavaScript
DisableFormat: true
---
Language: Json
BasedOnStyle: LLVM
---
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,20 @@ jobs:
- uses: actions/checkout@v1
with:
submodules: true
- name: install clang
uses: egor-tensin/setup-clang@v1
with:
# Clang 15 seems to avoid asan flakes that 14 has (#6116).
version: 15
platform: x64
- name: install ninja
run: sudo apt-get install ninja-build
- name: install Python dev dependencies
run: pip3 install -r requirements-dev.txt
- name: cmake
run: |
mkdir -p out
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"
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"
- name: build
run: cmake --build out
- name: test
Expand Down Expand Up @@ -189,7 +195,7 @@ jobs:
./alpine.sh apk add build-base cmake git python3 py3-pip clang ninja
- name: install python dev dependencies
run: ./alpine.sh pip3 install -r requirements-dev.txt
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt

- name: cmake
run: |
Expand Down Expand Up @@ -349,7 +355,8 @@ jobs:
# Duplicates build-asan. Please keep in sync
build-cxx20:
name: c++20
runs-on: ubuntu-latest
# Make sure we can still build on older Ubuntu
runs-on: ubuntu-20.04
env:
CC: "gcc"
CXX: "g++"
Expand Down
81 changes: 78 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,34 @@ jobs:
build-alpine:
name: alpine
runs-on: ubuntu-latest
strategy:
matrix:
docker_platform: [amd64, arm64]
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: matrix.docker_platform != 'amd64'

- name: start docker
run: |
docker run -w /src -dit --name alpine -v $PWD:/src node:lts-alpine
docker run -w /src -dit --platform=linux/${{ matrix.docker_platform }} --name alpine -v $PWD:/src node:lts-alpine
echo 'docker exec alpine "$@";' > ./alpine.sh
chmod +x ./alpine.sh
- name: install packages
run: |
./alpine.sh apk update
./alpine.sh apk add build-base cmake git python3 clang ninja py3-pip
- name: install python dev dependencies
run: ./alpine.sh pip3 install -r requirements-dev.txt
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt

- name: cmake
run: |
Expand All @@ -142,7 +150,8 @@ jobs:
id: archive
run: |
VERSION=$GITHUB_REF_NAME
PKGNAME="binaryen-$VERSION-x86_64-linux"
ARCH=$(./alpine.sh uname -m)
PKGNAME="binaryen-$VERSION-$ARCH-linux"
TARBALL=$PKGNAME.tar.gz
SHASUM=$PKGNAME.tar.gz.sha256
./alpine.sh find install/ -type f -perm -u=x -exec strip {} +
Expand All @@ -159,3 +168,69 @@ jobs:
files: |
${{ steps.archive.outputs.tarball }}
${{ steps.archive.outputs.shasum }}
# Build using Emscripten to JavaScript+WebAssembly.
build-node:
name: node
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v1
with:
submodules: true
- name: install ninja
run: sudo apt-get install ninja-build
- name: emsdk install
run: |
mkdir $HOME/emsdk
git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk
$HOME/emsdk/emsdk update-tags
$HOME/emsdk/emsdk install tot
$HOME/emsdk/emsdk activate tot
- name: update path
run: echo "PATH=$PATH:$HOME/emsdk" >> $GITHUB_ENV

# Configure with wasm EH and pthreads for maximal performance.
- name: cmake
run: |
source $HOME/emsdk/emsdk_env.sh
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
# Build wasm-opt for now TODO add other tools as desired
- name: build
run: ninja -C out wasm-opt

# Minimal smoke test: roundtrip a file.
# TODO: Add more testing here, but the full test suite is overkill as there
# is a 0.5 second cost to each run of wasm-opt.js
- name: test
run: |
node out/bin/wasm-opt.js test/hello_world.wat --print > out/t.wat
diff test/hello_world.wat out/t.wat
- name: archive
id: archive
run: |
VERSION=$GITHUB_REF_NAME
PKGNAME="binaryen-$VERSION-node"
TARBALL=$PKGNAME.tar.gz
SHASUM=$PKGNAME.tar.gz.sha256
mkdir binaryen-$VERSION
cp out/bin/wasm-opt* binaryen-$VERSION/
tar -czf $TARBALL binaryen-$VERSION
cmake -E sha256sum $TARBALL > $SHASUM
echo "::set-output name=tarball::$TARBALL"
echo "::set-output name=shasum::$SHASUM"
- name: upload tarball
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
${{ steps.archive.outputs.tarball }}
${{ steps.archive.outputs.shasum }}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ full changeset diff at the end of each section.
Current Trunk
-------------

v117
----

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

v116
----

Expand Down
62 changes: 49 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.10.2)
# to reduce this for compatability with emsdk.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")

project(binaryen LANGUAGES C CXX VERSION 116)
project(binaryen LANGUAGES C CXX VERSION 117)
include(GNUInstallDirs)

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

# Turn this on to compile binaryen toolchain utilities for the browser.
option(BUILD_FOR_BROWSER "Build binaryen toolchain utilities for the browser" OFF)

# Turn this on to use the Wasm EH feature instead of emscripten EH in the wasm/BinaryenJS builds
option(EMSCRIPTEN_ENABLE_WASM_EH "Enable Wasm EH feature in emscripten build" OFF)

# Turn this on to use pthreads feature in the wasm/BinaryenJS builds
option(EMSCRIPTEN_ENABLE_PTHREADS "Enable pthreads in emscripten build" OFF)

# For git users, attempt to generate a more useful version string
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
find_package(Git QUIET REQUIRED)
Expand Down Expand Up @@ -280,6 +286,11 @@ else()
add_compile_flag("-Wimplicit-fallthrough")
add_compile_flag("-Wnon-virtual-dtor")

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Google style requires this, so make sure we compile cleanly with it.
add_compile_flag("-Wctad-maybe-unsupported")
endif()

if(WIN32)
add_compile_flag("-D_GNU_SOURCE")
add_compile_flag("-D__STDC_FORMAT_MACROS")
Expand Down Expand Up @@ -319,7 +330,6 @@ if(EMSCRIPTEN)
endif()

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

add_link_flag("-sALLOW_MEMORY_GROWTH")
add_link_flag("-sSTACK_SIZE=5MB")
if(EMSCRIPTEN_ENABLE_WASM_EH)
add_compile_flag("-fwasm-exceptions")
else()
add_compile_flag("-sDISABLE_EXCEPTION_CATCHING=0")
add_link_flag("-sDISABLE_EXCEPTION_CATCHING=0")
endif()
# make the tools immediately usable on Node.js
add_link_flag("-sNODERAWFS")
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
add_nondebug_compile_flag("-flto")
endif()
if(EMSCRIPTEN_ENABLE_PTHREADS)
add_compile_flag("-pthread")
add_link_flag("-pthread")
# Use mimalloc to avoid a 5x slowdown:
# https://github.com/emscripten-core/emscripten/issues/15727#issuecomment-1960295018
add_link_flag("-sMALLOC=mimalloc")
# Disable the warning on pthreads+memory growth (we are not much affected by
# it as there is little wasm-JS transfer of data, almost all work is inside
# the wasm).
add_link_flag("-Wno-pthreads-mem-growth")
endif()
# In the browser, there is no natural place to provide commandline arguments
# for a commandline tool, so let the user run the main entry point themselves
# and pass in the arguments there.
if(BUILD_FOR_BROWSER)
add_link_flag("-sENVIRONMENT=web,worker")
add_link_flag("-sINVOKE_RUN=0")
add_link_flag("-sEXPORTED_RUNTIME_METHODS=run,callMain,FS")
add_link_flag("-sMODULARIZE")
add_link_flag("-sEXPORT_ES6")
add_link_flag("-sFILESYSTEM")
add_link_flag("-sFORCE_FILESYSTEM")
else()
# On Node.js, make the tools immediately usable.
add_link_flag("-sNODERAWFS")
endif()
# in opt builds, LTO helps so much (>20%) it's worth slow compile times
add_nondebug_compile_flag("-flto")
endif()

# clang doesn't print colored diagnostics when invoked from Ninja
if(UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
Expand Down Expand Up @@ -439,14 +474,16 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_wasm "-sFILESYSTEM")
target_link_libraries(binaryen_wasm "-sEXPORT_NAME=Binaryen")
target_link_libraries(binaryen_wasm "-sNODERAWFS=0")
# Emit a single file for convenience of people using binaryen.js as a library,
# so they only need to distribute a single file.
target_link_libraries(binaryen_wasm "-sSINGLE_FILE")
target_link_libraries(binaryen_wasm "-sEXPORT_ES6")
target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=allocateUTF8OnStack,stringToAscii")
target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
target_link_libraries(binaryen_wasm "-sEXPORTED_FUNCTIONS=_malloc,_free")
target_link_libraries(binaryen_wasm "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
target_link_libraries(binaryen_wasm "-msign-ext")
target_link_libraries(binaryen_wasm "-mbulk-memory")
target_link_libraries(binaryen_wasm optimized "--closure=1")
target_link_libraries(binaryen_wasm optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6\"")
# TODO: Fix closure warnings! (#5062)
target_link_libraries(binaryen_wasm optimized "-Wno-error=closure")
target_link_libraries(binaryen_wasm optimized "-flto")
Expand All @@ -472,14 +509,15 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_js "-sFILESYSTEM=1")
endif()
target_link_libraries(binaryen_js "-sNODERAWFS=0")
target_link_libraries(binaryen_js "-sSINGLE_FILE")
target_link_libraries(binaryen_js "-sEXPORT_NAME=Binaryen")
# Currently, js_of_ocaml can only process ES5 code
if(JS_OF_OCAML)
target_link_libraries(binaryen_js "-sEXPORT_ES6=0")
else()
target_link_libraries(binaryen_js "-sEXPORT_ES6=1")
endif()
target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=allocateUTF8OnStack,stringToAscii")
target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
target_link_libraries(binaryen_js "-sEXPORTED_FUNCTIONS=_malloc,_free")
target_link_libraries(binaryen_js "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
# js_of_ocaml needs a specified variable with special comment to provide the library to consumers
Expand All @@ -489,9 +527,7 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_js optimized "--closure=1")
# Currently, js_of_ocaml can only process ES5 code
if(JS_OF_OCAML)
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT5\"")
else()
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_in=ECMASCRIPT6 --language_out=ECMASCRIPT6\"")
target_link_libraries(binaryen_js optimized "--closure-args=\"--language_out=ECMASCRIPT5\"")
endif()
# TODO: Fix closure warnings! (#5062)
target_link_libraries(binaryen_js optimized "-Wno-error=closure")
Expand Down
Loading

0 comments on commit 4e0a009

Please sign in to comment.