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
@@ -5,6 +5,7 @@
#include "toolchain/driver/build_runtimes_subcommand.h"
#include "llvm/TargetParser/Triple.h"
#include "toolchain/driver/carbon_runtimes.h"
#include "toolchain/driver/clang_runner.h"
#include "toolchain/driver/clang_runtimes.h"
@@ -97,6 +98,7 @@ auto BuildRuntimesSubcommand::RunInternal(DriverEnv& driver_env)
CARBON_RETURN_IF_ERROR(runtimes.Remove(Runtimes::ClangResourceDir));
CARBON_RETURN_IF_ERROR(runtimes.Remove(Runtimes::LibUnwind));
CARBON_RETURN_IF_ERROR(runtimes.Remove(Runtimes::Libcxx));
CARBON_RETURN_IF_ERROR(runtimes.Remove(Runtimes::CarbonCore));
}
ClangResourceDirBuilder resource_dir_builder(&runner, driver_env.thread_pool,
@@ -108,10 +110,13 @@ auto BuildRuntimesSubcommand::RunInternal(DriverEnv& driver_env)
ClangArchiveRuntimesBuilder<Runtimes::Libcxx> libcxx_builder(
&runner, driver_env.thread_pool, llvm::Triple(features.target),
&runtimes);
CarbonPreludeBuilder prelude_builder(&driver_env, &runtimes,
&options_.codegen_options);
CARBON_RETURN_IF_ERROR(std::move(resource_dir_builder).Wait());
CARBON_RETURN_IF_ERROR(std::move(lib_unwind_builder).Wait());
CARBON_RETURN_IF_ERROR(std::move(libcxx_builder).Wait());
CARBON_RETURN_IF_ERROR(std::move(prelude_builder).Build());
return runtimes.base_path();
}