Skip to content

Commit f1c410b

Browse files
andrurogerzAnthony Tran
authored andcommitted
[llvm] annotate WindowsDriver and WIndowsManifest interfaces for DLL export (llvm#145567)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the WindowsDriver and WindowsManifest interfaces. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in llvm#109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Overview These changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
1 parent 953d3cc commit f1c410b

File tree

2 files changed

+48
-38
lines changed

2 files changed

+48
-38
lines changed

llvm/include/llvm/WindowsDriver/MSVCPaths.h

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

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

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

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

47-
bool appendArchToWindowsSDKLibPath(int SDKMajor, llvm::SmallString<128> LibPath,
48-
llvm::Triple::ArchType Arch,
49-
std::string &path);
48+
LLVM_ABI bool appendArchToWindowsSDKLibPath(int SDKMajor,
49+
llvm::SmallString<128> LibPath,
50+
llvm::Triple::ArchType Arch,
51+
std::string &path);
5052

5153
// Get the path to a specific subdirectory in the current toolchain for
5254
// a given target architecture.
5355
// VS2017 changed the VC toolchain layout, so this should be used instead
5456
// of hardcoding paths.
55-
std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout,
56-
const std::string &VCToolChainPath,
57-
llvm::Triple::ArchType TargetArch,
58-
llvm::StringRef SubdirParent = "");
57+
LLVM_ABI std::string getSubDirectoryPath(SubDirectoryType Type,
58+
ToolsetLayout VSLayout,
59+
const std::string &VCToolChainPath,
60+
llvm::Triple::ArchType TargetArch,
61+
llvm::StringRef SubdirParent = "");
5962

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

6670
/// Get Windows SDK installation directory.
67-
bool getWindowsSDKDir(vfs::FileSystem &VFS,
71+
LLVM_ABI bool getWindowsSDKDir(vfs::FileSystem &VFS,
72+
std::optional<llvm::StringRef> WinSdkDir,
73+
std::optional<llvm::StringRef> WinSdkVersion,
74+
std::optional<llvm::StringRef> WinSysRoot,
75+
std::string &Path, int &Major,
76+
std::string &WindowsSDKIncludeVersion,
77+
std::string &WindowsSDKLibVersion);
78+
79+
LLVM_ABI bool
80+
getUniversalCRTSdkDir(vfs::FileSystem &VFS,
6881
std::optional<llvm::StringRef> WinSdkDir,
6982
std::optional<llvm::StringRef> WinSdkVersion,
7083
std::optional<llvm::StringRef> WinSysRoot,
71-
std::string &Path, int &Major,
72-
std::string &WindowsSDKIncludeVersion,
73-
std::string &WindowsSDKLibVersion);
74-
75-
bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
76-
std::optional<llvm::StringRef> WinSdkDir,
77-
std::optional<llvm::StringRef> WinSdkVersion,
78-
std::optional<llvm::StringRef> WinSysRoot,
79-
std::string &Path, std::string &UCRTVersion);
84+
std::string &Path, std::string &UCRTVersion);
8085

8186
// Check command line arguments to try and find a toolchain.
82-
bool findVCToolChainViaCommandLine(
83-
vfs::FileSystem &VFS, std::optional<llvm::StringRef> VCToolsDir,
84-
std::optional<llvm::StringRef> VCToolsVersion,
85-
std::optional<llvm::StringRef> WinSysRoot, std::string &Path,
86-
ToolsetLayout &VSLayout);
87+
LLVM_ABI bool
88+
findVCToolChainViaCommandLine(vfs::FileSystem &VFS,
89+
std::optional<llvm::StringRef> VCToolsDir,
90+
std::optional<llvm::StringRef> VCToolsVersion,
91+
std::optional<llvm::StringRef> WinSysRoot,
92+
std::string &Path, ToolsetLayout &VSLayout);
8793

8894
// Check various environment variables to try and find a toolchain.
89-
bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS, std::string &Path,
90-
ToolsetLayout &VSLayout);
95+
LLVM_ABI bool findVCToolChainViaEnvironment(vfs::FileSystem &VFS,
96+
std::string &Path,
97+
ToolsetLayout &VSLayout);
9198

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

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

108116
} // namespace llvm
109117

llvm/include/llvm/WindowsManifest/WindowsManifestMerger.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
2626
#define LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
2727

28+
#include "llvm/Support/Compiler.h"
2829
#include "llvm/Support/Error.h"
2930

3031
namespace llvm {
@@ -34,9 +35,10 @@ class MemoryBufferRef;
3435

3536
namespace windows_manifest {
3637

37-
bool isAvailable();
38+
LLVM_ABI bool isAvailable();
3839

39-
class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
40+
class LLVM_ABI WindowsManifestError
41+
: public ErrorInfo<WindowsManifestError, ECError> {
4042
public:
4143
static char ID;
4244
WindowsManifestError(const Twine &Msg);
@@ -48,13 +50,13 @@ class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
4850

4951
class WindowsManifestMerger {
5052
public:
51-
WindowsManifestMerger();
52-
~WindowsManifestMerger();
53-
Error merge(MemoryBufferRef Manifest);
53+
LLVM_ABI WindowsManifestMerger();
54+
LLVM_ABI ~WindowsManifestMerger();
55+
LLVM_ABI Error merge(MemoryBufferRef Manifest);
5456

5557
// Returns vector containing merged xml manifest, or uninitialized vector for
5658
// empty manifest.
57-
std::unique_ptr<MemoryBuffer> getMergedManifest();
59+
LLVM_ABI std::unique_ptr<MemoryBuffer> getMergedManifest();
5860

5961
private:
6062
class WindowsManifestMergerImpl;

0 commit comments

Comments
 (0)