emscripten: 2.0.10 -> 2.0.27

This commit is contained in:
Yureka 2021-08-07 09:45:26 +02:00
parent d6869f3236
commit 691464d120
6 changed files with 1606 additions and 157 deletions

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

@ -4580,7 +4580,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 { });