brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 5c17edc Raw
153 lines · c
1//===--- MSVC.h - MSVC ToolChain Implementations ----------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H11 12#include "clang/Driver/Compilation.h"13#include "clang/Driver/CudaInstallationDetector.h"14#include "clang/Driver/LazyDetector.h"15#include "clang/Driver/RocmInstallationDetector.h"16#include "clang/Driver/SyclInstallationDetector.h"17#include "clang/Driver/Tool.h"18#include "clang/Driver/ToolChain.h"19#include "llvm/Frontend/Debug/Options.h"20#include "llvm/WindowsDriver/MSVCPaths.h"21 22namespace clang {23namespace driver {24namespace tools {25 26/// Visual studio tools.27namespace visualstudio {28class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {29public:30  Linker(const ToolChain &TC) : Tool("visualstudio::Linker", "linker", TC) {}31 32  bool hasIntegratedCPP() const override { return false; }33  bool isLinkJob() const override { return true; }34 35  void ConstructJob(Compilation &C, const JobAction &JA,36                    const InputInfo &Output, const InputInfoList &Inputs,37                    const llvm::opt::ArgList &TCArgs,38                    const char *LinkingOutput) const override;39};40} // end namespace visualstudio41 42} // end namespace tools43 44namespace toolchains {45 46class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {47public:48  MSVCToolChain(const Driver &D, const llvm::Triple &Triple,49                const llvm::opt::ArgList &Args);50 51  llvm::opt::DerivedArgList *52  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,53                Action::OffloadKind DeviceOffloadKind) const override;54 55  UnwindTableLevel56  getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;57  bool isPICDefault() const override;58  bool isPIEDefault(const llvm::opt::ArgList &Args) const override;59  bool isPICDefaultForced() const override;60 61  /// Set CodeView as the default debug info format for non-MachO binary62  /// formats, and to DWARF otherwise. Users can use -gcodeview and -gdwarf to63  /// override the default.64  llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {65    return getTriple().isOSBinFormatCOFF() ? llvm::codegenoptions::DIF_CodeView66                                           : llvm::codegenoptions::DIF_DWARF;67  }68 69  /// Set the debugger tuning to "default", since we're definitely not tuning70  /// for GDB.71  llvm::DebuggerKind getDefaultDebuggerTuning() const override {72    return llvm::DebuggerKind::Default;73  }74 75  unsigned GetDefaultDwarfVersion() const override {76    return 4;77  }78 79  std::string getSubDirectoryPath(llvm::SubDirectoryType Type,80                                  llvm::StringRef SubdirParent = "") const;81  std::string getSubDirectoryPath(llvm::SubDirectoryType Type,82                                  llvm::Triple::ArchType TargetArch) const;83 84  bool getIsVS2017OrNewer() const {85    return VSLayout == llvm::ToolsetLayout::VS2017OrNewer;86  }87 88  void89  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,90                            llvm::opt::ArgStringList &CC1Args) const override;91  void AddClangCXXStdlibIncludeArgs(92      const llvm::opt::ArgList &DriverArgs,93      llvm::opt::ArgStringList &CC1Args) const override;94 95  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,96                          llvm::opt::ArgStringList &CC1Args) const override;97 98  void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,99                         llvm::opt::ArgStringList &CC1Args) const override;100 101  void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args,102                            llvm::opt::ArgStringList &CmdArgs) const override;103 104  void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,105                          llvm::opt::ArgStringList &CC1Args) const override;106 107  bool getWindowsSDKLibraryPath(108      const llvm::opt::ArgList &Args, std::string &path) const;109  bool getUniversalCRTLibraryPath(const llvm::opt::ArgList &Args,110                                  std::string &path) const;111  bool useUniversalCRT() const;112  VersionTuple113  computeMSVCVersion(const Driver *D,114                     const llvm::opt::ArgList &Args) const override;115 116  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,117                                          types::ID InputType) const override;118  SanitizerMask getSupportedSanitizers() const override;119 120  void printVerboseInfo(raw_ostream &OS) const override;121 122  bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); }123 124  void125  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,126                        llvm::opt::ArgStringList &CC1Args,127                        Action::OffloadKind DeviceOffloadKind) const override;128 129protected:130  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,131                                     llvm::opt::ArgStringList &CC1Args,132                                     const std::string &folder,133                                     const Twine &subfolder1,134                                     const Twine &subfolder2 = "",135                                     const Twine &subfolder3 = "") const;136 137  Tool *buildLinker() const override;138  Tool *buildAssembler() const override;139private:140  std::optional<llvm::StringRef> WinSdkDir, WinSdkVersion, WinSysRoot;141  std::string VCToolChainPath;142  llvm::ToolsetLayout VSLayout = llvm::ToolsetLayout::OlderVS;143  LazyDetector<CudaInstallationDetector> CudaInstallation;144  LazyDetector<RocmInstallationDetector> RocmInstallation;145  LazyDetector<SYCLInstallationDetector> SYCLInstallation;146};147 148} // end namespace toolchains149} // end namespace driver150} // end namespace clang151 152#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H153