/
githubmirror
/
carbon-lang
Обзор
Документация
Войти
/
githubmirror
/
carbon-lang
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
toolchain/driver/link_options.cpp
98 строк
3 KB
Lucile Rose Nihlen
precompile and cache Carbon prelude (#7432)
16 июл 2026, 21:02
Не верифицирован
16 июл 2026, 21:02
625f2ca
Код
Авторство
О чём код?
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "toolchain/driver/link_options.h" namespace Carbon { namespace { auto BuildSharedOptions(CommandLine::CommandBuilder& b, LinkOptions* options) -> void { b.AddStringPositionalArg( { .name = "EXTRA_CLANG_LINK_ARGS", .help = R"""( Extra arguments to pass to Clang when forming the link command. This is primarily useful for expanding `LDFLAGS` or other baseline linking flags in a build system. These can also be used to pass object files to the link in the event your build system mixes object files and linker flags. )""", }, [&](auto& arg_b) { arg_b.Append(&options->extra_clang_args); }); } } // namespace auto LinkOptions::BuildForLinkSubcommand(CommandLine::CommandBuilder& b, CodegenOptions* cg_options) -> void { b.AddStringPositionalArg( { .name = "OBJECT_FILE", .help = R"""( The input object files. If empty, there must be extra Clang link arguments that provide object files intermingled with linking flags. )""", }, [&](auto& arg_b) { arg_b.Append(&object_filenames); }); b.AddStringOption( { .name = "output", .value_name = "FILE", .help = R"""( The linked file name. The output is always a linked binary. If not provided, there must be extra Clang link arguments that include specifying the output of the link. This allows supporting build systems that intermingle the output flag with arbitrary other linker flags that need to use legacy parsing logic. )""", }, [&](auto& arg_b) { arg_b.Set(&output_filename); }); 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); }); BuildSharedOptions(b, this); cg_options->Build(b); codegen_options = cg_options; } auto LinkOptions::BuildForBuildSubcommand(CommandLine::CommandBuilder& b, CodegenOptions* cg_options) -> void { codegen_options = cg_options; b.AddStringOption( { .name = "output", .short_name = "o", .value_name = "FILE", .help = R"""( The file name for the output binary. If none is specified, `build` will use the 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