mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:34:45 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user