Merge pull request #133217 from yu-re-ka/feature/emscripten-2-0-26

emscripten: 2.0.10 -> 2.0.26
This commit is contained in:
Michael Raskin 2021-08-26 23:08:02 +00:00 committed by GitHub
commit 7c3be098d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1640 additions and 174 deletions

View file

@ -2,13 +2,13 @@
stdenv.mkDerivation rec {
pname = "binaryen";
version = "99";
version = "101";
src = fetchFromGitHub {
owner = "WebAssembly";
repo = "binaryen";
rev = "version_${version}";
sha256 = "1a6ixxm1f8mrr9mn6a0pimajdzsdr4w1qhr92skxq67168vvc1ic";
sha256 = "sha256-rNiZQIQqNbc1P2A6UTn0dRHeT3BS+nv1o81aPaJy+5U=";
};
nativeBuildInputs = [ cmake python3 ];

View file

@ -0,0 +1,42 @@
From 67f54fde2b1683aae3800f7a86a4e507c1125be8 Mon Sep 17 00:00:00 2001
From: Yureka <yuka@yuka.dev>
Date: Sat, 7 Aug 2021 09:16:46 +0200
Subject: [PATCH] emulate clang 'sysroot + /include' logic
Authored-By: Alexander Khovansky <alex@khovansky.me>
Co-Authored-By: Yureka <yuka@yuka.dev>
Clang provided by nix patches out logic that appends 'sysroot + /include'
to the include path as well as automatic inclusion of libcxx includes (/include/c++/v1).
The patch below adds that logic back by introducing cflags emulating this behavior to emcc
invocations directly.
Important note: with non-nix clang, sysroot/include dir ends up being the last
in the include search order, right after the resource root.
Hence usage of -idirafter. Clang also documents an -isystem-after flag
but it doesn't appear to work
---
emcc.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/emcc.py b/emcc.py
index 999314afc..0e23c066c 100755
--- a/emcc.py
+++ b/emcc.py
@@ -759,7 +759,12 @@ def emsdk_ldflags(user_args):
def emsdk_cflags(user_args):
- cflags = ['--sysroot=' + shared.Cache.get_sysroot(absolute=True)]
+ cflags = [
+ '--sysroot=' + shared.Cache.get_sysroot(absolute=True),
+ '-resource-dir=@resourceDir@',
+ '-idirafter' + shared.Cache.get_sysroot(absolute=True) + os.path.join('/include'),
+ '-iwithsysroot' + os.path.join('/include','c++','v1')
+ ]
def array_contains_any_of(hay, needles):
for n in needles:
--
2.32.0

View file

@ -1,17 +1,17 @@
{ lib, stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
, jre, binaryen
, llvmPackages_11
, symlinkJoin, makeWrapper
, llvmPackages
, symlinkJoin, makeWrapper, substituteAll
, mkYarnModules
}:
stdenv.mkDerivation rec {
pname = "emscripten";
version = "2.0.10";
version = "2.0.27";
llvmEnv = symlinkJoin {
name = "emscripten-llvm-${version}";
paths = with llvmPackages_11; [ clang-unwrapped lld llvm ];
paths = with llvmPackages; [ clang-unwrapped clang-unwrapped.lib lld llvm ];
};
nodeModules = mkYarnModules {
@ -26,27 +26,32 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = "emscripten-core";
repo = "emscripten";
sha256 = "0jy4n1pykk9vkm5da9v3qsfrl6j7yhngcazh2792xxs6wzfcs9gk";
sha256 = "1dpfib2nmbvskqlaqw3kvaay69qpa7d155hd4w05c2xgmahmrd4n";
rev = version;
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ nodejs python3 ];
patches = [
(substituteAll {
src = ./0001-emulate-clang-sysroot-include-logic.patch;
resourceDir = "${llvmEnv}/lib/clang/${llvmPackages.release_version}/";
})
];
buildPhase = ''
runHook preBuild
patchShebangs .
# fixes cmake support
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py
# disables cache in user home, use installation directory instead
sed -i '/^def/!s/root_is_writable()/True/' tools/shared.py
sed -i '/^def/!s/root_is_writable()/True/' tools/config.py
sed -i "/^def check_sanity/a\\ return" tools/shared.py
# super ugly: monkeypatch to add sysroot/include to the include
# path because they are otherwise not part of Nix's clang.
sed -i "490a\\ '/include'," tools/shared.py
# required for wasm2c
ln -s ${nodeModules}/node_modules .
@ -66,19 +71,19 @@ stdenv.mkDerivation rec {
sed -i "s|^EMAR =.*|EMAR='$out/bin/emar'|" tools/shared.py
sed -i "s|^EMRANLIB =.*|EMRANLIB='$out/bin/emranlib'|" tools/shared.py
# The tests use the C compiler to compile generated C code,
# use the wrapped compiler
sed -i 's/shared.CLANG_CC/"cc"/' tests/runner.py
runHook postBuild
'';
installPhase = ''
runHook preInstall
appdir=$out/share/emscripten
mkdir -p $appdir
cp -r . $appdir
chmod -R +w $appdir
mkdir -p $out/bin
for b in em++ em-config emar embuilder.py emcc emcmake emconfigure emmake emranlib emrun emscons; do
for b in em++ em-config emar embuilder.py emcc emcmake emconfigure emmake emranlib emrun emscons emsize; do
makeWrapper $appdir/$b $out/bin/$b \
--set NODE_PATH ${nodeModules}/node_modules \
--set EM_EXCLUSIVE_CACHE_ACCESS 1 \
@ -107,6 +112,8 @@ stdenv.mkDerivation rec {
pushd $appdir
python tests/runner.py test_hello_world
popd
runHook postInstall
'';
meta = with lib; {

View file

@ -1,15 +1,21 @@
{
"name": "emscripten",
"version": "2.0.10",
"version": "2.0.26",
"private": true,
"devDependencies": {
"es-check": "^5.1.0",
"es-check": "^5.2.4",
"eslint": "^7.29.0",
"eslint-config-google": "^0.14.0",
"source-map": "0.5.7",
"ws": "~0.4.28"
},
"dependencies": {
"acorn": "7.3.1",
"google-closure-compiler": "20200920.0.0",
"html-minifier-terser": "5.0.2",
"source-map": "0.5.6",
"acorn": "8.4.1",
"google-closure-compiler": "20210601.0.0",
"html-minifier-terser": "5.1.1",
"wasm2c": "1.0.0"
},
"scripts": {
"lint": "eslint src/parseTools.js"
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -259,4 +259,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -274,4 +274,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -267,4 +267,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -264,4 +264,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -44,6 +44,10 @@ stdenv.mkDerivation rec {
libc++ is an implementation of the C++ standard library, targeting C++11,
C++14 and above.
'';
# https://github.com/NixOS/nixpkgs/pull/133217#issuecomment-895742807
broken = stdenv.isDarwin;
# "All of the code in libc++ is dual licensed under the MIT license and the
# UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ];

View file

@ -52,6 +52,20 @@ in stdenv.mkDerivation (rec {
patches = [
./gnu-install-dirs.patch
# Fix random compiler crashes: https://bugs.llvm.org/show_bug.cgi?id=50611
(fetchpatch {
url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/4764a4f8c920912a2bfd8b0eea57273acfe0d8a8/trunk/no-strict-aliasing-DwarfCompileUnit.patch";
sha256 = "18l6mrvm2vmwm77ckcnbjvh6ybvn72rhrb799d4qzwac4x2ifl7g";
stripLen = 1;
})
# Fix tests on non-x86 platforms: https://reviews.llvm.org/D107020
(fetchpatch {
url = "https://github.com/llvm/llvm-project/commit/5060224d9eed8b8359ed5090bb7c577b8575e9e7.patch";
sha256 = "1s2n3pqa11pmlifys1jkppmw858p5i64xszpc8ppc98middv19v1";
stripLen = 1;
})
] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
postPatch = optionalString stdenv.isDarwin ''

View file

@ -121,4 +121,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -122,4 +122,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -268,4 +268,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -267,4 +267,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -267,4 +267,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -264,4 +264,4 @@ let
};
});
in { inherit tools libraries; } // libraries // tools
in { inherit tools libraries release_version; } // libraries // tools

View file

@ -4593,7 +4593,9 @@ with pkgs;
choose = callPackage ../tools/text/choose { };
emscripten = callPackage ../development/compilers/emscripten { };
emscripten = callPackage ../development/compilers/emscripten {
llvmPackages = llvmPackages_13;
};
emscriptenPackages = recurseIntoAttrs (callPackage ./emscripten-packages.nix { });

View file

@ -10,12 +10,11 @@ rec {
stdenv = pkgs.emscriptenStdenv;
}).overrideDerivation
(old: {
nativeBuildInputs = [ autoreconfHook pkg-config ];
nativeBuildInputs = [ pkg-config cmake ];
propagatedBuildInputs = [ zlib ];
buildInputs = old.buildInputs ++ [ automake autoconf ];
configurePhase = ''
HOME=$TMPDIR
emconfigure ./configure --prefix=$out
emcmake cmake . $cmakeFlags -DCMAKE_INSTALL_PREFIX=$out -DCMAKE_INSTALL_INCLUDEDIR=$dev/include
'';
checkPhase = ''
echo "================= testing json_c using node ================="
@ -26,7 +25,7 @@ rec {
`pkg-config zlib --cflags` \
`pkg-config zlib --libs` \
-I . \
.libs/libjson-c.so \
libjson-c.a \
-o ./test1.js
echo "Using node to execute the test which basically outputs an error on stderr which we grep for"
@ -163,7 +162,7 @@ rec {
echo "Compiling a custom test"
set -x
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
libz.so.${old.version} -I . -o example.js
-L. libz.so.${old.version} -I . -o example.js
echo "Using node to execute the test"
${pkgs.nodejs}/bin/node ./example.js