precompile and cache Carbon prelude (#7432)

Refactors the link driver to automatically compile and cache the carbon
prelude for use in linking.

Implements a `carbon_library` rule for compiling the Core library
dependencies in the examples.
This commit is contained in:
Lucile Rose Nihlen
2026-07-16 18:02:14 +00:00
committed by GitHub
parent 90f6654b48
commit 625f2ca629
63 changed files with 1454 additions and 634 deletions
+23 -7
View File
@@ -27,8 +27,8 @@ system mixes object files and linker flags.
} // namespace
auto LinkOptions::BuildForLinkSubcommand(CommandLine::CommandBuilder& b)
-> void {
auto LinkOptions::BuildForLinkSubcommand(CommandLine::CommandBuilder& b,
CodegenOptions* cg_options) -> void {
b.AddStringPositionalArg(
{
.name = "OBJECT_FILE",
@@ -56,14 +56,27 @@ legacy parsing logic.
},
[&](auto& arg_b) { arg_b.Set(&output_filename); });
BuildSharedOptions(b, this);
b.AddFlag(
{
.name = "link_prelude_files",
.help = R"""(
Automatically include the Carbon prelude files in the link.
)""",
},
[&](auto& arg_b) {
arg_b.Default(true);
arg_b.Set(&link_prelude_files);
});
codegen_options = std::make_shared<CodegenOptions>();
codegen_options->Build(b);
BuildSharedOptions(b, this);
cg_options->Build(b);
codegen_options = cg_options;
}
auto LinkOptions::BuildForBuildSubcommand(CommandLine::CommandBuilder& b)
-> void {
auto LinkOptions::BuildForBuildSubcommand(CommandLine::CommandBuilder& b,
CodegenOptions* cg_options) -> void {
codegen_options = cg_options;
b.AddStringOption(
{
.name = "output",
@@ -77,6 +90,9 @@ name of the first provided input file.
[&](auto& arg_b) { arg_b.Set(&output_filename); });
BuildSharedOptions(b, this);
// The prelude files have already been built and are part of the input binary
// set, so will already be linked through that path.
link_prelude_files = false;
}
} // namespace Carbon