[llvm] [llvm] compile out LLVM_ABI unless building as a shared lib or dylib (PR #134958)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 17:47:21 PDT 2025
https://github.com/andrurogerz created https://github.com/llvm/llvm-project/pull/134958
## Purpose
Ensure that `LLVM_ABI` and related macros are compiled out when not building LLVM as a shared library.
## Overview
I observed that by default on Linux and Darwin, the `LLVM_ABI` macro was being defined to a visibility annotation even when not building as a shared library. This is contrary to my expectation: I believe `LLVM_ABI` and related macros should compile to nothing unless building a DLL for Windows or shared object file for other targets.
The root cause appears to be that `LLVM_ENABLE_PLUGINS` it set to on by default. While that's a reasonable default, I don't think it actually requires the `LLVM_ABI` macros modify symbol visibility.
## Background
This change is in support of the project to annotate LLVM's public interfaces described [here](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307/). As we begin adding annotations throughout the codebase, it will be much safer to have the annotations be inactive by default and enable them once the effort is complete.
>From bd4f24a7b3a0d78b08b69a25005251a6f8ecf139 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 8 Apr 2025 17:11:37 -0700
Subject: [PATCH] [llvm] compile out LLVM_ABI unless building llvm shared lib
or dylib
---
llvm/include/llvm/Support/Compiler.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index d3772896069cc..2a4cbe673d35e 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -175,8 +175,7 @@
// Marker to add to classes or functions in public headers that should not have
// export macros added to them by the clang tool
#define LLVM_ABI_NOT_EXPORTED
-#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) || \
- defined(LLVM_ENABLE_PLUGINS)
+#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
// Some libraries like those for tablegen are linked in to tools that used
// in the build so can't depend on the llvm shared library. If export macros
// were left enabled when building these we would get duplicate or
More information about the llvm-commits
mailing list