aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-02-27 22:06:11 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-02-28 13:21:05 -0700
commit240d0b68f62c4fd3562649ec7fc29a51be3698d7 (patch)
treee0c2a736cff252ccc9c7722754efa686cd1ba315 /build.zig
parent9410b11ca663231e367e3adfd668979c4b870a41 (diff)
downloadzig-240d0b68f62c4fd3562649ec7fc29a51be3698d7.tar.gz
zig-240d0b68f62c4fd3562649ec7fc29a51be3698d7.zip
make aro-based translate-c lazily built from source
Part of #19063. Primarily, this moves Aro from deps/ to lib/compiler/ so that it can be lazily compiled from source. src/aro_translate_c.zig is moved to lib/compiler/aro_translate_c.zig and some of Zig CLI logic moved to a main() function there. aro_translate_c.zig becomes the "common" import for clang-based translate-c. Not all of the compiler was able to be detangled from Aro, however, so it still, for now, remains being compiled with the main compiler sources due to the clang-based translate-c depending on it. Once aro-based translate-c achieves feature parity with the clang-based translate-c implementation, the clang-based one can be removed from Zig. Aro made it unnecessarily difficult to depend on with these .def files and all these Zig module requirements. I looked at the .def files and made these observations: - The canonical source is llvm .def files. - Therefore there is an update process to sync with llvm that involves regenerating the .def files in Aro. - Therefore you might as well just regenerate the .zig files directly and check those into Aro. - Also with a small amount of tinkering, the file size on disk of these generated .zig files can be made many times smaller, without compromising type safety in the usage of the data. This would make things much easier on Zig as downstream project, particularly we could remove those pesky stubs when bootstrapping. I have gone ahead with these changes since they unblock me and I will have a chat with Vexu to see what he thinks.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig29
1 files changed, 8 insertions, 21 deletions
diff --git a/build.zig b/build.zig
index 9179d3d959..584269822d 100644
--- a/build.zig
+++ b/build.zig
@@ -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;
@@ -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;
}