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
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
fail-fast: false
matrix:
zig-version:
- "0.16.0"
- "0.17.0"
operating-system: [ ubuntu-latest, macos-latest, windows-latest ]
optimize:
- "Debug"
- "ReleaseSafe"
- "ReleaseFast"
- "ReleaseSmall"
- "debug"
- "safe"
- "fast"
- "small"
options:
- ""
- "-Djit_always_on -Djit_asynchronous=false"
Expand Down Expand Up @@ -50,9 +50,9 @@ jobs:
- name: Setup nightly Zig
uses: mlugg/setup-zig@v2.2.1
with:
version: ${{ matrix.zig-version }}
version: "0.17.0"
- name: Build for wasm
run: zig build -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall
run: zig build -Dtarget=wasm32-freestanding -Doptimize=small

lint:
runs-on: macos-latest
Expand All @@ -61,5 +61,5 @@ jobs:
- name: Setup Zig
uses: mlugg/setup-zig@v2.2.1
with:
version: ${{ matrix.zig-version }}
version: "0.17.0"
- run: zig fmt --check src/*.zig src/**/*.zig
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This release brings a lot of useful tools to write buzz code: LSP, formatter and DAP support.

> [!NOTE]
> This release builds with zig 0.16.0. We will only use tagged version of zig from now on.
> This release builds with zig 0.17.0. We will only use tagged version of zig from now on.

## Added

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A small/lightweight statically typed scripting language written in Zig
## How to build and install

### Requirements
- Zig 0.16.0
- Zig 0.17.0
- Since this is built with Zig, you should be able to build buzz on a wide variety of architectures even though this has only been tested on x86/M1.
- Supports linux, macOS or windows
- libc
Expand Down
73 changes: 26 additions & 47 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn build(b: *Build) !void {
},
);
if (is_wasm) {
exe.global_base = 6560;
exe.global_base = std.wasm.page_size;
exe.entry = .disabled;
exe.rdynamic = true;
exe.import_memory = true;
Expand All @@ -95,9 +95,7 @@ pub fn build(b: *Build) !void {

const run_exe = b.addRunArtifact(exe);
run_exe.step.dependOn(install_step);
if (b.args) |args| {
run_exe.addArgs(args);
}
run_exe.addPassthruArgs();
b.step("run", "run buzz").dependOn(&run_exe.step);

// buzz_behavior
Expand All @@ -123,9 +121,7 @@ pub fn build(b: *Build) !void {
b.installArtifact(behavior_exe.?);
run_behavior = b.addRunArtifact(behavior_exe.?);
run_behavior.?.step.dependOn(install_step);
if (b.args) |args| {
run_behavior.?.addArgs(args);
}
run_behavior.?.addPassthruArgs();
b.step("test-behavior", "Test behavior").dependOn(&run_behavior.?.step);
}

Expand Down Expand Up @@ -180,9 +176,7 @@ pub fn build(b: *Build) !void {
b.installArtifact(lsp_exe.?);
const run_lsp_exe = b.addRunArtifact(lsp_exe.?);
run_lsp_exe.step.dependOn(install_step);
if (b.args) |args| {
run_lsp_exe.addArgs(args);
}
run_lsp_exe.addPassthruArgs();
b.step("lsp", "run buzz lsp").dependOn(&run_lsp_exe.step);
}
const lsp_tests = if (!is_wasm and target.result.os.tag != .windows)
Expand Down Expand Up @@ -245,9 +239,7 @@ pub fn build(b: *Build) !void {
},
);
const run_update_std_docs = b.addRunArtifact(update_std_docs_exe);
if (b.args) |args| {
run_update_std_docs.addArgs(args);
}
run_update_std_docs.addPassthruArgs();
b.step("update-std-docs", "Regenerate standard library reference docs").dependOn(&run_update_std_docs.step);

// Building buzz api library
Expand Down Expand Up @@ -321,7 +313,7 @@ pub fn build(b: *Build) !void {
const test_step = b.step("test", "Run all the tests");
const run_tests = b.addRunArtifact(tests);
run_tests.cwd = b.path(".");
run_tests.setEnvironmentVariable("BUZZ_PATH", b.graph.environ_map.get("BUZZ_PATH") orelse std.fs.path.dirname(b.exe_dir).?);
run_tests.setEnvironmentVariable("BUZZ_PATH", b.graph.environ_map.get("BUZZ_PATH") orelse "zig-out");
run_tests.step.dependOn(install_step); // wait for libraries to be installed
test_step.dependOn(&run_tests.step);
if (lsp_tests) |lsp_test_exe| {
Expand Down Expand Up @@ -384,14 +376,7 @@ pub fn build(b: *Build) !void {

/// Creates an internal step that installs all Buzz std headers.
fn createBuzzHeaderInstallStep(b: *Build) *Build.Step {
const step = b.allocator.create(Build.Step) catch @panic("OOM");
step.* = Build.Step.init(
.{
.id = .custom,
.name = "install buzz headers",
.owner = b,
},
);
const step = b.step("install-buzz-headers", "Install buzz headers");

for (static_headers.all) |header| {
const install_header = b.addInstallLibFile(
Expand All @@ -412,7 +397,7 @@ fn createBuzzHeaderInstallStep(b: *Build) *Build.Step {
return step;
}

pub fn buildPcre2(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*Build.Step.Compile {
pub fn buildPcre2(b: *Build, target: Build.ResolvedTarget, optimize: std.lang.Optimize) !*Build.Step.Compile {
const copyFiles = b.addWriteFiles();
_ = copyFiles.addCopyFile(
b.path("vendors/pcre2/src/config.h.generic"),
Expand Down Expand Up @@ -494,7 +479,7 @@ pub fn buildPcre2(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin
return lib;
}

pub fn buildMimalloc(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*Build.Step.Compile {
pub fn buildMimalloc(b: *Build, target: Build.ResolvedTarget, optimize: std.lang.Optimize) !*Build.Step.Compile {
const lib = b.addLibrary(
.{
.name = "mimalloc",
Expand Down Expand Up @@ -533,7 +518,7 @@ pub fn buildMimalloc(b: *Build, target: Build.ResolvedTarget, optimize: std.buil
"./vendors/mimalloc/src/stats.c",
"./vendors/mimalloc/src/prim/prim.c",
},
.flags = if (lib.root_module.optimize != .Debug)
.flags = if (lib.root_module.optimize != .debug)
&.{
"-DNDEBUG=1",
"-DMI_SECURE=0",
Expand All @@ -557,7 +542,7 @@ pub fn buildMimalloc(b: *Build, target: Build.ResolvedTarget, optimize: std.buil
return lib;
}

pub fn buildLinenoise(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*Build.Step.Compile {
pub fn buildLinenoise(b: *Build, target: Build.ResolvedTarget, optimize: std.lang.Optimize) !*Build.Step.Compile {
const lib = b.addLibrary(
.{
.name = "linenoise",
Expand Down Expand Up @@ -594,7 +579,7 @@ pub fn buildLinenoise(b: *Build, target: Build.ResolvedTarget, optimize: std.bui
fn buildTestLibraries(
b: *Build,
target: Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
optimize: std.lang.Optimize,
build_option_module: *Build.Module,
buzz_lib: *Build.Step.Compile,
) *Build.Step {
Expand Down Expand Up @@ -695,8 +680,8 @@ pub fn buildWasmReplDemo(b: *Build, exe: *Build.Step.Compile) void {

const esbuild = b.addSystemCommand(
&.{
b.pathFromRoot("node_modules/.bin/esbuild"),
b.pathFromRoot("src/wasm.ts"),
b.pathJoin(&.{"node_modules/.bin/esbuild"}),
b.pathJoin(&.{"src/wasm.ts"}),
"--bundle",
"--format=esm",
// This replaces all occurrences of '__WASM_ARTIFACT_FILENAME' in TypeScript source files
Expand All @@ -709,7 +694,7 @@ pub fn buildWasmReplDemo(b: *Build, exe: *Build.Step.Compile) void {
b.fmt(
"--outdir={s}",
.{
b.getInstallPath(.bin, ""),
b.pathJoin(&.{"zig-out/bin"}),
},
),
},
Expand All @@ -725,7 +710,7 @@ pub fn buildWasmReplDemo(b: *Build, exe: *Build.Step.Compile) void {
b.getInstallStep().dependOn(&copyRepl.step);
}

pub fn buildMir(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*Build.Step.Compile {
pub fn buildMir(b: *Build, target: Build.ResolvedTarget, optimize: std.lang.Optimize) !*Build.Step.Compile {
const lib = b.addLibrary(
.{
.name = "mir",
Expand Down Expand Up @@ -773,7 +758,7 @@ pub fn buildMir(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.O
pub fn buildFuzz(
b: *Build,
target: Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
optimize: std.lang.Optimize,
ext_deps: []const *std.Build.Step.Compile,
) *Build.Step.Compile {
// Define a step for generating fuzzing tooling:
Expand Down Expand Up @@ -807,24 +792,18 @@ pub fn buildFuzz(
}) orelse return null;

const install_tools = b.addInstallDirectory(.{
.source_dir = std.Build.LazyPath{
.cwd_relative = afl.builder.install_path,
},
.source_dir = afl.path("zig-out"),
.install_dir = .prefix,
.install_subdir = "AFLplusplus",
});

install_tools.step.dependOn(afl.builder.getInstallStep());
run_afl_cc = b.addSystemCommand(&.{
b.pathJoin(&.{ afl.builder.exe_dir, "afl-cc" }),
"-O3",
"-o",
});
run_afl_cc = b.addRunFile(afl.path("zig-out/bin/afl-cc"));
run_afl_cc.addArgs(&.{ "-O3", "-o" });
for (ext_deps) |dep| {
run_afl_cc.addArg("-L");
run_afl_cc.addFileArg(dep.getEmittedBin());
run_afl_cc.addFileArg2(dep.getEmittedBin(), .{});
}
run_afl_cc.step.dependOn(&afl.builder.top_level_steps.get("llvm_exes").?.step);
run_afl_cc.step.dependOn(&install_tools.step);
} else {
run_afl_cc = b.addSystemCommand(
Expand All @@ -836,7 +815,7 @@ pub fn buildFuzz(
_ = afl_obj.getEmittedBin(); // hack around build system bug

for (ext_deps) |dep| {
run_afl_cc.addFileArg(dep.getEmittedBin());
run_afl_cc.addFileArg2(dep.getEmittedBin(), .{});
}

// On darwin we need compiler-rt
Expand All @@ -857,7 +836,7 @@ pub fn buildFuzz(
},
);

run_afl_cc.addFileArg(compiler_rt.getEmittedBin());
run_afl_cc.addFileArg2(compiler_rt.getEmittedBin(), .{});
}

run_afl_cc.addArgs(
Expand All @@ -868,9 +847,9 @@ pub fn buildFuzz(
);
}

const fuzz_exe = run_afl_cc.addOutputFileArg(afl_obj.name);
run_afl_cc.addFileArg(b.path("src/afl.c"));
run_afl_cc.addFileArg(afl_obj.getEmittedLlvmBc());
const fuzz_exe = run_afl_cc.addOutputFileArg2(afl_obj.name, .{});
run_afl_cc.addFileArg2(b.path("src/afl.c"), .{});
run_afl_cc.addFileArg2(afl_obj.getEmittedLlvmBc(), .{});

// Install it
fuzz.dependOn(&b.addInstallBinFile(fuzz_exe, "fuzz_afl").step);
Expand Down
14 changes: 7 additions & 7 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
.name = .buzz,
.fingerprint = 0x87514371589e863a,
.version = "0.6.0",
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.dependencies = .{
.clap = .{
.url = "git+https://github.com/Hejsil/zig-clap.git#fc1e5cc3f6d9d3001112385ee6256d694e959d2f",
.hash = "clap-0.11.0-oBajB7foAQC3Iyn4IVCkUdYaOVVng5IZkSncySTjNig1",
.url = "git+https://github.com/Hejsil/zig-clap.git#05faf3905e8548f5cc269a8836e154065e70128d",
.hash = "clap-0.12.0-oBajB4XpAQCF1WRKnD5KOKPsnwwT_NNdAJ7Ww3irYJac",
},
.lsp_kit = .{
.url = "git+https://github.com/zigtools/lsp-kit.git#b886a2b0d5cee85ecbcc3089b863f7517cc9ff7f",
.hash = "lsp_kit-0.1.0-bi_PL3IyDACfp1xdTnkiOHEok2YpPCCCJHuuOcNzjl1D",
.url = "git+https://github.com/zigtools/lsp-kit.git#3e1058db66079911fdde82f833fdce6856e0a706",
.hash = "lsp_kit-0.1.0-bi_PL9o2DADHS1PDra3MGz1MXnsboN_ewNvrc419z7Fb",
},
.dap_kit = .{
.url = "git+https://github.com/buzz-language/dap-kit.git#478f2adf40b70f2f8e669352d5c419e6192f1a51",
.hash = "dap_kit-0.0.0-OvEgyANhAgAMRFGjEEJoqlAKKzuxV2VNRqsb6cO0nFUV",
.url = "git+https://github.com/buzz-language/dap-kit.git#9e05d263a1412b7392eebabd9a570da0b7a7460e",
.hash = "dap_kit-0.0.0-OvEgyAVjAgCgtawOjYZvMmUKmM0BCFSvY5DQGxiYAyvm",
},
},
.paths = .{""},
Expand Down
4 changes: 2 additions & 2 deletions build/compiler_rt/atomics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const SpinlockTable = struct {
}
};

list: [max_spinlocks]Spinlock = [_]Spinlock{.{}} ** max_spinlocks,
list: [max_spinlocks]Spinlock = @splat(.{}),

// The spinlock table behaves as a really simple hash table, mapping
// addresses to spinlocks. The mapping is not unique but that's only a
Expand Down Expand Up @@ -341,7 +341,7 @@ fn __atomic_compare_exchange_16(ptr: *u128, expected: *u128, desired: u128, succ
return atomic_compare_exchange_N(u128, ptr, expected, desired, success, failure);
}

inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr: *T, val: T, model: i32) T {
inline fn fetch_op_N(comptime T: type, comptime op: std.lang.AtomicRmwOp, ptr: *T, val: T, model: i32) T {
_ = model;
const Updater = struct {
fn update(new: T, old: T) T {
Expand Down
2 changes: 1 addition & 1 deletion build/compiler_rt/cmpdf2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
/// and `__ltdf2`.
fn __cmpdf2(a: f64, b: f64) callconv(.c) i32 {
return @intFromEnum(comparef.cmpf2(f64, comparef.LE, a, b));
return @backingInt(comparef.cmpf2(f64, comparef.LE, a, b));
}

/// "These functions return a value less than or equal to zero if neither argument is NaN,
Expand Down
2 changes: 1 addition & 1 deletion build/compiler_rt/cmphf2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ comptime {
/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
/// and `__lthf2`.
fn __cmphf2(a: f16, b: f16) callconv(.c) i32 {
return @intFromEnum(comparef.cmpf2(f16, comparef.LE, a, b));
return @backingInt(comparef.cmpf2(f16, comparef.LE, a, b));
}

/// "These functions return a value less than or equal to zero if neither argument is NaN,
Expand Down
2 changes: 1 addition & 1 deletion build/compiler_rt/cmpsf2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ comptime {
/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
/// and `__ltsf2`.
fn __cmpsf2(a: f32, b: f32) callconv(.c) i32 {
return @intFromEnum(comparef.cmpf2(f32, comparef.LE, a, b));
return @backingInt(comparef.cmpf2(f32, comparef.LE, a, b));
}

/// "These functions return a value less than or equal to zero if neither argument is NaN,
Expand Down
16 changes: 8 additions & 8 deletions build/compiler_rt/cmptf2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ comptime {
/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
/// and `__lttf2`.
fn __cmptf2(a: f128, b: f128) callconv(.c) i32 {
return @intFromEnum(comparef.cmpf2(f128, comparef.LE, a, b));
return @backingInt(comparef.cmpf2(f128, comparef.LE, a, b));
}

/// "These functions return a value less than or equal to zero if neither argument is NaN,
Expand Down Expand Up @@ -71,34 +71,34 @@ const SparcFCMP = enum(i32) {
};

fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.c) i32 {
return @intFromEnum(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
return @backingInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
}

fn _Qp_feq(a: *const f128, b: *const f128) callconv(.c) bool {
return @as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b))) == .Equal;
return @as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b)))) == .Equal;
}

fn _Qp_fne(a: *const f128, b: *const f128) callconv(.c) bool {
return @as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b))) != .Equal;
return @as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b)))) != .Equal;
}

fn _Qp_flt(a: *const f128, b: *const f128) callconv(.c) bool {
return @as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b))) == .Less;
return @as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b)))) == .Less;
}

fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.c) bool {
return @as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b))) == .Greater;
return @as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b)))) == .Greater;
}

fn _Qp_fge(a: *const f128, b: *const f128) callconv(.c) bool {
return switch (@as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b)))) {
return switch (@as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b))))) {
.Equal, .Greater => true,
.Less, .Unordered => false,
};
}

fn _Qp_fle(a: *const f128, b: *const f128) callconv(.c) bool {
return switch (@as(SparcFCMP, @enumFromInt(_Qp_cmp(a, b)))) {
return switch (@as(SparcFCMP, @fromBackingInt(@intCast(_Qp_cmp(a, b))))) {
.Equal, .Less => true,
.Greater, .Unordered => false,
};
Expand Down
Loading
Loading