Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urwasm jet #747

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ fn buildBinary(
.optimize = optimize,
});

const wasm3 = b.dependency("wasm3", .{
.target = target,
.optimize = optimize,
});

//
// Build Artifact
//
Expand Down Expand Up @@ -416,6 +421,7 @@ fn buildBinary(
urbit.linkLibrary(sigsegv.artifact("sigsegv"));
urbit.linkLibrary(urcrypt.artifact("urcrypt"));
urbit.linkLibrary(whereami.artifact("whereami"));
urbit.linkLibrary(wasm3.artifact("wasm3"));

if (t.isDarwin()) {
// Requires llvm@18 homebrew installation
Expand Down
3 changes: 3 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
.url = "https://github.com/allyourcodebase/zlib/archive/0918e87b7629b9c6a50a08edd0ce30d849758faf.tar.gz",
.hash = "122034ab2a12adf8016ffa76e48b4be3245ffd305193edba4d83058adbcfa749c107",
},
.wasm3 = .{
.path = "./ext/wasm3",
},
},
.paths = .{
"",
Expand Down
87 changes: 87 additions & 0 deletions ext/wasm3/build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const t = target.result;

const softfloat = b.dependency("softfloat", .{
.target = target,
.optimize = optimize,
});

const wasm3_c = b.dependency("wasm3", .{
.target = target,
.optimize = optimize,
});

const wasm3 = b.addStaticLibrary(.{
.name = "wasm3",
.target = target,
.optimize = optimize,
});

wasm3.linkLibC();

wasm3.addIncludePath(wasm3_c.path("source/"));

const common_flags = [_][]const u8{
"-std=c99",
"-Wall",
"-Wextra",
"-Wparentheses",
"-Wundef",
"-Wpointer-arith",
"-Wstrict-aliasing=2",
"-Werror=implicit-function-declaration",
"-fno-sanitize=all",
// "-fsanitize=undefined",
// "-fno-sanitize-trap=undefined",
};

const mac_flags = common_flags ++ [_][]const u8{
"-fPIC",
"-c",
};

wasm3.addCSourceFiles(.{
.root = wasm3_c.path("source/"),
.files = &.{
"m3_bind.c",
"m3_code.c",
"m3_compile.c",
"m3_core.c",
"m3_emit.c",
"m3_env.c",
"m3_exec.c",
"m3_function.c",
"m3_info.c",
"m3_module.c",
"m3_parse.c",
"m3_validate.c",
},
.flags = if (t.os.tag == .macos) &mac_flags else &common_flags,
});

wasm3.installHeader(wasm3_c.path("source/m3_config_platforms.h"), "m3_config_platforms.h");
wasm3.installHeader(wasm3_c.path("source/m3_bind.h"), "m3_bind.h");
wasm3.installHeader(wasm3_c.path("source/m3_code.h"), "m3_code.h");
wasm3.installHeader(wasm3_c.path("source/m3_compile.h"), "m3_compile.h");
wasm3.installHeader(wasm3_c.path("source/m3_config.h"), "m3_config.h");
wasm3.installHeader(wasm3_c.path("source/m3_core.h"), "m3_core.h");
wasm3.installHeader(wasm3_c.path("source/m3_emit.h"), "m3_emit.h");
wasm3.installHeader(wasm3_c.path("source/m3_env.h"), "m3_env.h");
wasm3.installHeader(wasm3_c.path("source/m3_exception.h"), "m3_exception.h");
wasm3.installHeader(wasm3_c.path("source/m3_exec.h"), "m3_exec.h");
wasm3.installHeader(wasm3_c.path("source/m3_exec_defs.h"), "m3_exec_defs.h");
wasm3.installHeader(wasm3_c.path("source/m3_function.h"), "m3_function.h");
wasm3.installHeader(wasm3_c.path("source/m3_info.h"), "m3_info.h");
wasm3.installHeader(wasm3_c.path("source/m3_math_utils.h"), "m3_math_utils.h");
wasm3.installHeader(wasm3_c.path("source/wasm3.h"), "wasm3.h");
wasm3.installHeader(wasm3_c.path("source/wasm3_defs.h"), "wasm3_defs.h");
wasm3.installHeader(wasm3_c.path("source/m3_validate.h"), "m3_validate.h");

wasm3.linkLibrary(softfloat.artifact("softfloat"));

b.installArtifact(wasm3);
}
17 changes: 17 additions & 0 deletions ext/wasm3/build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.{
.name = "wasm3",
.version = "0.0.1",
.dependencies = .{
.softfloat = .{
.path = "../softfloat",
},
.wasm3 = .{
// .path = "../../../../wasm3"
.url = "https://github.com/Quodss/wasm3/archive/a8ccdb9a96eda023730e5b876c37e1550a4d18f9.tar.gz",
.hash = "1220ccd506e41df3d84563f3d997911e6d628ed7d7490854193215c6ac2dc69a3586",
},
},
.paths = .{
"",
},
}
4 changes: 4 additions & 0 deletions pkg/c3/motes.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@
# define c3__exit c3_s4('e','x','i','t')
# define c3__eyre c3_s4('e','y','r','e')
# define c3__f c3_s1('f')
# define c3__f32 c3_s3('f','3','2')
# define c3__f64 c3_s3('f','6','4')
# define c3__fx c3_s2('f','x')
# define c3__fab c3_s3('f','a','b')
# define c3__face c3_s4('f','a','c','e')
Expand Down Expand Up @@ -596,6 +598,8 @@
# define c3__hxtr c3_s4('h','x','t','r')
# define c3__hxts c3_s4('h','x','t','s')
# define c3__i c3_s1('i')
# define c3__i32 c3_s3('i','3','2')
# define c3__i64 c3_s3('i','6','4')
# define c3__ic c3_s2('i','c')
# define c3__ice c3_s3('i','c','e')
# define c3__iced c3_s4('i','c','e','d')
Expand Down
7 changes: 7 additions & 0 deletions pkg/noun/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});

const wasm3 = b.dependency("wasm3", .{
.target = target,
.optimize = optimize,
});

pkg_noun.linkLibC();

pkg_noun.linkLibrary(pkg_c3.artifact("c3"));
Expand All @@ -123,6 +128,7 @@ pub fn build(b: *std.Build) !void {
pkg_noun.linkLibrary(urcrypt.artifact("urcrypt"));
pkg_noun.linkLibrary(whereami.artifact("whereami"));
pkg_noun.linkLibrary(zlib.artifact("z"));
pkg_noun.linkLibrary(wasm3.artifact("wasm3"));

pkg_noun.addIncludePath(b.path(""));
if (t.os.tag.isDarwin())
Expand Down Expand Up @@ -310,6 +316,7 @@ const c_source_files = [_][]const u8{
"jets/e/slaw.c",
"jets/e/tape.c",
"jets/e/trip.c",
"jets/e/urwasm.c",
"jets/f/cell.c",
"jets/f/comb.c",
"jets/f/cons.c",
Expand Down
3 changes: 3 additions & 0 deletions pkg/noun/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
.url = "https://github.com/allyourcodebase/zlib/archive/0918e87b7629b9c6a50a08edd0ce30d849758faf.tar.gz",
.hash = "122034ab2a12adf8016ffa76e48b4be3245ffd305193edba4d83058adbcfa749c107",
},
.wasm3 = .{
.path = "../../ext/wasm3",
},
},
.paths = .{
"",
Expand Down
51 changes: 51 additions & 0 deletions pkg/noun/jets/137/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,56 @@ static u3j_core _137_non_d[] =
};


static u3j_harm _137_hex_lia_run_a[] = {{".2", u3we_lia_run, c3y}, {}};

static u3j_harm _137_hex_lia_run_once_inner_a[] = {{".2", u3we_lia_run_once, c3y}, {}};

static u3j_core _137_hex_lia_run_once_d[] = {
{ "run-once-inner-v0", 15, _137_hex_lia_run_once_inner_a, 0, no_hashes },
{}
};

static u3j_core _137_hex_lia_monad_d[] = {
{ "run-v0", 7, _137_hex_lia_run_a, 0, no_hashes },
{ "run-once-v0", 7, 0, _137_hex_lia_run_once_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_engine_d[] = {
{ "monad-v0", 3, 0, _137_hex_lia_monad_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_op_def_d[] = {
{ "wasm-engine-v0", 3, 0, _137_hex_wasm_engine_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_validator_d[] = {
{ "wasm-op-def-v0", 3, 0, _137_hex_wasm_op_def_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_parser_d[] = {
{ "validator-v0", 3, 0, _137_hex_wasm_validator_d, no_hashes },
{}
};

static u3j_core _137_hex_lia_sur_d[] = {
{ "wasm-parser-v0", 3, 0, _137_hex_wasm_parser_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_engine_sur_d[] = {
{ "monad-sur-v0", 3, 0, _137_hex_lia_sur_d, no_hashes },
{}
};

static u3j_core _137_hex_wasm_sur_d[] = {
{ "engine-sur-v0", 3, 0, _137_hex_wasm_engine_sur_d, no_hashes },
{}
};

static u3j_core _137_hex_d[] =
{ { "non", 7, 0, _137_non_d, no_hashes },

Expand All @@ -869,6 +919,7 @@ static u3j_core _137_hex_d[] =
{ "secp", 6, 0, _137_hex_secp_d, no_hashes },
{ "mimes", 31, 0, _137_hex_mimes_d, no_hashes },
{ "json", 31, 0, _137_hex_json_d, no_hashes },
{ "wasm-sur-v0", 3, 0, _137_hex_wasm_sur_d, no_hashes },
{}
};

Expand Down
Loading