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 { stdenv.mkDerivation rec {
pname = "binaryen"; pname = "binaryen";
version = "99"; version = "101";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "WebAssembly"; owner = "WebAssembly";
repo = "binaryen"; repo = "binaryen";
rev = "version_${version}"; rev = "version_${version}";
sha256 = "1a6ixxm1f8mrr9mn6a0pimajdzsdr4w1qhr92skxq67168vvc1ic"; sha256 = "sha256-rNiZQIQqNbc1P2A6UTn0dRHeT3BS+nv1o81aPaJy+5U=";
}; };
nativeBuildInputs = [ cmake python3 ]; 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 { lib, stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
, jre, binaryen , jre, binaryen
, llvmPackages_11 , llvmPackages
, symlinkJoin, makeWrapper , symlinkJoin, makeWrapper, substituteAll
, mkYarnModules , mkYarnModules
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "emscripten"; pname = "emscripten";
version = "2.0.10"; version = "2.0.27";
llvmEnv = symlinkJoin { llvmEnv = symlinkJoin {
name = "emscripten-llvm-${version}"; name = "emscripten-llvm-${version}";
paths = with llvmPackages_11; [ clang-unwrapped lld llvm ]; paths = with llvmPackages; [ clang-unwrapped clang-unwrapped.lib lld llvm ];
}; };
nodeModules = mkYarnModules { nodeModules = mkYarnModules {
@ -26,27 +26,32 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "emscripten-core"; owner = "emscripten-core";
repo = "emscripten"; repo = "emscripten";
sha256 = "0jy4n1pykk9vkm5da9v3qsfrl6j7yhngcazh2792xxs6wzfcs9gk"; sha256 = "1dpfib2nmbvskqlaqw3kvaay69qpa7d155hd4w05c2xgmahmrd4n";
rev = version; rev = version;
}; };
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
buildInputs = [ nodejs python3 ]; buildInputs = [ nodejs python3 ];
patches = [
(substituteAll {
src = ./0001-emulate-clang-sysroot-include-logic.patch;
resourceDir = "${llvmEnv}/lib/clang/${llvmPackages.release_version}/";
})
];
buildPhase = '' buildPhase = ''
runHook preBuild
patchShebangs . patchShebangs .
# fixes cmake support # fixes cmake support
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py 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 # 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 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 # required for wasm2c
ln -s ${nodeModules}/node_modules . 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|^EMAR =.*|EMAR='$out/bin/emar'|" tools/shared.py
sed -i "s|^EMRANLIB =.*|EMRANLIB='$out/bin/emranlib'|" 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, runHook postBuild
# use the wrapped compiler
sed -i 's/shared.CLANG_CC/"cc"/' tests/runner.py
''; '';
installPhase = '' installPhase = ''
runHook preInstall
appdir=$out/share/emscripten appdir=$out/share/emscripten
mkdir -p $appdir mkdir -p $appdir
cp -r . $appdir cp -r . $appdir
chmod -R +w $appdir chmod -R +w $appdir
mkdir -p $out/bin 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 \ makeWrapper $appdir/$b $out/bin/$b \
--set NODE_PATH ${nodeModules}/node_modules \ --set NODE_PATH ${nodeModules}/node_modules \
--set EM_EXCLUSIVE_CACHE_ACCESS 1 \ --set EM_EXCLUSIVE_CACHE_ACCESS 1 \
@ -107,6 +112,8 @@ stdenv.mkDerivation rec {
pushd $appdir pushd $appdir
python tests/runner.py test_hello_world python tests/runner.py test_hello_world
popd popd
runHook postInstall
''; '';
meta = with lib; { meta = with lib; {

View File

@ -1,15 +1,21 @@
{ {
"name": "emscripten", "name": "emscripten",
"version": "2.0.10", "version": "2.0.26",
"private": true,
"devDependencies": { "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" "ws": "~0.4.28"
}, },
"dependencies": { "dependencies": {
"acorn": "7.3.1", "acorn": "8.4.1",
"google-closure-compiler": "20200920.0.0", "google-closure-compiler": "20210601.0.0",
"html-minifier-terser": "5.0.2", "html-minifier-terser": "5.1.1",
"source-map": "0.5.6",
"wasm2c": "1.0.0" "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, libc++ is an implementation of the C++ standard library, targeting C++11,
C++14 and above. 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 # "All of the code in libc++ is dual licensed under the MIT license and the
# UIUC License (a BSD-like license)": # UIUC License (a BSD-like license)":
license = with lib.licenses; [ mit ncsa ]; license = with lib.licenses; [ mit ncsa ];

View File

@ -52,6 +52,20 @@ in stdenv.mkDerivation (rec {
patches = [ patches = [
./gnu-install-dirs.patch ./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; ] ++ lib.optional enablePolly ./gnu-install-dirs-polly.patch;
postPatch = optionalString stdenv.isDarwin '' 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 { }; choose = callPackage ../tools/text/choose { };
emscripten = callPackage ../development/compilers/emscripten { }; emscripten = callPackage ../development/compilers/emscripten {
llvmPackages = llvmPackages_13;
};
emscriptenPackages = recurseIntoAttrs (callPackage ./emscripten-packages.nix { }); emscriptenPackages = recurseIntoAttrs (callPackage ./emscripten-packages.nix { });

View File

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