mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
This removes the separately built and installed LLD binary. The symlinks used by Clang when directly invoking LLD now point back to the main `carbon-busybox` binary and dispatch through the newly added subcommand. With this change we're down to shipping a single busybox binary in the toolchain, removing duplicate installed copies of LLD and all its LLVM dependencies. =] The LLD subcommand works a bit differently from the `clang` subcommand because the CLI for LLD is specific to which platform flavor of linker is being invoked. As part of this, I've extracted some of the common functionality in the Clang runner into a base class that can be re-used. I expect to use this again in a follow-up change to add subcommands to run other LLVM tools. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
55 lines
1.5 KiB
C++
55 lines
1.5 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_LLD_SUBCOMMAND_H_
|
|
#define CARBON_TOOLCHAIN_DRIVER_LLD_SUBCOMMAND_H_
|
|
|
|
#include "common/command_line.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "toolchain/driver/driver_env.h"
|
|
#include "toolchain/driver/driver_subcommand.h"
|
|
|
|
namespace Carbon {
|
|
|
|
// Options for the LLD subcommand, which is just a thin wrapper.
|
|
//
|
|
// See the implementation of `Build` for documentation on members.
|
|
struct LldOptions {
|
|
// Supported linking platforms.
|
|
//
|
|
// Note that these are similar to the object formats in an LLVM triple, but we
|
|
// use a distinct enum because we only include the platforms supported by our
|
|
// subcommand which is a subset of those recognized by the LLVM triple
|
|
// infrastructure.
|
|
enum class Platform {
|
|
Elf,
|
|
MachO,
|
|
};
|
|
|
|
auto Build(CommandLine::CommandBuilder& b) -> void;
|
|
|
|
Platform platform;
|
|
llvm::SmallVector<llvm::StringRef> args;
|
|
};
|
|
|
|
// Implements the LLD subcommand of the driver.
|
|
class LldSubcommand : public DriverSubcommand {
|
|
public:
|
|
explicit LldSubcommand();
|
|
|
|
auto BuildOptions(CommandLine::CommandBuilder& b) -> void override {
|
|
options_.Build(b);
|
|
}
|
|
|
|
auto Run(DriverEnv& driver_env) -> DriverResult override;
|
|
|
|
private:
|
|
LldOptions options_;
|
|
};
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_TOOLCHAIN_DRIVER_LLD_SUBCOMMAND_H_
|