-
Notifications
You must be signed in to change notification settings - Fork 15.1k
RFC: [llvm] refactor common export macros to llvm/Config #149175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /*===------- llvm/Config/export-config.h - export configuration ----- C -*-===*/ | ||
| /* */ | ||
| /* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ | ||
| /* Exceptions. */ | ||
| /* See https://llvm.org/LICENSE.txt for license information. */ | ||
| /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ | ||
| /* */ | ||
| /*===----------------------------------------------------------------------===*/ | ||
|
|
||
|
|
||
| /* This file contains configuration definitions controling which LLVM projects | ||
| and components require public ABI export for shared library builds. It also | ||
| contains generic LLVM_INTERFACE_ macro definitions that can be aliased by | ||
| libraries and components and used to decorate their public interface. */ | ||
|
|
||
| #ifndef LLVM_EXPORT_CONFIG_H | ||
| #define LLVM_EXPORT_CONFIG_H | ||
|
|
||
| /* Define if exporting LLVM public interface for shared library */ | ||
| #cmakedefine LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS | ||
|
|
||
| /* Define if exporting LLVM-C public interface for shared library */ | ||
| #cmakedefine LLVM_ENABLE_LLVM_C_EXPORT_ANNOTATIONS | ||
|
|
||
| /// LLVM_INTERFACE_ABI is the main export/visibility macro to mark something as explicitly | ||
| /// exported when llvm is built as a shared library with everything else that is | ||
| /// unannotated will have internal visibility. | ||
| /// | ||
| /// LLVM_INTERFACE_ABI_EXPORT is for the special case for things like plugin symbol | ||
| /// declarations or definitions where we don't want the macro to be switching | ||
| /// between dllexport and dllimport on windows based on what codebase is being | ||
| /// built, it will only be dllexport. For non windows platforms this macro | ||
| /// behaves the same as LLVM_ABI. | ||
| /// | ||
| /// LLVM_INTERFACE_EXPORT_TEMPLATE is used on explicit template instantiations in source | ||
| /// files that were declared extern in a header. This macro is only set as a | ||
| /// compiler export attribute on windows, on other platforms it does nothing. | ||
| /// | ||
| /// LLVM_INTERFACE_TEMPLATE_ABI is for annotating extern template declarations in headers | ||
| /// for both functions and classes. On windows its turned in to dllimport for | ||
| /// library consumers, for other platforms its a default visibility attribute. | ||
| /// | ||
| /// LLVM_INTERFACE_ABI_FOR_TEST is for annotating symbols that are only exported because | ||
| /// they are imported from a test. These symbols are not technically part of the | ||
| /// LLVM public interface and could be conditionally excluded when not building | ||
| /// tests in the future. | ||
| /// | ||
| // 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_INTERFACE_ABI_NOT_EXPORTED | ||
| // TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for | ||
| // two preprocessor definitions to gate LLVM_ABI macro definitions. | ||
| #if !defined(LLVM_BUILD_STATIC) | ||
| #if defined(_WIN32) && !defined(__MINGW32__) | ||
| #if defined(LLVM_EXPORTS) | ||
| #define LLVM_INTERFACE_ABI __declspec(dllexport) | ||
| #define LLVM_INTERFACE_TEMPLATE_ABI | ||
| #define LLVM_INTERFACE_EXPORT_TEMPLATE __declspec(dllexport) | ||
| #else | ||
| #define LLVM_INTERFACE_ABI __declspec(dllimport) | ||
| #define LLVM_INTERFACE_TEMPLATE_ABI __declspec(dllimport) | ||
| #define LLVM_INTERFACE_EXPORT_TEMPLATE | ||
| #endif | ||
| #define LLVM_INTERFACE_ABI_EXPORT __declspec(dllexport) | ||
| #elif defined(__has_attribute) && __has_attribute(visibility) | ||
| #if defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \ | ||
| defined(__MVS__) || defined(__CYGWIN__) | ||
| #define LLVM_INTERFACE_ABI __attribute__((visibility("default"))) | ||
| #define LLVM_INTERFACE_TEMPLATE_ABI LLVM_INTERFACE_ABI | ||
| #define LLVM_INTERFACE_EXPORT_TEMPLATE | ||
| #define LLVM_INTERFACE_ABI_EXPORT LLVM_INTERFACE_ABI | ||
| #elif defined(__MACH__) || defined(__WASM__) || defined(__EMSCRIPTEN__) | ||
| #define LLVM_INTERFACE_ABI __attribute__((visibility("default"))) | ||
| #define LLVM_INTERFACE_TEMPLATE_ABI | ||
| #define LLVM_INTERFACE_EXPORT_TEMPLATE | ||
| #define LLVM_INTERFACE_ABI_EXPORT LLVM_INTERFACE_ABI | ||
| #endif | ||
| #endif | ||
| #endif | ||
| #if !defined(LLVM_INTERFACE_ABI) | ||
| #define LLVM_INTERFACE_ABI | ||
| #define LLVM_INTERFACE_TEMPLATE_ABI | ||
| #define LLVM_INTERFACE_EXPORT_TEMPLATE | ||
| #define LLVM_INTERFACE_ABI_EXPORT | ||
| #endif | ||
| #define LLVM_INTERFACE_ABI_FOR_TEST LLVM_INTERFACE_ABI | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work. This defines the interface as to how LLVM was built. If I build LLVM dynamically, llvm-c statically, and LLVM Demangle dynamically, I need 2 independent sets of definitions for LLVM and LLVM Demangle. Doing something else really doesn't work. The de-duplication is not worth additional complexity and introducing new patterns IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am completely on-board with the complexity argument for not doing it this way. I will put up the
abi-breakingPR again with the duplicated logic.