Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions binaryen.nix

This file was deleted.

1 change: 1 addition & 0 deletions build-wasm-app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let
in { ename, pkg, assets ? [], scripts ? [], styles ? [] }: runCommand "wasm-app-${ename}" {
nativeBuildInputs = [ buildPackages.xorg.lndir buildPackages.binaryen ];
passthru = { inherit pkg; };
meta.platforms = ["wasm32-unknown"];
} ''
mkdir -p $out
lndir ${buildPackages.buildPackages.webabi}/lib/node_modules/webabi/build $out
Expand Down
9 changes: 5 additions & 4 deletions cross-overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ self: super: {

haskell = let inherit (super) haskell; in haskell // {
packages = haskell.packages // {
ghcWasm = haskell.packages.ghc863.override (drv: {
ghcWasm = haskell.packages.ghc881.override (drv: {
ghc = (self.buildPackages.haskell.compiler.ghcHEAD.override {
enableShared = false;
enableRelocatedStaticLibs = false;
Expand All @@ -18,16 +18,16 @@ self: super: {
dontStrip = true;
dontUseLibFFIForAdjustors = crossSystem.isWasm;
disableFFI = crossSystem.isWasm;
version = "8.6.3";
version = "8.8.1";
useLLVM = true;
buildLlvmPackages = self.buildPackages.llvmPackages_HEAD;
llvmPackages = self.buildPackages.llvmPackages_HEAD;
}).overrideAttrs (drv: {
nativeBuildInputs = drv.nativeBuildInputs or [] ++ [self.buildPackages.autoreconfHook];
src = self.buildPackages.fetchgit {
url = "https://github.com/WebGHC/ghc.git";
rev = "9af15622eead357865f33eb1945bd2fe3da70c90";
sha256 = "08xzlasdv14hhfdszk7khjlhjifpzdlc1fybaiwgik3nrhphlkjf";
rev = "a0755fefa31adc4b451884540d08f3d5c5ea918c";
sha256 = "1j0rq5b06yx9cfadjfrhq4lai7kls916iy7hcb52iq4dr8hq9n2i";
fetchSubmodules = true;
preFetch = ''
export HOME=$(pwd)
Expand All @@ -41,6 +41,7 @@ self: super: {
++ lib.optional crossSystem.isWasm "pic";
dontDisableStatic = true;
NIX_NO_SELF_RPATH=1;
patches = lib.filter (p: p.name != "loadpluginsinmodules.diff") drv.patches;
});
overrides = self.lib.composeExtensions (drv.overrides or (_:_:{})) (hsSelf: hsSuper: {
primitive = self.haskell.lib.appendPatch hsSuper.primitive ./primitive.patch;
Expand Down
6 changes: 3 additions & 3 deletions cross.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ in bootStages ++ [
name = "clang-cross-wrapper";
cc = llvmPackages.clang-unwrapped;
bintools = toolPackages.wrapBintoolsWith {
bintools = llvmPackages.llvm-binutils;
bintools = llvmPackages.bintools;
inherit libc;
};
inherit libc;
Expand Down Expand Up @@ -116,8 +116,8 @@ in bootStages ++ [
stdenv = stdenv-noLibc;
};
compiler-rt = toolPackages.llvmPackages_HEAD.compiler-rt.override {
baremetal = true;
hostPlatform = crossSystem;
# baremetal = true;
# hostPlatform = crossSystem;
stdenv = stdenv-noCompilerRt;
};
in {
Expand Down
12 changes: 8 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@
haskell-example = self.build-wasm-app { ename = "hello"; pkg = self.haskell.packages.ghcWasm.hello; };

llvmPackages_HEAD = self.callPackage ./llvm-head {
buildTools = self.buildPackages.llvmPackages_HEAD;
buildLlvmTools = self.buildPackages.llvmPackages_HEAD;
targetLlvmLibraries = self.buildPackages.llvmPackages_HEAD;
debugVersion = debugLlvm;
};

wabt = self.callPackage ./wabt.nix {};
binaryen = self.callPackage ./binaryen.nix {};

webabi = self.callPackage ./webabi-nix {};

webghc-runner = self.writeShellScriptBin "webghc-runner" ''
exec ${self.nodejs-8_x}/bin/node ${self.webabi}/lib/node_modules/webabi/build/node_runner.js "$@"
'';

build-wasm-app = self.callPackage ./build-wasm-app.nix {};

# Issue happens when combining pkgsStatic & custom cross stdenv.
# We need to force a normal busybox here to avoid hitting a
# weird bootstrapping issue.
busybox-sandbox-shell = super.busybox-sandbox-shell.override { busybox = self.busybox; };
})] ++ overlays;
};
nixpkgsCrossArgs = project.nixpkgsArgs // {
Expand All @@ -36,6 +39,7 @@
config = "wasm32-unknown-unknown-wasm";
arch = "wasm32";
libc = null;
useLLVM = true;
disableDynamicLinker = true;
thread-model = "single";
# target-cpu = "bleeding-edge";
Expand Down
74 changes: 37 additions & 37 deletions libiconv-wasm32.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
diff -ruN libiconv-1.15/build-aux/config.sub libiconv-1.15-patched/build-aux/config.sub
--- libiconv-1.15/build-aux/config.sub 2017-01-02 09:02:47.000000000 +1000
+++ libiconv-1.15-patched/build-aux/config.sub 2017-11-22 08:38:36.995036311 +1000
@@ -118,7 +118,7 @@
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | cloudabi*-eabi* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
+ storm-chaos* | os2-emx* | rtmk-nova* | unknown-wasm)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -1543,6 +1543,8 @@
diff -ruN libiconv-1.16/build-aux/config.sub libiconv-1.16-patched/build-aux/config.sub
--- libiconv-1.16/build-aux/config.sub 2019-04-27 03:29:05.000000000 +0900
+++ libiconv-1.16-patched/build-aux/config.sub 2019-11-23 21:36:56.794790501 +0900
@@ -135,7 +135,7 @@
| linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
- | storm-chaos* | os2-emx* | rtmk-nova*)
+ | storm-chaos* | os2-emx* | rtmk-nova* | unknown-wasm)
basic_machine=$field1
os=$maybe_os
;;
@@ -1511,6 +1511,8 @@
;;
-ios)
ios)
;;
+ -unknown-wasm)
+ unknown-wasm)
+ ;;
-none)
none)
;;
*)
diff -ruN libiconv-1.15/lib/loop_wchar.h libiconv-1.15-patched/lib/loop_wchar.h
--- libiconv-1.15/lib/loop_wchar.h 2014-01-02 17:23:02.000000000 -0500
+++ libiconv-1.15-patched/lib/loop_wchar.h 2018-05-29 11:23:49.342538241 -0400
*-eabi)
diff -ruN libiconv-1.16/lib/loop_wchar.h libiconv-1.16-patched/lib/loop_wchar.h
--- libiconv-1.16/lib/loop_wchar.h 2018-09-18 01:06:14.000000000 +0900
+++ libiconv-1.16-patched/lib/loop_wchar.h 2019-11-23 21:40:43.599165612 +0900
@@ -36,7 +36,9 @@
# include <wchar.h>
# define BUF_SIZE 64 /* assume MB_LEN_MAX <= 64 */
Expand All @@ -32,24 +32,24 @@ diff -ruN libiconv-1.15/lib/loop_wchar.h libiconv-1.15-patched/lib/loop_wchar.h
# ifdef mbstate_t
# define mbrtowc(pwc, s, n, ps) (mbrtowc)(pwc, s, n, 0)
# define mbsinit(ps) 1
diff -ruN libiconv-1.15/libcharset/build-aux/config.sub libiconv-1.15-patched/libcharset/build-aux/config.sub
--- libiconv-1.15/libcharset/build-aux/config.sub 2017-01-02 09:02:47.000000000 +1000
+++ libiconv-1.15-patched/libcharset/build-aux/config.sub 2017-11-22 08:52:03.504787774 +1000
@@ -118,7 +118,7 @@
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | cloudabi*-eabi* | \
- storm-chaos* | os2-emx* | rtmk-nova*)
+ storm-chaos* | os2-emx* | rtmk-nova* | unknown-wasm)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -1543,6 +1543,8 @@
diff -ruN libiconv-1.16/libcharset/build-aux/config.sub libiconv-1.16-patched/libcharset/build-aux/config.sub
--- libiconv-1.16/libcharset/build-aux/config.sub 2019-04-27 03:29:05.000000000 +0900
+++ libiconv-1.16-patched/libcharset/build-aux/config.sub 2019-11-23 21:39:26.892696874 +0900
@@ -135,7 +135,7 @@
| linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
- | storm-chaos* | os2-emx* | rtmk-nova*)
+ | storm-chaos* | os2-emx* | rtmk-nova* | unknown-wasm)
basic_machine=$field1
os=$maybe_os
;;
@@ -1511,6 +1511,8 @@
;;
-ios)
ios)
;;
+ -unknown-wasm)
+ unknown-wasm)
+ ;;
-none)
none)
;;
*)
*-eabi)
19 changes: 19 additions & 0 deletions llvm-head/bintools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ runCommand, stdenv, llvm, lld, version }:

let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } ''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/${prefix}$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||")
ln -sf $prog $out/bin/${prefix}$(basename $prog)
done
rm -f $out/bin/${prefix}cat
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
''
53 changes: 53 additions & 0 deletions llvm-head/clang/compiler-rt-baremetal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Index: lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- a/lib/Driver/ToolChains/BareMetal.cpp
+++ b/lib/Driver/ToolChains/BareMetal.cpp
@@ -157,7 +157,7 @@
void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
ArgStringList &CmdArgs) const {
CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
- getTriple().getArchName() + ".a"));
+ getTriple().getArchName()));
}

void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Index: test/Driver/baremetal.cpp
===================================================================
--- a/test/Driver/baremetal.cpp
+++ b/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"

// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"

// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
// CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"

// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -61,7 +61,7 @@
// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"

// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Loading