mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 14:00:11 +01:00
Add an optional additional set of positional parameters that can be passed to the `link` subcommand for Clang-style (or GCC-style) `LDFLAGS`. These can _also_ contain object files, etc., and in fact it is useful to allow them to contain object files in order to integrate the `carbon link` subcommand into a build system that mixes both link flags and object files. This at least happens with Bazel, and I suspect is common. Eventually, it would be nice to have sufficient semantics to handle all the varieties of links we want without resorting to this escape hatch, but that's likely a long way away and so it seems especially useful to allow falling back to Clang's flags as needed for now. This does somewhat directly surface the Clang implementation detail in the command line syntax, but I don't see a lot of good alternatives. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
// 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
|
|
|
|
#ifndef CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_
|
|
#define CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_
|
|
|
|
#include "common/command_line.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "toolchain/driver/codegen_options.h"
|
|
#include "toolchain/driver/driver_env.h"
|
|
#include "toolchain/driver/driver_subcommand.h"
|
|
|
|
namespace Carbon {
|
|
|
|
// Options for the link subcommand.
|
|
//
|
|
// See the implementation of `Build` for documentation on members.
|
|
struct LinkOptions {
|
|
auto Build(CommandLine::CommandBuilder& b) -> void;
|
|
|
|
CodegenOptions codegen_options;
|
|
llvm::StringRef output_filename;
|
|
llvm::SmallVector<llvm::StringRef> object_filenames;
|
|
|
|
llvm::SmallVector<llvm::StringRef> extra_clang_args;
|
|
};
|
|
|
|
// Implements the link subcommand of the driver.
|
|
class LinkSubcommand : public DriverSubcommand {
|
|
public:
|
|
explicit LinkSubcommand();
|
|
|
|
auto BuildOptions(CommandLine::CommandBuilder& b) -> void override {
|
|
options_.Build(b);
|
|
}
|
|
|
|
auto Run(DriverEnv& driver_env) -> DriverResult override;
|
|
|
|
private:
|
|
LinkOptions options_;
|
|
};
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_
|