Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
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
4 changes: 4 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn build(b: *std.Build) void {
const skip_run_translated = b.option(bool, "skip-run-translated", "Main test suite skips run-translated tests") orelse false;
const test_cross_targets = b.option(bool, "test-cross-targets", "Include cross-translation targets in the test cases") orelse false;
const use_llvm = b.option(bool, "llvm", "Use LLVM backend to generate aro executable");
const link_libc = b.option(bool, "link-libc", "Link libc") orelse (optimize != .Debug);

const aro = b.dependency("aro", .{
.target = target,
Expand Down Expand Up @@ -40,6 +41,9 @@ pub fn build(b: *std.Build) void {
.use_llvm = use_llvm,
.use_lld = use_llvm,
});
if (link_libc) {
translate_c_exe.linkLibC();
}

b.installDirectory(.{
.source_dir = aro.path("include"),
Expand Down
11 changes: 8 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ const Translator = @import("Translator.zig");

const fast_exit = @import("builtin").mode != .Debug;

var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;

pub fn main() u8 {
const gpa = general_purpose_allocator.allocator();
defer _ = general_purpose_allocator.deinit();
const gpa = if (@import("builtin").link_libc)
std.heap.raw_c_allocator
else
debug_allocator.allocator();
defer if (!@import("builtin").link_libc) {
_ = debug_allocator.deinit();
};

var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena_instance.deinit();
Expand Down