@@ -1,54 +1,22 @@
1−{ stdenv, fetchFromGitHub, cmake, python, ... }:
2−
1+{ newScope, stdenv, wrapCC, wrapCCWith, symlinkJoin }:
32let
4− rev = "1.37.16";
5− gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
6−in
7−stdenv.mkDerivation rec {
8− name = "emscripten-fastcomp-${rev}";
9−
10− src = fetchFromGitHub {
11− owner = "kripken";
12− repo = "emscripten-fastcomp";
13− sha256 = "0wj9sc0gciaiidcjv6wb0qn6ks06xds7q34351masc7qpvd217by";
14− inherit rev;
15− };
16−
17− srcFL = fetchFromGitHub {
18− owner = "kripken";
19− repo = "emscripten-fastcomp-clang";
20− sha256 = "1akdgxzxhzjbhp4d14ajcrp9jrf39x004a726ly2gynqc185l4j7";
21− inherit rev;
22− };
23−
24− nativeBuildInputs = [ cmake python ];
25− preConfigure = ''
26− cp -Lr ${srcFL} tools/clang
27− chmod +w -R tools/clang
28− '';
29− cmakeFlags = [
30− "-DCMAKE_BUILD_TYPE=Release"
31− "-DLLVM_TARGETS_TO_BUILD='X86;JSBackend'"
32− "-DLLVM_INCLUDE_EXAMPLES=OFF"
33− "-DLLVM_INCLUDE_TESTS=OFF"
34− # "-DCLANG_INCLUDE_EXAMPLES=OFF"
35− "-DCLANG_INCLUDE_TESTS=OFF"
36− ] ++ (stdenv.lib.optional stdenv.isLinux
37− # necessary for clang to find crtend.o
38− "-DGCC_INSTALL_PREFIX=${gcc}"
39− );
40− enableParallelBuilding = true;
41−
42− passthru = {
43− isClang = true;
44− inherit gcc;
45− };
3+ callPackage = newScope (self // {inherit stdenv;});
464
47− meta = with stdenv.lib; {
48− homepage = https://github.com/kripken/emscripten-fastcomp;
49− description = "Emscripten LLVM";
50− platforms = platforms.all;
51− maintainers = with maintainers; [ qknight matthewbauer ];
52− license = stdenv.lib.licenses.ncsa;
5+ self = {
6+ emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {};
7+ emscriptenfastcomp-wrapped = wrapCCWith stdenv.cc.libc ''
8+ # hardening flags break WASM support
9+ cat > $out/nix-support/add-hardening.sh
10+ '' self.emscriptenfastcomp-unwrapped;
11+ emscriptenfastcomp = symlinkJoin {
12+ name = "emscriptenfastcomp";
13+ paths = [ self.emscriptenfastcomp-wrapped self.emscriptenfastcomp-unwrapped ];
14+ preferLocalBuild = false;
15+ allowSubstitutes = true;
16+ postBuild = ''
17+ # replace unwrapped clang-3.9 binary by wrapper
18+ ln -sf $out/bin/clang $out/bin/clang-[0-9]*
19+ '';
20+ };
5321 };
54−}
22+in self