Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions llvm/include/llvm/WindowsDriver/MSVCPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/Triple.h"
#include <optional>
#include <string>
Expand All @@ -36,74 +37,81 @@ enum class ToolsetLayout {
// Windows SDKs and VC Toolchains group their contents into subdirectories based
// on the target architecture. This function converts an llvm::Triple::ArchType
// to the corresponding subdirectory name.
const char *archToWindowsSDKArch(llvm::Triple::ArchType Arch);
LLVM_ABI const char *archToWindowsSDKArch(llvm::Triple::ArchType Arch);

// Similar to the above function, but for Visual Studios before VS2017.
const char *archToLegacyVCArch(llvm::Triple::ArchType Arch);
LLVM_ABI const char *archToLegacyVCArch(llvm::Triple::ArchType Arch);

// Similar to the above function, but for DevDiv internal builds.
const char *archToDevDivInternalArch(llvm::Triple::ArchType Arch);
LLVM_ABI const char *archToDevDivInternalArch(llvm::Triple::ArchType Arch);

bool appendArchToWindowsSDKLibPath(int SDKMajor, llvm::SmallString<128> LibPath,
llvm::Triple::ArchType Arch,
std::string &path);
LLVM_ABI bool appendArchToWindowsSDKLibPath(int SDKMajor,
llvm::SmallString<128> LibPath,
llvm::Triple::ArchType Arch,
std::string &path);

// Get the path to a specific subdirectory in the current toolchain for
// a given target architecture.
// VS2017 changed the VC toolchain layout, so this should be used instead
// of hardcoding paths.
std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout,
const std::string &VCToolChainPath,
llvm::Triple::ArchType TargetArch,
llvm::StringRef SubdirParent = "");
LLVM_ABI std::string getSubDirectoryPath(SubDirectoryType Type,
ToolsetLayout VSLayout,
const std::string &VCToolChainPath,
llvm::Triple::ArchType TargetArch,
llvm::StringRef SubdirParent = "");

// Check if the Include path of a specified version of Visual Studio contains
// specific header files. If not, they are probably shipped with Universal CRT.
bool useUniversalCRT(ToolsetLayout VSLayout, const std::string &VCToolChainPath,
llvm::Triple::ArchType TargetArch,
llvm::vfs::FileSystem &VFS);
LLVM_ABI bool useUniversalCRT(ToolsetLayout VSLayout,
const std::string &VCToolChainPath,
llvm::Triple::ArchType TargetArch,
llvm::vfs::FileSystem &VFS);

/// Get Windows SDK installation directory.
bool getWindowsSDKDir(vfs::FileSystem &VFS,
LLVM_ABI bool getWindowsSDKDir(vfs::FileSystem &VFS,
std::optional<llvm::StringRef> WinSdkDir,
std::optional<llvm::StringRef> WinSdkVersion,
std::optional<llvm::StringRef> WinSysRoot,
std::string &Path, int &Major,
std::string &WindowsSDKIncludeVersion,
std::string &WindowsSDKLibVersion);

LLVM_ABI bool
getUniversalCRTSdkDir(vfs::FileSystem &VFS,
std::optional<llvm::StringRef> WinSdkDir,
std::optional<llvm::StringRef> WinSdkVersion,
std::optional<llvm::StringRef> WinSysRoot,
std::string &Path, int &Major,
std::string &WindowsSDKIncludeVersion,
std::string &WindowsSDKLibVersion);

bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
std::optional<llvm::StringRef> WinSdkDir,
std::optional<llvm::StringRef> WinSdkVersion,
std::optional<llvm::StringRef> WinSysRoot,
std::string &Path, std::string &UCRTVersion);
std::string &Path, std::string &UCRTVersion);

// Check command line arguments to try and find a toolchain.
bool findVCToolChainViaCommandLine(
vfs::FileSystem &VFS, std::optional<llvm::StringRef> VCToolsDir,
std::optional<llvm::StringRef> VCToolsVersion,
std::optional<llvm::StringRef> WinSysRoot, std::string &Path,
ToolsetLayout &VSLayout);
LLVM_ABI bool
findVCToolChainViaCommandLine(vfs::FileSystem &VFS,
std::optional<llvm::StringRef> VCToolsDir,
std::optional<llvm::StringRef> VCToolsVersion,
std::optional<llvm::StringRef> WinSysRoot,
std::string &Path, ToolsetLayout &VSLayout);

// Check various environment variables to try and find a toolchain.
bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS, std::string &Path,
ToolsetLayout &VSLayout);
LLVM_ABI bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS,
std::string &Path,
ToolsetLayout &VSLayout);

// Query the Setup Config server for installs, then pick the newest version
// and find its default VC toolchain. If `VCToolsVersion` is specified, that
// version is preferred over the latest version.
//
// This is the preferred way to discover new Visual Studios, as they're no
// longer listed in the registry.
bool
LLVM_ABI bool
findVCToolChainViaSetupConfig(vfs::FileSystem &VFS,
std::optional<llvm::StringRef> VCToolsVersion,
std::string &Path, ToolsetLayout &VSLayout);

// Look in the registry for Visual Studio installs, and use that to get
// a toolchain path. VS2017 and newer don't get added to the registry.
// So if we find something here, we know that it's an older version.
bool findVCToolChainViaRegistry(std::string &Path, ToolsetLayout &VSLayout);
LLVM_ABI bool findVCToolChainViaRegistry(std::string &Path,
ToolsetLayout &VSLayout);

} // namespace llvm

Expand Down
14 changes: 8 additions & 6 deletions llvm/include/llvm/WindowsManifest/WindowsManifestMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
#define LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H

#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"

namespace llvm {
Expand All @@ -34,9 +35,10 @@ class MemoryBufferRef;

namespace windows_manifest {

bool isAvailable();
LLVM_ABI bool isAvailable();

class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
class LLVM_ABI WindowsManifestError
: public ErrorInfo<WindowsManifestError, ECError> {
public:
static char ID;
WindowsManifestError(const Twine &Msg);
Expand All @@ -48,13 +50,13 @@ class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {

class WindowsManifestMerger {
public:
WindowsManifestMerger();
~WindowsManifestMerger();
Error merge(MemoryBufferRef Manifest);
LLVM_ABI WindowsManifestMerger();
LLVM_ABI ~WindowsManifestMerger();
LLVM_ABI Error merge(MemoryBufferRef Manifest);

// Returns vector containing merged xml manifest, or uninitialized vector for
// empty manifest.
std::unique_ptr<MemoryBuffer> getMergedManifest();
LLVM_ABI std::unique_ptr<MemoryBuffer> getMergedManifest();

private:
class WindowsManifestMergerImpl;
Expand Down
Loading