1
+ # The SOVERSION should be updated only if a change is made to the libclang
2
+ # ABI, and when it is updated, it should be updated to the current
3
+ # LLVM_VERSION_MAJOR.
4
+ # Please also see clang/tools/libclang/libclang.map
5
+
6
+ if (NOT CLANG_FORCE_MATCHING_LIBCLANG_SOVERSION )
7
+ # default is to use the SOVERSION according to ABI...
8
+ set (LIBCLANG_SOVERSION 13 )
9
+ else ()
10
+ # ... unless explicily overridden
11
+ set (LIBCLANG_SOVERSION ${CLANG_VERSION_MAJOR} )
12
+ endif ()
13
+
14
+ # TODO: harmonize usage of LIBCLANG_SOVERSION / LIBCLANG_LIBARY_VERSION
15
+ # below; this was added under time-pressure to avoid reverting the
16
+ # better default from LLVM 14 for LLVM 15.0.0-rc3, hence no time
17
+ # to clean up previous inconsistencies.
18
+
1
19
set (SOURCES
2
20
ARCMigrate.cpp
3
21
BuildSystem.cpp
@@ -64,7 +82,8 @@ endif ()
64
82
option (LIBCLANG_BUILD_STATIC
65
83
"Build libclang as a static library (in addition to a shared one)" OFF )
66
84
67
- set (LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR} /libclang.exports )
85
+ set (LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_BINARY_DIR} /libclang-generic.exports )
86
+ set (LIBCLANG_VERSION_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR} /libclang.map )
68
87
69
88
if (MSVC )
70
89
# Avoid LNK4197 by not specifying libclang.exports here.
@@ -73,6 +92,20 @@ if(MSVC)
73
92
set (LLVM_EXPORTED_SYMBOL_FILE )
74
93
endif ()
75
94
95
+ if (UNIX AND NOT APPLE )
96
+ set (LLVM_EXPORTED_SYMBOL_FILE )
97
+ set (USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT} )
98
+ endif ()
99
+
100
+ if (LLVM_EXPORTED_SYMBOL_FILE )
101
+ add_custom_command (OUTPUT ${LLVM_EXPORTED_SYMBOL_FILE}
102
+ COMMAND "${Python3_EXECUTABLE} "
103
+ ARGS ${CMAKE_CURRENT_SOURCE_DIR} /linker-script-to-export-list.py
104
+ ${LIBCLANG_VERSION_SCRIPT_FILE}
105
+ ${LLVM_EXPORTED_SYMBOL_FILE}
106
+ DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE} )
107
+ endif ()
108
+
76
109
if (LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC ))
77
110
set (ENABLE_SHARED SHARED )
78
111
endif ()
@@ -145,6 +178,21 @@ if(ENABLE_SHARED)
145
178
)
146
179
endif ()
147
180
endif ()
181
+ if (USE_VERSION_SCRIPT )
182
+ target_link_options (libclang PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR} /libclang.map" )
183
+ # The Solaris 11.4 linker supports a subset of GNU ld version scripts,
184
+ # but requires a special option to enable it.
185
+ if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
186
+ target_link_options (libclang PRIVATE "-Wl,-z,gnu-version-script-compat" )
187
+ endif ()
188
+ # Ensure that libclang.so gets rebuilt when the linker script changes.
189
+ set_property (SOURCE ARCMigrate.cpp APPEND PROPERTY
190
+ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /libclang.map )
191
+
192
+ set_target_properties (libclang PROPERTIES
193
+ VERSION ${LLVM_VERSION_MAJOR} .${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}
194
+ SOVERSION ${LIBCLANG_SOVERSION} )
195
+ endif ()
148
196
endif ()
149
197
150
198
if (INTERNAL_INSTALL_PREFIX )
0 commit comments