Skip to content

Commit

Permalink
Merge pull request #19122 from ziglang/lazy-aro
Browse files Browse the repository at this point in the history
make aro-based translate-c lazily built from source
  • Loading branch information
andrewrk authored Feb 29, 2024
2 parents 69df00f + 49437d3 commit f5aad47
Show file tree
Hide file tree
Showing 68 changed files with 16,578 additions and 22,667 deletions.
16 changes: 1 addition & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,8 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/src/target.zig"
"${CMAKE_SOURCE_DIR}/src/tracy.zig"
"${CMAKE_SOURCE_DIR}/src/translate_c.zig"
"${CMAKE_SOURCE_DIR}/src/translate_c/ast.zig"
"${CMAKE_SOURCE_DIR}/src/type.zig"
"${CMAKE_SOURCE_DIR}/src/wasi_libc.zig"
"${CMAKE_SOURCE_DIR}/src/stubs/aro_builtins.zig"
"${CMAKE_SOURCE_DIR}/src/stubs/aro_names.zig"
)

if(MSVC)
Expand Down Expand Up @@ -822,18 +819,7 @@ set(BUILD_ZIG2_ARGS
--dep "aro"
--mod "root" "src/main.zig"
--mod "build_options" "${ZIG_CONFIG_ZIG_OUT}"
--mod "aro_options" "src/stubs/aro_options.zig"
--mod "Builtins/Builtin.def" "src/stubs/aro_builtins.zig"
--mod "Attribute/names.def" "src/stubs/aro_names.zig"
--mod "Diagnostics/messages.def" "src/stubs/aro_messages.zig"
--dep "build_options=aro_options"
--mod "aro_backend" "deps/aro/backend.zig"
--dep "Builtins/Builtin.def"
--dep "Attribute/names.def"
--dep "Diagnostics/messages.def"
--dep "build_options=aro_options"
--dep "backend=aro_backend"
--mod "aro" "deps/aro/aro.zig"
--mod "aro" "lib/compiler/aro/aro.zig"
)

add_custom_command(
Expand Down
16 changes: 1 addition & 15 deletions bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,8 @@ int main(int argc, char **argv) {
"--dep", "build_options",
"--dep", "aro",
"--mod", "root", "src/main.zig",

"--mod", "build_options", "config.zig",
"--mod", "aro_options", "src/stubs/aro_options.zig",
"--mod", "Builtins/Builtin.def", "src/stubs/aro_builtins.zig",
"--mod", "Attribute/names.def", "src/stubs/aro_names.zig",
"--mod", "Diagnostics/messages.def", "src/stubs/aro_messages.zig",

"--dep", "build_options=aro_options",
"--mod", "aro_backend", "deps/aro/backend.zig",

"--dep", "Builtins/Builtin.def",
"--dep", "Attribute/names.def",
"--dep", "Diagnostics/messages.def",
"--dep", "build_options=aro_options",
"--dep", "backend=aro_backend",
"--mod", "aro", "deps/aro/aro.zig",
"--mod", "aro", "lib/compiler/aro/aro.zig",
NULL,
};
print_and_run(child_argv);
Expand Down
29 changes: 8 additions & 21 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const io = std.io;
const fs = std.fs;
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
const assert = std.debug.assert;
const GenerateDef = @import("deps/aro/build/GenerateDef.zig");

const zig_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 0 };
const stack_size = 32 * 1024 * 1024;
Expand Down Expand Up @@ -636,34 +635,22 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
});
exe.stack_size = stack_size;

const aro_options = b.addOptions();
aro_options.addOption([]const u8, "version_str", "aro-zig");
const aro_options_module = aro_options.createModule();
const aro_backend = b.createModule(.{
.root_source_file = .{ .path = "deps/aro/backend.zig" },
.imports = &.{.{
.name = "build_options",
.module = aro_options_module,
}},
});
const aro_module = b.createModule(.{
.root_source_file = .{ .path = "deps/aro/aro.zig" },
.root_source_file = .{ .path = "lib/compiler/aro/aro.zig" },
});

const aro_translate_c_module = b.createModule(.{
.root_source_file = .{ .path = "lib/compiler/aro_translate_c.zig" },
.imports = &.{
.{
.name = "build_options",
.module = aro_options_module,
},
.{
.name = "backend",
.module = aro_backend,
.name = "aro",
.module = aro_module,
},
GenerateDef.create(b, .{ .name = "Builtins/Builtin.def", .src_prefix = "deps/aro/aro" }),
GenerateDef.create(b, .{ .name = "Attribute/names.def", .src_prefix = "deps/aro/aro" }),
GenerateDef.create(b, .{ .name = "Diagnostics/messages.def", .src_prefix = "deps/aro/aro", .kind = .named }),
},
});

exe.root_module.addImport("aro", aro_module);
exe.root_module.addImport("aro_translate_c", aro_translate_c_module);
return exe;
}

Expand Down
Loading

0 comments on commit f5aad47

Please sign in to comment.