nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 cmake,
5 python3,
6 fetchFromGitHub,
7 fetchpatch2,
8 emscripten,
9 gtest,
10 lit,
11 nodejs,
12 filecheck,
13}:
14let
15 testsuite = fetchFromGitHub {
16 owner = "WebAssembly";
17 repo = "testsuite";
18 rev = "4b24564c844e3d34bf46dfcb3c774ee5163e31cc";
19 hash = "sha256-8VirKLRro0iST58Rfg17u4tTO57KNC/7F/NB43dZ7w4=";
20 };
21in
22stdenv.mkDerivation rec {
23 pname = "binaryen";
24 version = "125";
25
26 src = fetchFromGitHub {
27 owner = "WebAssembly";
28 repo = "binaryen";
29 rev = "version_${version}";
30 hash = "sha256-QG8ZhvjcTbhIfYkVfrjxd97v9KaG/A8jO69rPg99/ME=";
31 };
32
33 patches = [
34 # TODO: remove at next release
35 # fix build on aarch64/riscv64 with gcc15 but bug exists on all platforms.
36 (fetchpatch2 {
37 name = "fix-uninitialized-small-vector.patch";
38 # https://github.com/WebAssembly/binaryen/pull/8094
39 url = "https://github.com/WebAssembly/binaryen/commit/3ff3762bf7c83edcdfccad522de640f2b0928ae2.patch?full_index=1";
40 hash = "sha256-lhrXQJAaQ/4ofnpyVqhD08IuDxPRc7UPyZ8DoCfM9NE=";
41 })
42 ];
43
44 nativeBuildInputs = [
45 cmake
46 python3
47 ];
48
49 strictDeps = true;
50
51 preConfigure = ''
52 if [ $doCheck -eq 1 ]; then
53 sed -i '/gtest/d' third_party/CMakeLists.txt
54 rmdir test/spec/testsuite
55 ln -s ${testsuite} test/spec/testsuite
56 else
57 cmakeFlagsArray=($cmakeFlagsArray -DBUILD_TESTS=0)
58 fi
59 '';
60
61 nativeCheckInputs = [
62 lit
63 nodejs
64 filecheck
65 ];
66 checkInputs = [ gtest ];
67 checkPhase = ''
68 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib python3 ../check.py $tests
69 '';
70
71 tests = [
72 "version"
73 "wasm-opt"
74 "wasm-dis"
75 "crash"
76 "dylink"
77 "ctor-eval"
78 "wasm-metadce"
79 "wasm-reduce"
80 "spec"
81 "lld"
82 "wasm2js"
83 # "unit" # fails on test.unit.test_cluster_fuzz.ClusterFuzz
84 # "binaryenjs" "binaryenjs_wasm" # not building this
85 # "lit" # fails on d8/fuzz_shell*
86 "gtest"
87 ]
88 ++ lib.optionals stdenv.hostPlatform.isLinux [
89 "example"
90 "validator"
91 ];
92
93 doCheck = (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin);
94
95 meta = {
96 homepage = "https://github.com/WebAssembly/binaryen";
97 description = "Compiler infrastructure and toolchain library for WebAssembly, in C++";
98 platforms = lib.platforms.all;
99 maintainers = with lib.maintainers; [
100 asppsa
101 willcohen
102 ];
103 license = lib.licenses.asl20;
104 };
105 passthru.tests = { inherit emscripten; };
106}