[all-commits] [llvm/llvm-project] e175ec: [llvm] revisions to `LLVM_ABI` export macro defini...
Andrew Rogers via All-commits
all-commits at lists.llvm.org
Tue Jun 24 09:18:56 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e175ecff936287823b5443d7b2d443fc6569f31f
https://github.com/llvm/llvm-project/commit/e175ecff936287823b5443d7b2d443fc6569f31f
Author: Andrew Rogers <andrurogerz at gmail.com>
Date: 2025-06-24 (Tue, 24 Jun 2025)
Changed paths:
M llvm/CMakeLists.txt
M llvm/docs/InterfaceExportAnnotations.rst
M llvm/include/llvm/ADT/APFloat.h
M llvm/include/llvm/ADT/SlowDynamicAPInt.h
M llvm/include/llvm/Bitcode/BitcodeReader.h
M llvm/include/llvm/CodeGen/MachineOperand.h
M llvm/include/llvm/CodeGen/PseudoSourceValue.h
M llvm/include/llvm/Config/llvm-config.h.cmake
M llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
M llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
M llvm/include/llvm/ExecutionEngine/RuntimeDyld.h
M llvm/include/llvm/IR/Function.h
M llvm/include/llvm/ProfileData/SampleProfWriter.h
M llvm/include/llvm/Support/Compiler.h
M llvm/include/llvm/Support/Error.h
M llvm/include/llvm/Support/FileSystem.h
M llvm/include/llvm/Support/JSON.h
M llvm/include/llvm/Support/Path.h
M llvm/include/llvm/Support/PrettyStackTrace.h
M llvm/include/llvm/XRay/InstrumentationMap.h
M llvm/include/llvm/XRay/Trace.h
Log Message:
-----------
[llvm] revisions to `LLVM_ABI` export macro definitions (#144598)
## Purpose
Simplify the logic used to define `LLVM_ABI` and related macros,
eliminate the `LLVM_ABI_FRIEND` macro, and update the `LLVM_ABI` macro
to always resolve to `__attribute__((visibility("default")))` when
building LLVM as a shared library for ELF or Mach-O targets.
## Background
Previously, `LLVM_ABI` was defined to the C++ style attribute
`[[gnu::visibility("default")]]` when compiling with gcc, which has more
restrictions on its placement. Of note, the C++ style attributes cannot
decorate `friend` functions and must not appear after `extern` on
variable declarations.
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
- Define a new CMake config value,
`LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS`, which is implicitly set whenever
`LLVM_BUILD_LLVM_DYLIB`, `LLVM_BUILD_SHARED_LIBS`, or
`LLVM_ENABLE_PLUGINS` is set. Add it as a `#cmakedefine` to
llvm-config.h so its definition is available to projects building
against LLVM as required so clients see `__declspec(dllimport)` on
Windows.
- Gate the `LLVM_ABI` macro definitions in Compiler.h behind the new
`LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS` definition. This is
simpler/cleaner, but should be equivalent to the previous logic.
- Maintain `LLVM_BUILD_STATIC` as an override to be used by specific
targets that don't want to build against the DLL/shared library, such as
tablegen.
- For ELF and Mach-O targets, directly define `LLVM_ABI` as
`__attribute__((visibility("default")))` instead of
`LLVM_ATTRIBUTE_VISIBILITY_DEFAULT`, which resolves to C++ style
`[[gnu::visibility("default")]]` when compiling with gcc.
- Remove the `LLVM_ABI_FRIEND` macro and replace all usages of it with
`LLVM_ABI`.
- Update the documentation for exporting friend functions to no longer
reference `LLVM_ABI_FRIEND`.
## Validation
- Built as static lib with clang and gcc on Linux.
- Built as static with clang-cl and MSVC on Windows.
- Built as shared lib with clang and gcc on Linux (+ additional local
changes not yet merged).
- Built as DLL with clang-cl and MSVC on Windows (+ additional local
changes not yet merged).
---------
Co-authored-by: SquallATF <squallatf at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list