Skip to content

Commit 96b1d29

Browse files
committed
Merge branch 'main' into wasm_split_fuzz_fix
2 parents 97986a6 + c6a5e65 commit 96b1d29

355 files changed

Lines changed: 20331 additions & 13552 deletions

File tree

Some content is hidden

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

.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
sudo chmod +x llvm.sh
3939
sudo ./llvm.sh ${LLVM_VERSION}
4040
sudo apt-get install clang-format clang-format-${LLVM_VERSION} clang-tidy-${LLVM_VERSION}
41-
- run: flake8
4241
- run: ruff check
4342
- run: ./scripts/clang-format-diff.sh
4443
- name: clang-tidy
@@ -219,19 +218,30 @@ jobs:
219218
- name: test
220219
run: python check.py --binaryen-bin=out/bin
221220

222-
# Build with gcc 6.3 and run tests on Alpine Linux (inside chroot).
221+
# Run tests on Alpine Linux, which we use to make our release builds.
223222
# Note: Alpine uses musl libc.
224-
# Keep in sync with build_release.yml
223+
# Keep in sync with create_release.yml. The only difference is that here we
224+
# do not have the "archive" and "upload tarball" jobs.
225225
build-alpine:
226226
name: alpine
227-
runs-on: ubuntu-24.04-arm
227+
runs-on: ${{ matrix.os }}
228+
strategy:
229+
matrix:
230+
os: [ubuntu-latest, ubuntu-24.04-arm]
228231
steps:
232+
- uses: actions/setup-python@v5
233+
with:
234+
python-version: '3.x'
229235
- uses: actions/checkout@v4
230236
with:
231237
submodules: true
238+
232239
- name: start docker
233240
run: |
234-
docker run -w /src -dit --platform=linux/arm64 --name alpine -v $PWD:/src node:lts-alpine
241+
if [[ "${{ matrix.docker_platform }}" == "ubuntu-24.04-arm" ]]; then
242+
platform="--platform=linux/arm64"
243+
fi
244+
docker run -w /src -dit $platform --name alpine -v $PWD:/src node:lts-alpine
235245
echo 'docker exec alpine "$@";' > ./alpine.sh
236246
chmod +x ./alpine.sh
237247
@@ -248,8 +258,11 @@ jobs:
248258
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
249259

250260
- name: cmake
261+
# Build with an 8MB stack size, as otherwise Alpine/musl's default stack
262+
# size for pthreads is tiny,
263+
# https://github.com/WebAssembly/binaryen/issues/8594
251264
run: |
252-
./alpine.sh cmake . -G Ninja -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_CXX_FLAGS="-static" -DCMAKE_C_FLAGS="-static" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIB=ON -DBUILD_MIMALLOC=ON -DCMAKE_INSTALL_PREFIX=install
265+
./alpine.sh cmake . -G Ninja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_C_FLAGS="-static" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-z,stack-size=8388608" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIB=ON -DBUILD_MIMALLOC=ON -DCMAKE_INSTALL_PREFIX=install
253266
254267
- name: build
255268
run: |
@@ -346,23 +359,20 @@ jobs:
346359
- name: install ninja
347360
run: sudo apt-get install ninja-build
348361
- name: emsdk install
349-
run: |
350-
mkdir $HOME/emsdk
351-
git clone --depth 1 https://github.com/emscripten-core/emsdk.git $HOME/emsdk
352-
$HOME/emsdk/emsdk update-tags
353-
$HOME/emsdk/emsdk install tot
354-
$HOME/emsdk/emsdk activate tot
362+
uses: emscripten-core/setup-emsdk@v15
363+
with:
364+
version: tot
355365
- name: override emscripten repository
356366
if: ${{ env.EMSCRIPTEN_REPO != '' }}
357367
run: |
358-
$HOME/emsdk/emsdk install emscripten-main-64bit \
368+
$EMSDK/emsdk install emscripten-main-64bit \
359369
--override-repository emscripten-main-64bit@$EMSCRIPTEN_REPO
360-
$HOME/emsdk/emsdk activate emscripten-main-64bit
370+
$EMSDK/emsdk activate emscripten-main-64bit
361371
- name: update path
362-
run: echo "PATH=$PATH:$HOME/emsdk" >> $GITHUB_ENV
372+
run: echo "PATH=$PATH:$EMSDK" >> $GITHUB_ENV
363373
- name: emcc-tests
364374
run: |
365-
source $HOME/emsdk/emsdk_env.sh
375+
source $EMSDK/emsdk_env.sh
366376
./scripts/emcc-tests.sh
367377
368378
# Windows + gcc needs work before the tests will run, so just test the compile
@@ -383,40 +393,6 @@ jobs:
383393
- name: build
384394
run: cmake --build out
385395

386-
# Duplicates build-asan. Please keep in sync
387-
build-cxx20:
388-
name: c++20
389-
# Make sure we can still build on older Ubuntu
390-
runs-on: ubuntu-22.04
391-
env:
392-
CC: "gcc"
393-
CXX: "g++"
394-
steps:
395-
- uses: actions/setup-python@v5
396-
with:
397-
python-version: '3.x'
398-
- uses: actions/checkout@v4
399-
with:
400-
submodules: true
401-
- name: install ninja
402-
run: sudo apt-get install ninja-build
403-
- name: install v8
404-
run: |
405-
npm install jsvu -g
406-
jsvu --os=default --engines=v8
407-
- name: install Python dev dependencies
408-
run: pip3 install -r requirements-dev.txt
409-
- name: cmake
410-
run: |
411-
mkdir -p out
412-
cmake -S . -B out -G Ninja -DCMAKE_INSTALL_PREFIX=out/install -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20
413-
- name: build
414-
run: cmake --build out
415-
- name: test
416-
run: |
417-
python check.py --binaryen-bin=out/bin lit
418-
python check.py --binaryen-bin=out/bin gtest
419-
420396
# Ensures we can build in no-asserts mode (just building).
421397
build-noasserts:
422398
name: noasserts

.github/workflows/create_release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
${{ steps.archive-arm64.outputs.SHASUM }}
109109
110110
# Build with gcc 6.3 and run tests on Alpine Linux (inside chroot).
111+
# Keep in sync with ci.yml.
111112
# Note: Alpine uses musl libc.
112113
build-alpine:
113114
name: alpine
@@ -145,8 +146,11 @@ jobs:
145146
run: ./alpine.sh pip3 install --break-system-packages -r requirements-dev.txt
146147

147148
- name: cmake
149+
# Build with an 8MB stack size, as otherwise Alpine/musl's default stack
150+
# size for pthreads is tiny,
151+
# https://github.com/WebAssembly/binaryen/issues/8594
148152
run: |
149-
./alpine.sh cmake . -G Ninja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_C_FLAGS="-static" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIB=ON -DBUILD_MIMALLOC=ON -DCMAKE_INSTALL_PREFIX=install
153+
./alpine.sh cmake . -G Ninja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_C_FLAGS="-static" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-z,stack-size=8388608" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIB=ON -DBUILD_MIMALLOC=ON -DCMAKE_INSTALL_PREFIX=install
150154
151155
- name: build
152156
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ CMakeUserPresets.json
6161

6262
# files related to clangd cache
6363
.cache/*
64+
65+
.venv/

.ruff.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
target-version = "py310"
2+
preview = true
23

34
exclude = [
45
'third_party',
56
'test/lit/lit.cfg.py',
67
'test/spec/testsuite',
78
]
89

10+
[lint.pylint]
11+
max-locals = 30
12+
max-positional-args = 7
13+
14+
[lint.per-file-ignores]
15+
"test/**.py" = ["PLR6301", "PLW1514", "PLR0914"]
16+
917
[lint]
1018
select = [
1119
"ARG",
1220
"ASYNC",
1321
"B",
22+
"D",
1423
"C4",
1524
"C90",
1625
"COM",
@@ -27,17 +36,29 @@ select = [
2736

2837
ignore = [
2938
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
39+
"D100", # https://docs.astral.sh/ruff/rules/undocumented-public-module/
40+
"D101", # https://docs.astral.sh/ruff/rules/undocumented-public-class/
41+
"D102", # https://docs.astral.sh/ruff/rules/undocumented-public-method/
42+
"D103", # https://docs.astral.sh/ruff/rules/undocumented-public-function/
43+
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
44+
"D105", # https://docs.astral.sh/ruff/rules/undocumented-magic-method/
45+
"D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
46+
"D213", # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
47+
"D107", # https://docs.astral.sh/ruff/rules/undocumented-public-init/
3048
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default/
3149
"B011", # https://docs.astral.sh/ruff/rules/assert-false/
3250
"B023", # https://docs.astral.sh/ruff/rules/function-uses-loop-variable/
3351
"E501", # https://docs.astral.sh/ruff/rules/line-too-long/
3452
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name/
3553
"PERF401", # https://docs.astral.sh/ruff/rules/manual-list-comprehension/
54+
"PLR0904", # https://docs.astral.sh/ruff/rules/too-many-public-methods/
3655
"PLR0912", # https://docs.astral.sh/ruff/rules/too-many-branches/
3756
"PLR0913", # https://docs.astral.sh/ruff/rules/too-many-arguments/
3857
"PLR0915", # https://docs.astral.sh/ruff/rules/too-many-statements/
58+
"PLR1702", # https://docs.astral.sh/ruff/rules/too-many-nested-blocks/
3959
"PLR2004", # https://docs.astral.sh/ruff/rules/magic-value-comparison/
4060
"PLW0603", # https://docs.astral.sh/ruff/rules/global-statement/
4161
"PLW1510", # https://docs.astral.sh/ruff/rules/subprocess-run-without-check/
4262
"PLW2901", # https://docs.astral.sh/ruff/rules/redefined-loop-name/
63+
"PLW1514", # https://docs.astral.sh/ruff/rules/unspecified-encoding/
4364
]

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,34 @@ full changeset diff at the end of each section.
1515
Current Trunk
1616
-------------
1717

18-
- Add support for non-nullable table types and initialization expressions for
18+
- Rename `MemorySegment` functions to `DataSegment` in the c and js apis
19+
- Rename `BinaryenGetNumMemorySegments` to `BinaryenGetNumDataSegments` in c api.
20+
- Rename `BinaryenGetMemorySegmentByteOffset` to `BinaryenGetDataSegmentByteOffset` in c api.
21+
- Rename `BinaryenGetMemorySegmentByteLength` to `BinaryenGetDataSegmentByteLength` in c api.
22+
- Rename `BinaryenGetMemorySegmentPassive` to `BinaryenGetDataSegmentPassive` in c api.
23+
- Rename `BinaryenCopyMemorySegmentData` to `BinaryenCopyDataSegmentData` in c api.
24+
- Rename `module.getNumMemorySegments` to `module.getNumDataSegments` in js api.
25+
- Rename `module.getMemorySegmentInfo` to `module.getDataSegmentInfo` in js api.
26+
27+
v129
28+
----
29+
30+
- Add a `BinaryenDataSegmentRef` type to the C API. (#8286)
31+
- Add `BinaryenGetDataSegment` and `BinaryenGetDataSegmentByIndex` to the C API, which allow looking up a data segment by name or index.
32+
- Add `BinaryenDataSegmentGetName` to the C API, which allows looking up a data segment's name.
33+
- Convert `BinaryenGetMemorySegmentByteOffset`, `BinaryenGetMemorySegmentByteLength`, `BinaryenGetMemorySegmentPassive` and `BinaryenCopyMemorySegmentData` to take a `BinaryenDataSegmentRef` instead of a name.
34+
- Add `module.getDataSegment`, `module.getDataSegmentByIndex` to the JS API, which allows looking up a data segment by name or index.
35+
- Convert `module.getMemorySegmentInfo` to take a data segment reference instead of a name, and return the name as part of the info.
36+
- Add support for non-nullable table types and initialization expressions for
1937
tables. This comes with a breaking change to C API: `BinaryenAddTable` takes
2038
an additional `BinaryenExpressionRef` parameter to provide an initialization
2139
expression. This may be set to NULL for tables without an initializer. In JS
2240
this parameter is optional and so is not breaking. (#8405)
41+
- [multibyte] Add multibyte array store and load instructions. (#8059, #8504)
42+
- MinifyImportsAndExports now has a new output format using JSON. This was
43+
changed while fixing bugs with colliding module names (to avoid two breaking
44+
changes to the output). (#8550)
45+
- Update from C++17 to C++20 (#8218)
2346

2447
v128
2548
----

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ cmake_minimum_required(VERSION 3.16.3)
55
# Needed for C++17 (std::path)
66
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
77

8-
project(binaryen LANGUAGES C CXX VERSION 128)
8+
project(binaryen LANGUAGES C CXX VERSION 129)
99
include(GNUInstallDirs)
1010

1111
# The C++ standard whose features are required to build Binaryen.
1212
# Keep in sync with scripts/test/shared.py cxx_standard
1313
# The if condition allows embedding in a project with a higher default C++ standard set
14-
set(REQUIRED_CXX_STANDARD 17)
14+
set(REQUIRED_CXX_STANDARD 20)
1515
if(NOT CMAKE_CXX_STANDARD)
1616
set(CMAKE_CXX_STANDARD ${REQUIRED_CXX_STANDARD})
1717
elseif(CMAKE_CXX_STANDARD LESS ${REQUIRED_CXX_STANDARD})
@@ -550,8 +550,8 @@ if(EMSCRIPTEN)
550550
if(JS_OF_OCAML)
551551
# js_of_ocaml needs a specified variable with special comment to provide the library to consumer
552552
target_link_libraries(binaryen_js PRIVATE "--extern-pre-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.jsoo-extern-pre.js")
553-
# Currently, js_of_ocaml can only process ES5 code
554-
target_link_libraries(binaryen_js PRIVATE optimized "--closure-args=\"--language_out=ECMASCRIPT5\"")
553+
# js_of_ocaml does not support top level await
554+
target_link_libraries(binaryen_js PRIVATE "-sWASM_ASYNC_COMPILATION=0")
555555
else()
556556
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_ES6")
557557
endif()

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ After that you can build with CMake:
412412
cmake . && make
413413
```
414414

415-
A C++17 compiler is required. On macOS, you need to install `cmake`, for example, via `brew install cmake`. Note that you can also use `ninja` as your generator: `cmake -G Ninja . && ninja`.
415+
A C++20 compiler is required. On macOS, you need to install `cmake`, for
416+
example, via `brew install cmake`. Note that you can also use `ninja` as your
417+
generator: `cmake -G Ninja . && ninja`.
416418

417419
To avoid the gtest dependency, you can pass `-DBUILD_TESTS=OFF` to cmake.
418420

check.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from multiprocessing.pool import ThreadPool
2626
from pathlib import Path
2727

28-
from scripts.test import binaryenjs, lld, shared, support, wasm2js, wasm_opt
28+
from scripts.test import binaryenjs, finalize, shared, support, wasm2js, wasm_opt
2929

3030
assert sys.version_info >= (3, 10), 'requires Python 3.10'
3131

@@ -265,7 +265,9 @@ def run_one_spec_test(wast: Path, stdout=None):
265265

266266

267267
def run_spec_test_with_wrapped_stdout(wast: Path):
268-
"""Return (bool, str) where the first element is whether the test was
268+
"""Run a single spec test while capturing stdout.
269+
270+
Return (bool, str) where the first element is whether the test was
269271
successful and the second is the combined stdout and stderr of the test.
270272
"""
271273
out = io.StringIO()
@@ -436,7 +438,7 @@ def wrapper(*args, **kwargs):
436438
'wasm-metadce': run_wasm_metadce_tests,
437439
'wasm-reduce': run_wasm_reduce_tests,
438440
'spec': run_spec_tests,
439-
'lld': lld.test_wasm_emscripten_finalize,
441+
'finalize': finalize.test_wasm_emscripten_finalize,
440442
'wasm2js': wasm2js.test_wasm2js,
441443
'validator': run_validator_tests,
442444
'example': run_example_tests,

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# These requirements are only needed for developers who want to run the test
2-
# suite or flake8, not for end users.
2+
# suite, or CI checks, not for end users.
33

44
# Install with `pip3 install -r requirements-dev.txt`
55

6-
flake8==7.3.0
76
ruff==0.14.1
87
filecheck==0.0.22
98
lit==0.11.0.post1

0 commit comments

Comments
 (0)