Files
carbon-lang/toolchain/driver/lld_runner.h
T
Chandler CarruthandJon Ross-Perkins 8d1d491ad0 Add LLD subcommand and busybox support (#4973)
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>
2025-02-21 04:26:45 +00:00

37 lines
1.2 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_RUNNER_H_
#define CARBON_TOOLCHAIN_DRIVER_LLD_RUNNER_H_
#include "common/ostream.h"
#include "lld/Common/Driver.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/driver/tool_runner_base.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
// Runs LLD in a manner similar to invoking it with the provided arguments.
class LldRunner : ToolRunnerBase {
public:
using ToolRunnerBase::ToolRunnerBase;
// Run LLD as a GNU-style linker with the provided arguments.
auto ElfLink(llvm::ArrayRef<llvm::StringRef> args) -> bool;
// Run LLD as a Darwin-style linker with the provided arguments.
auto MachOLink(llvm::ArrayRef<llvm::StringRef> args) -> bool;
private:
auto LinkHelper(llvm::StringLiteral label,
llvm::ArrayRef<llvm::StringRef> args, const std::string& path,
lld::DriverDef driver_def) -> bool;
};
} // namespace Carbon
#endif // CARBON_TOOLCHAIN_DRIVER_LLD_RUNNER_H_