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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can either:
- Use it online: https://playground.zigtools.org/
- Run it locally:

Requires Zig `0.16.0`. Will automatically fetch Zig along with ZLS, compiling both for webassembly.
Requires Zig `0.17.0`. Will automatically fetch Zig along with ZLS, compiling both for webassembly.

```bash
zig build -Drelease
Expand Down
11 changes: 5 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const std = @import("std");

pub fn build(b: *std.Build) void {
const target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .wasi });
const optimize: std.builtin.OptimizeMode = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall });
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .small });

const enable_wasm_opt = b.option(bool, "wasm-opt", "Run wasm-opt") orelse false;

Expand Down Expand Up @@ -40,14 +40,13 @@ pub fn build(b: *std.Build) void {
const zig_dependency = b.dependency("zig", .{
.target = target,
.optimize = optimize,
.@"version-string" = @as([]const u8, "0.16.0"),
.@"version-string" = @as([]const u8, "0.17.0"),
.@"no-lib" = true,
.dev = "wasm",
});
zig_step.dependOn(installArtifact(b, zig_dependency.artifact("zig"), enable_wasm_opt));

const lib_compiler_rt = b.addLibrary(.{
.linkage = .static,
const lib_compiler_rt = b.addObject(.{
.name = "compiler_rt",
.root_module = b.createModule(.{
.root_source_file = zig_dependency.path("lib/compiler_rt.zig"),
Expand All @@ -58,7 +57,7 @@ pub fn build(b: *std.Build) void {
compiler_rt_step.dependOn(&b.addInstallArtifact(lib_compiler_rt, .{ .dest_dir = .{ .override = .prefix } }).step);

const run_tar = b.addSystemCommand(&.{ "tar", "-czf" });
const zig_tar_gz = run_tar.addOutputFileArg("zig.tar.gz");
const zig_tar_gz = run_tar.addOutputFileArg2("zig.tar.gz", .{});
tarball_step.dependOn(&b.addInstallFile(zig_tar_gz, "zig.tar.gz").step);
run_tar.addArg("-C");
run_tar.addDirectoryArg(zig_dependency.path("."));
Expand All @@ -78,7 +77,7 @@ fn installArtifact(b: *std.Build, artifact: *std.Build.Step.Compile, enable_wasm
wasm_opt.addArtifactArg(artifact);
wasm_opt.addArg("-o");
const file_name = b.fmt("{s}.wasm", .{artifact.name});
const exe = wasm_opt.addOutputFileArg(file_name);
const exe = wasm_opt.addOutputFileArg2(file_name, .{});
return &b.addInstallBinFile(exe, file_name).step;
} else {
return &b.addInstallArtifact(artifact, .{}).step;
Expand Down
10 changes: 5 additions & 5 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
.name = .playground,
.version = "0.0.0",
.fingerprint = 0xdc188848360fd988, // Changing this has security and trust implications.
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.dependencies = .{
.zls = .{
.url = "git+https://github.com/zigtools/zls?ref=0.16.0#494486203c3a48927f2383aa3d5ce5fca112186d",
.hash = "zls-0.16.0-rmm5fs_JJgBG3dk5HwYK1FylE2_LMN0BYpX57tPzT-Xc",
.url = "git+https://github.com/zigtools/zls?ref=0.17.0#542462c4ddf045493fa9ca028ee6bc3f38b2754a",
.hash = "zls-0.17.0-rmm5fjYwHAAfoBoodSZ8k3NYPa8ZZG60JPlOTGFrAhTw",
},
.zig = .{
.url = "git+https://github.com/zigtools/zig?ref=wasm32-wasi#1c430bc130989d285723de8b7aa8e3c77297a266",
.hash = "zig-0.0.0-Fp4XJHzK5Q2xL7r676PlbSvBhz_af_mGXkGPVaXvf_Kx",
.url = "git+https://codeberg.org/ziglang/zig?ref=0.17.0#7647adab80dd088f4de3610fd245915a912eb6ad",
.hash = "zig-0.0.0-Fp4XJNPbSg7JHi19U9bkBViqpw1CEGENf1JhYBLHWjMq",
},
},
.paths = .{""},
Expand Down
8 changes: 4 additions & 4 deletions src/workers/zig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ async function run(source: string) {
currentlyRunning = true;

const libDirectory = await getLatestZigArchive();
const libCompilerRt = await fetch(new URL("../../zig-out/libcompiler_rt.a", import.meta.url));
const compilerRtObject = await fetch(new URL("../../zig-out/compiler_rt.o", import.meta.url));

const args = [
"zig.wasm",
"build-exe",
"main.zig",
"libcompiler_rt.a",
"compiler_rt.o",
"-fno-compiler-rt", // manually linked because the self hosted webassembly backend cannot compile it by itself
"-fno-entry", // prevent the native webassembly backend from adding a start function to the module
"-fno-ubsan-rt",
];
const env: string[] = [];
const fds = [
Expand All @@ -25,7 +25,7 @@ async function run(source: string) {
stderrOutput(), // stderr
new PreopenDirectory(".", new Map<string, Inode>([
["main.zig", new File(new TextEncoder().encode(source))],
["libcompiler_rt.a", new File(await libCompilerRt.arrayBuffer())]
["compiler_rt.o", new File(await compilerRtObject.arrayBuffer())]
])),
new PreopenDirectory("/lib", libDirectory.contents),
new PreopenDirectory("/cache", new Map()),
Expand Down
21 changes: 0 additions & 21 deletions zig.patch

This file was deleted.

Loading