about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers
diff options
context:
space:
mode:
authorGabriel Ebner <gebner@gebner.org>2020-08-28 20:19:50 +0200
committerAlyssa Ross <hi@alyssa.is>2020-11-27 13:27:58 +0000
commit62b6420185e7114cf5c173b8e568396979bd4b5c (patch)
tree5c1e78c37ebf3fed0f82f10a54bae22fcc270e64 /nixpkgs/pkgs/development/compilers
parent8bae66faa3e7ba2555d679bb368186f6d07d5cea (diff)
downloadnixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar.gz
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar.bz2
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar.lz
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar.xz
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.tar.zst
nixlib-62b6420185e7114cf5c173b8e568396979bd4b5c.zip
emscripten: 1.39.1 -> 2.0.0
(cherry picked from commit 2d39da2084d5286bcefcf3e45c27fb140b350b19)
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
-rw-r--r--nixpkgs/pkgs/development/compilers/emscripten/default.nix95
-rw-r--r--nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix28
-rw-r--r--nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix53
3 files changed, 49 insertions, 127 deletions
diff --git a/nixpkgs/pkgs/development/compilers/emscripten/default.nix b/nixpkgs/pkgs/development/compilers/emscripten/default.nix
index cd5142acce88..314ca3f0d92a 100644
--- a/nixpkgs/pkgs/development/compilers/emscripten/default.nix
+++ b/nixpkgs/pkgs/development/compilers/emscripten/default.nix
@@ -1,63 +1,66 @@
-{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler
-, jre, binaryen, enableWasm ? true ,  cmake
+{ stdenv, fetchFromGitHub, python3, nodejs, closurecompiler
+, jre, binaryen
+, llvmPackages_11
+, symlinkJoin, makeWrapper
 }:
 
-let
-  rev = emscriptenVersion;
-  appdir = "share/emscripten";
-  binaryenVersioned = binaryen.override { emscriptenRev = rev; };
-in
+stdenv.mkDerivation rec {
+  pname = "emscripten";
+  # 2.0.1 requires unreleased binaryen version (as of 2020-08-28)
+  version = "2.0.0";
 
-stdenv.mkDerivation {
-  name = "emscripten-${rev}";
+  llvmEnv = symlinkJoin {
+    name = "emscripten-llvm-${version}";
+    paths = with llvmPackages_11; [ clang-unwrapped lld llvm ];
+  };
 
   src = fetchFromGitHub {
     owner = "emscripten-core";
     repo = "emscripten";
-    sha256 = "1j3f0hpy05qskaiyv75l7wv4n0nzxhrh9b296zchx3f6f9h2rghq";
-    inherit rev;
+    sha256 = "1ihr1v8dlq5xq97i59n7s1hhz5pkafi6556ppgzjmmhiiraz2mkh";
+    rev = version;
   };
 
-  buildInputs = [ nodejs cmake python ];
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ nodejs python3 ];
+
+  outputs = [ "out" "appdir" ];
 
-  buildCommand = ''
-    mkdir -p $out/${appdir}
-    cp -r $src/* $out/${appdir}
-    chmod -R +w $out/${appdir}
-    grep -rl '^#!/usr.*python' $out/${appdir} | xargs sed -i -s 's@^#!/usr.*python.*@#!${python}/bin/python@'
-    sed -i -e "s,EM_CONFIG = '~/.emscripten',EM_CONFIG = '$out/${appdir}/config'," $out/${appdir}/tools/shared.py
-    sed -i -e 's,^.*did not see a source tree above the LLVM.*$,      return True,' $out/${appdir}/tools/shared.py
-    sed -i -e 's,def check_sanity(force=False):,def check_sanity(force=False):\n  return,' $out/${appdir}/tools/shared.py
+  buildPhase = ''
+    patchShebangs .
     # fixes cmake support
-    sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" $out/${appdir}/emcc.py
-    mkdir $out/bin
-    ln -s $out/${appdir}/{em++,em-config,emar,embuilder.py,emcc,emcmake,emconfigure,emlink.py,emmake,emranlib,emrun,emscons} $out/bin
+    sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py
 
-    echo "EMSCRIPTEN_ROOT = '$out/${appdir}'" > $out/${appdir}/config
-    echo "LLVM_ROOT = '${emscriptenfastcomp}/bin'" >> $out/${appdir}/config
-    echo "PYTHON = '${python}/bin/python'" >> $out/${appdir}/config
-    echo "NODE_JS = '${nodejs}/bin/node'" >> $out/${appdir}/config
-    echo "JS_ENGINES = [NODE_JS]" >> $out/${appdir}/config
-    echo "COMPILER_ENGINE = NODE_JS" >> $out/${appdir}/config
-    echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> $out/${appdir}/config
-    echo "JAVA = '${jre}/bin/java'" >> $out/${appdir}/config
+    echo "EMSCRIPTEN_ROOT = '$appdir'" > .emscripten
+    echo "LLVM_ROOT = '${llvmEnv}/bin'" >> .emscripten
+    echo "NODE_JS = '${nodejs}/bin/node'" >> .emscripten
+    echo "JS_ENGINES = [NODE_JS]" >> .emscripten
+    echo "COMPILER_ENGINE = NODE_JS" >> .emscripten
+    echo "CLOSURE_COMPILER = '${closurecompiler}/share/java/closure-compiler-v${closurecompiler.version}.jar'" >> .emscripten
+    echo "JAVA = '${jre}/bin/java'" >> .emscripten
     # to make the test(s) below work
-    echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config
-  ''
-  + stdenv.lib.optionalString enableWasm ''
-    echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config
-  ''
-  +
-  ''
-    echo "--------------- running test -----------------"
-    # quick hack to get the test working
-    HOME=$TMPDIR
-    cp $out/${appdir}/config $HOME/.emscripten
-    export PATH=$PATH:$out/bin
+    echo "SPIDERMONKEY_ENGINE = []" >> .emscripten
+    echo "BINARYEN_ROOT = '${binaryen}'" >> .emscripten
+  '';
+
+  installPhase = ''
+    rm -rf cache
+    cp -r . $appdir
+    chmod -R +w $appdir
+
+    mkdir -p $out/bin
+    for b in em++ em-config emar embuilder.py emcc emcmake emconfigure emlink.py emmake emranlib emrun emscons; do
+      makeWrapper $appdir/$b $out/bin/$b \
+        --set PYTHON ${python3}/bin/python
+    done
+  '';
 
-    #export EMCC_DEBUG=2  
-    ${python}/bin/python $src/tests/runner.py test_hello_world
-    echo "--------------- /running test -----------------"
+  doCheck = true;
+  checkPhase = ''
+    #export EMCC_DEBUG=2
+    export PYTHON=${python3}/bin/python
+    export HOME=$TMPDIR
+    python tests/runner.py test_hello_world
   '';
 
   meta = with stdenv.lib; {
diff --git a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix
deleted file mode 100644
index 57496d288605..000000000000
--- a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/default.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }:
-let
-  callPackage = newScope (self // {inherit stdenv;});
-
-  self = {
-    emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {};
-    emscriptenfastcomp-wrapped = wrapCCWith {
-      cc = self.emscriptenfastcomp-unwrapped;
-      # Never want Apple's cctools for WASM target
-      bintools = binutils;
-      libc = stdenv.cc.libc;
-      extraBuildCommands = ''
-        # hardening flags break WASM support
-        cat > $out/nix-support/add-hardening.sh
-      '';
-    };
-    emscriptenfastcomp = symlinkJoin {
-      name = "emscriptenfastcomp-${stdenv.lib.getVersion self.emscriptenfastcomp-unwrapped}";
-      paths = [ self.emscriptenfastcomp-wrapped self.emscriptenfastcomp-unwrapped ];
-      preferLocalBuild = false;
-      allowSubstitutes = true;
-      postBuild = ''
-        # replace unwrapped clang-3.9 binary by wrapper
-        ln -sf $out/bin/clang $out/bin/clang-[0-9]*
-      '';
-    };
-  };
-in self
diff --git a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix b/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix
deleted file mode 100644
index f8f06e24f8ba..000000000000
--- a/nixpkgs/pkgs/development/compilers/emscripten/fastcomp/emscripten-fastcomp.nix
+++ /dev/null
@@ -1,53 +0,0 @@
-{ emscriptenVersion, stdenv, fetchFromGitHub, cmake, python, gtest, gccForLibs, ... }:
-
-let
-  rev = emscriptenVersion;
-in
-stdenv.mkDerivation rec {
-  name = "emscripten-fastcomp-${rev}";
-
-  src = fetchFromGitHub {
-    owner = "emscripten-core";
-    repo = "emscripten-fastcomp";
-    sha256 = "0bd0l5k2fa4k0nax2cpxi003pqffqivx4z4m2j5xdha1a12sid8i";
-    inherit rev;
-  };
-
-  srcFL = fetchFromGitHub {
-    owner = "emscripten-core";
-    repo = "emscripten-fastcomp-clang";
-    sha256 = "1iw2qplhp489qzw0rma73sab7asnm27g4m95sr36c6kq9cq6agri";
-    inherit rev;
-  };
-
-  nativeBuildInputs = [ cmake python gtest ];
-  preConfigure = ''
-    cp -Lr ${srcFL} tools/clang
-    chmod +w -R tools/clang
-  '';
-  cmakeFlags = [
-    "-DCMAKE_BUILD_TYPE=Release"
-    "-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'"
-    "-DLLVM_INCLUDE_EXAMPLES=OFF"
-    "-DLLVM_INCLUDE_TESTS=ON"
-    #"-DLLVM_CONFIG=${llvm}/bin/llvm-config"
-    "-DLLVM_BUILD_TESTS=ON"
-    "-DCLANG_INCLUDE_TESTS=ON"
-  ] ++ (stdenv.lib.optional stdenv.isLinux
-    # necessary for clang to find crtend.o
-    "-DGCC_INSTALL_PREFIX=${gccForLibs}"
-  );
-  enableParallelBuilding = true;
-
-  passthru = {
-    isClang = true;
-  };
-
-  meta = with stdenv.lib; {
-    homepage = "https://github.com/emscripten-core/emscripten-fastcomp";
-    description = "Emscripten LLVM";
-    platforms = platforms.all;
-    maintainers = with maintainers; [ qknight matthewbauer ];
-    license = stdenv.lib.licenses.ncsa;
-  };
-}