diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2019-01-29 21:01:24 -0500 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2019-04-23 21:48:57 -0400 |
commit | 9abff4af4f07c16aecd89bf82051afbc3228d6fd (patch) | |
tree | 7a8d8fe316db1636819a43a28192da740ea835c8 /lib/systems | |
parent | 6088a4793f2a83921b197a9185034934fcd96d02 (diff) |
wasm: init cross target
Adds pkgsCross.wasm32 and pkgsCross.wasm64. Use it to build Nixpkgs
with a WebAssembly toolchain.
stdenv/cross: use static overlay on isWasm
isWasm doesn’t make sense dynamically linked.
Diffstat (limited to 'lib/systems')
-rw-r--r-- | lib/systems/default.nix | 3 | ||||
-rw-r--r-- | lib/systems/doubles.nix | 3 | ||||
-rw-r--r-- | lib/systems/examples.nix | 14 | ||||
-rw-r--r-- | lib/systems/for-meta.nix | 1 | ||||
-rw-r--r-- | lib/systems/inspect.nix | 3 | ||||
-rw-r--r-- | lib/systems/parse.nix | 4 |
6 files changed, 24 insertions, 4 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix index b45a5fd8d2ba..c408fe46be6f 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -30,6 +30,7 @@ rec { libc = /**/ if final.isDarwin then "libSystem" else if final.isMinGW then "msvcrt" + else if final.isWasi then "wasilibc" else if final.isMusl then "musl" else if final.isUClibc then "uclibc" else if final.isAndroid then "bionic" @@ -62,7 +63,7 @@ rec { "netbsd" = "NetBSD"; "freebsd" = "FreeBSD"; "openbsd" = "OpenBSD"; - "wasm" = "Wasm"; + "wasi" = "Wasi"; }.${final.parsed.kernel.name} or null; # uname -p diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index 2cf06b6ac1c8..c6877ebef0bc 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -17,6 +17,8 @@ let "x86_64-netbsd" "x86_64-openbsd" "x86_64-solaris" "x86_64-windows" "i686-windows" + + "wasm64-wasi" "wasm32-wasi" ]; allParsed = map parse.mkSystemFromString all; @@ -45,6 +47,7 @@ in rec { netbsd = filterDoubles predicates.isNetBSD; openbsd = filterDoubles predicates.isOpenBSD; unix = filterDoubles predicates.isUnix; + wasi = filterDoubles predicates.isWasi; windows = filterDoubles predicates.isWindows; mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "armv7a-linux" "aarch64-linux" "powerpc64le-linux"]; diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 1a5b80449bf2..94c7cfd7570f 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -116,7 +116,7 @@ rec { config = "aarch64-none-elf"; libc = "newlib"; }; - + aarch64be-embedded = { config = "aarch64_be-none-elf"; libc = "newlib"; @@ -126,7 +126,7 @@ rec { config = "powerpc-none-eabi"; libc = "newlib"; }; - + ppcle-embedded = { config = "powerpcle-none-eabi"; libc = "newlib"; @@ -211,4 +211,14 @@ rec { config = "x86_64-unknown-netbsd"; libc = "nblibc"; }; + + # + # WASM + # + + wasi32 = { + config = "wasm32-unknown-wasi"; + useLLVM = true; + }; + } diff --git a/lib/systems/for-meta.nix b/lib/systems/for-meta.nix index 51fb6ae760d1..17ae94deb7d1 100644 --- a/lib/systems/for-meta.nix +++ b/lib/systems/for-meta.nix @@ -32,6 +32,7 @@ in rec { openbsd = [ patterns.isOpenBSD ]; unix = patterns.isUnix; # Actually a list windows = [ patterns.isWindows ]; + wasi = [ patterns.isWasi ]; inherit (lib.systems.doubles) mesaPlatforms; } diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index f8d5ca84d7aa..b88af55e46be 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -43,9 +43,10 @@ rec { isWindows = { kernel = kernels.windows; }; isCygwin = { kernel = kernels.windows; abi = abis.cygnus; }; isMinGW = { kernel = kernels.windows; abi = abis.gnu; }; + isWasi = { kernel = kernels.wasi; }; isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ]; - isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ]; + isMusl = (with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ]) ++ [{ kernel = kernels.wasi; }]; isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ]; isEfi = map (family: { cpu.family = family; }) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 3e23a721f0d9..522a3bf71aff 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -226,6 +226,7 @@ rec { elf = {}; macho = {}; pe = {}; + wasm = {}; unknown = {}; }; @@ -268,6 +269,7 @@ rec { none = { execFormat = unknown; families = { }; }; openbsd = { execFormat = elf; families = { inherit bsd; }; }; solaris = { execFormat = elf; families = { }; }; + wasi = { execFormat = wasm; families = { }; }; windows = { execFormat = pe; families = { }; }; } // { # aliases # 'darwin' is the kernel for all of them. We choose macOS by default. @@ -376,6 +378,8 @@ rec { then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; } else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; } + else if (elemAt l 2 == "wasi") + then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; } else if hasPrefix "netbsd" (elemAt l 2) then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"]) |