lld_subcommand.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_DRIVER_LLD_SUBCOMMAND_H_
  5. #define CARBON_TOOLCHAIN_DRIVER_LLD_SUBCOMMAND_H_
  6. #include "common/command_line.h"
  7. #include "llvm/ADT/SmallVector.h"
  8. #include "llvm/ADT/StringRef.h"
  9. #include "toolchain/driver/driver_env.h"
  10. #include "toolchain/driver/driver_subcommand.h"
  11. namespace Carbon {
  12. // Options for the LLD subcommand, which is just a thin wrapper.
  13. //
  14. // See the implementation of `Build` for documentation on members.
  15. struct LldOptions {
  16. // Supported linking platforms.
  17. //
  18. // Note that these are similar to the object formats in an LLVM triple, but we
  19. // use a distinct enum because we only include the platforms supported by our
  20. // subcommand which is a subset of those recognized by the LLVM triple
  21. // infrastructure.
  22. enum class Platform {
  23. Elf,
  24. MachO,
  25. };
  26. auto Build(CommandLine::CommandBuilder& b) -> void;
  27. Platform platform;
  28. llvm::SmallVector<llvm::StringRef> args;
  29. };
  30. // Implements the LLD subcommand of the driver.
  31. class LldSubcommand : public DriverSubcommand {
  32. public:
  33. explicit LldSubcommand();
  34. auto BuildOptions(CommandLine::CommandBuilder& b) -> void override {
  35. options_.Build(b);
  36. }
  37. auto Run(DriverEnv& driver_env) -> DriverResult override;
  38. private:
  39. LldOptions options_;
  40. };
  41. } // namespace Carbon
  42. #endif // CARBON_TOOLCHAIN_DRIVER_LLD_SUBCOMMAND_H_