aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorAndrew Rogers <andrurogerz@gmail.com>2025-06-04 10:28:58 -0700
committerGitHub <noreply@github.com>2025-06-04 10:28:58 -0700
commitecbe2e8c3f8f4be87d5d30ad5d1fcc1986fa5c47 (patch)
tree06ba6b464c8e3f4aba7ff59bde861264ef0ea8f2 /llvm/lib
parent68a346f71d9b54f2e439007336285420ece0de39 (diff)
downloadllvm-ecbe2e8c3f8f4be87d5d30ad5d1fcc1986fa5c47.zip
llvm-ecbe2e8c3f8f4be87d5d30ad5d1fcc1986fa5c47.tar.gz
llvm-ecbe2e8c3f8f4be87d5d30ad5d1fcc1986fa5c47.tar.bz2
[llvm] annotate interfaces in llvm/ObjCopy and llvm/Object for DLL export (#142668)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the `llvm/ObjCopy` and `llvm/Object` libraries. These 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 #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). The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS on Linux: - Add `#include "llvm/Support/Compiler.h"` to files where it was not auto-added by IDS due to no pre-existing block of include statements. - Manually annotate template class `CommonArchiveMemberHeader` with `LLVM_ABI` since IDS ignores templates and this is the simplest solution for DLL-exporting its child classes because it has methods defined out-of-line. Seems to be an uncommon situation. - Explicitly make `Archive` class non-copyable due to the class-level `LLVM_ABI` annotation. - Add default constructor to `ELFFile` so it can be instantiated for DLL-export as a base class. - Add `LLVM_TEMPLATE_ABI` and `LLVM_EXPORT_TEMPLATE` to exported instantiated templates. ## 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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Object/XCOFFObjectFile.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
index 5a24643..c5a2ec2 100644
--- a/llvm/lib/Object/XCOFFObjectFile.cpp
+++ b/llvm/lib/Object/XCOFFObjectFile.cpp
@@ -93,8 +93,8 @@ uint8_t XCOFFRelocation<AddressType>::getRelocatedLength() const {
return (Info & XR_BIASED_LENGTH_MASK) + 1;
}
-template struct ExceptionSectionEntry<support::ubig32_t>;
-template struct ExceptionSectionEntry<support::ubig64_t>;
+template struct LLVM_EXPORT_TEMPLATE ExceptionSectionEntry<support::ubig32_t>;
+template struct LLVM_EXPORT_TEMPLATE ExceptionSectionEntry<support::ubig64_t>;
template <typename T>
Expected<StringRef> getLoaderSecSymNameInStrTbl(const T *LoaderSecHeader,
@@ -1375,11 +1375,11 @@ Expected<StringRef> XCOFFSymbolRef::getName() const {
}
// Explicitly instantiate template classes.
-template struct XCOFFSectionHeader<XCOFFSectionHeader32>;
-template struct XCOFFSectionHeader<XCOFFSectionHeader64>;
+template struct LLVM_EXPORT_TEMPLATE XCOFFSectionHeader<XCOFFSectionHeader32>;
+template struct LLVM_EXPORT_TEMPLATE XCOFFSectionHeader<XCOFFSectionHeader64>;
-template struct XCOFFRelocation<llvm::support::ubig32_t>;
-template struct XCOFFRelocation<llvm::support::ubig64_t>;
+template struct LLVM_EXPORT_TEMPLATE XCOFFRelocation<llvm::support::ubig32_t>;
+template struct LLVM_EXPORT_TEMPLATE XCOFFRelocation<llvm::support::ubig64_t>;
template LLVM_EXPORT_TEMPLATE
llvm::Expected<llvm::ArrayRef<llvm::object::XCOFFRelocation64>>