1{ lib, stdenv, cmake, python3, fetchFromGitHub, fetchpatch, emscripten,
2 gtest, lit, nodejs, filecheck
3}:
4
5stdenv.mkDerivation rec {
6 pname = "binaryen";
7 version = "116";
8
9 src = fetchFromGitHub {
10 owner = "WebAssembly";
11 repo = "binaryen";
12 rev = "version_${version}";
13 hash = "sha256-gMwbWiP+YDCVafQMBWhTuJGWmkYtnhEdn/oofKaUT08=";
14 };
15
16 # FIXME: remove for next release
17 patches = [
18 (fetchpatch {
19 name = "nodejs-20.patch";
20 url = "https://github.com/WebAssembly/binaryen/commit/889422e0c92552ff484659f9b41e777ba7ab35c1.patch";
21 hash = "sha256-acM8mytL9nhm4np9tpUbd1X0wJ7y308HV2fvgcAW1lY=";
22 })
23
24 # Fix fmin tests on gcc-13: https://github.com/WebAssembly/binaryen/pull/5994
25 (fetchpatch {
26 name = "gcc-13.patch";
27 url = "https://github.com/WebAssembly/binaryen/commit/1e17dfb695a19d5d41f1f88411fbcbc5f2408c8f.patch";
28 hash = "sha256-5JZh15CXkg5XdTG8eRJXPwO+zmymYeFjKbHutRPTmlU=";
29 })
30 ];
31
32 nativeBuildInputs = [ cmake python3 ];
33
34 preConfigure = ''
35 if [ $doCheck -eq 1 ]; then
36 sed -i '/googletest/d' third_party/CMakeLists.txt
37 else
38 cmakeFlagsArray=($cmakeFlagsArray -DBUILD_TESTS=0)
39 fi
40 '';
41
42 nativeCheckInputs = [ gtest lit nodejs filecheck ];
43 checkPhase = ''
44 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib python3 ../check.py $tests
45 '';
46
47 tests = [
48 "version" "wasm-opt" "wasm-dis"
49 "crash" "dylink" "ctor-eval"
50 "wasm-metadce" "wasm-reduce" "spec"
51 "lld" "wasm2js" "validator"
52 "example" "unit"
53 # "binaryenjs" "binaryenjs_wasm" # not building this
54 "lit" "gtest"
55 ];
56 doCheck = stdenv.isLinux;
57
58 meta = with lib; {
59 homepage = "https://github.com/WebAssembly/binaryen";
60 description = "Compiler infrastructure and toolchain library for WebAssembly, in C++";
61 platforms = platforms.all;
62 maintainers = with maintainers; [ asppsa ];
63 license = licenses.asl20;
64 };
65
66 passthru.tests = {
67 inherit emscripten;
68 };
69}