-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Fix visibility macros for c-index-test #171054
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
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-clang Author: None (kkent030315) ChangesFixes #152083 - duplicate symbols in
Full diff: https://github.com/llvm/llvm-project/pull/171054.diff 2 Files Affected:
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 4059fc3e986c7..9dcc77d5a5184 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -115,9 +115,6 @@ macro(add_clang_library name)
if(TARGET "obj.${name}")
target_compile_definitions("obj.${name}" PUBLIC CLANG_BUILD_STATIC)
endif()
- elseif(TARGET "obj.${name}" AND NOT ARG_SHARED AND NOT ARG_STATIC)
- # Clang component libraries linked to clang-cpp are declared without SHARED or STATIC
- target_compile_definitions("obj.${name}" PUBLIC CLANG_EXPORTS)
endif()
set(libs ${name})
diff --git a/clang/include/clang/Support/Compiler.h b/clang/include/clang/Support/Compiler.h
index e1ae3eda4ccc2..1aab64e11521c 100644
--- a/clang/include/clang/Support/Compiler.h
+++ b/clang/include/clang/Support/Compiler.h
@@ -45,8 +45,8 @@
#define CLANG_TEMPLATE_ABI
#define CLANG_EXPORT_TEMPLATE __declspec(dllexport)
#else
-#define CLANG_ABI __declspec(dllimport)
-#define CLANG_TEMPLATE_ABI __declspec(dllimport)
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
#define CLANG_EXPORT_TEMPLATE
#endif
#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \
|
Fixes llvm#152083 - duplicate symbols in `c-index-test` - Eliminated the use of `CLANG_EXPORTS` for Clang component libraries. - Removed unnecessary dllimport attributes from `Compiler.h`. They aren't strictly required (the linker will resolve them).
|
This also eliminates 5000+ unnecessary symbol exports in To test this change turn |
|
Probably related to #163349, I'm still not yet sure if this is the best solution. Please let me know if you have better ideas, thanks. |
|
I believe this breaks dylib builds ( |
How so? Can you be more specific how this would break dylib builds, and what exactly is in the progress? As mentioned in the comment dllimport attribute is not strictly required, it's safe to remove it. |
|
Apparently |
For code symbols, the attribute isn't strictly required, just suboptimal; lacking of
The issue report uses a GNU style command line for the windows-msvc target, but such that configuration doesn't seem to have been tested well. Perhaps some of |
|
|
@kikairoya Thank you for the detailed info! I appreciate.
Yes, it is. In the case we're not modifying dllimport attributes in |
I don't think this is suitable for this, let me do some tests. (I did the similar before submitting this PR, didnt worked iirc) |
We should not to export the C++ interfaces, to align with every other build configurations (e.g.
I guess there are bunch of related blocks. llvm-project/clang/cmake/modules/AddClang.cmake Lines 111 to 117 in e7f6038
llvm-project/clang/tools/libclang/CMakeLists.txt Lines 119 to 121 in e7f6038
llvm-project/llvm/cmake/modules/AddLLVM.cmake Lines 1389 to 1390 in e7f6038
(These may not be all; every related block should be fixed.) |
Fixes #152083 - duplicate symbols in
c-index-testCLANG_EXPORTSfor Clang component libraries.Compiler.h. They aren't strictly required (the linker will resolve them).