This repository was archived by the owner on Nov 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ pub fn build(b: *std.Build) void {
77 const skip_run_translated = b .option (bool , "skip-run-translated" , "Main test suite skips run-translated tests" ) orelse false ;
88 const test_cross_targets = b .option (bool , "test-cross-targets" , "Include cross-translation targets in the test cases" ) orelse false ;
99 const use_llvm = b .option (bool , "llvm" , "Use LLVM backend to generate aro executable" );
10+ const link_libc = b .option (bool , "link-libc" , "Link libc" ) orelse (optimize != .Debug );
1011
1112 const aro = b .dependency ("aro" , .{
1213 .target = target ,
@@ -40,6 +41,9 @@ pub fn build(b: *std.Build) void {
4041 .use_llvm = use_llvm ,
4142 .use_lld = use_llvm ,
4243 });
44+ if (link_libc ) {
45+ translate_c_exe .linkLibC ();
46+ }
4347
4448 b .installDirectory (.{
4549 .source_dir = aro .path ("include" ),
Original file line number Diff line number Diff line change @@ -7,11 +7,16 @@ const Translator = @import("Translator.zig");
77
88const fast_exit = @import ("builtin" ).mode != .Debug ;
99
10- var general_purpose_allocator : std .heap .GeneralPurposeAllocator (.{}) = .init ;
10+ var debug_allocator : std .heap .DebugAllocator (.{}) = .init ;
1111
1212pub fn main () u8 {
13- const gpa = general_purpose_allocator .allocator ();
14- defer _ = general_purpose_allocator .deinit ();
13+ const gpa = if (@import ("builtin" ).link_libc )
14+ std .heap .raw_c_allocator
15+ else
16+ debug_allocator .allocator ();
17+ defer if (! @import ("builtin" ).link_libc ) {
18+ _ = debug_allocator .deinit ();
19+ };
1520
1621 var arena_instance = std .heap .ArenaAllocator .init (std .heap .page_allocator );
1722 defer arena_instance .deinit ();
You can’t perform that action at this time.
0 commit comments