@@ -230,11 +230,22 @@ else()
230
230
endif ()
231
231
232
232
set (LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system -libcxxabi libcxxrt libstdc++ libsupc++ vcruntime )
233
- set (LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY} " CACHE STRING "Specify C++ ABI library to use. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES} ." )
234
- if (NOT "${LIBCXX_CXX_ABI} " IN_LIST LIBCXX_SUPPORTED_ABI_LIBRARIES )
235
- message (FATAL_ERROR "Unsupported C++ ABI library: '${LIBCXX_CXX_ABI} '. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES} ." )
236
- endif ()
237
-
233
+ set (LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY} " CACHE STRING
234
+ "Specify the C++ ABI library to use for the shared and the static libc++ libraries. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES} .
235
+ This CMake option also supports \" consumption specifiers\" , which specify how the selected ABI library should be consumed by
236
+ libc++. The supported specifiers are:
237
+ - `shared`: The selected ABI library should be used as a shared library.
238
+ - `static`: The selected ABI library should be used as a static library.
239
+ - `merged`: The selected ABI library should be a static library whose object files will be merged directly into the produced libc++ library.
240
+
241
+ A consumption specifier is provided by appending it to the name of the library, such as `LIBCXX_CXX_ABI=merged-libcxxabi`.
242
+ If no consumption specifier is provided, the libc++ shared library will default to using a shared ABI library, and the
243
+ libc++ static library will default to using a static ABI library." )
244
+ set (LIBCXX_ABILIB_FOR_SHARED "${LIBCXX_CXX_ABI} " CACHE STRING "C++ ABI library to use for the shared libc++ library." )
245
+ set (LIBCXX_ABILIB_FOR_STATIC "${LIBCXX_CXX_ABI} " CACHE STRING "C++ ABI library to use for the static libc++ library." )
246
+
247
+ #############################
248
+ # TODO: Remove these options in LLVM 21.
238
249
option (LIBCXX_ENABLE_STATIC_ABI_LIBRARY
239
250
"Use a static copy of the ABI library when linking libc++.
240
251
This option cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT." OFF )
@@ -247,17 +258,34 @@ option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
247
258
"Statically link the ABI library to shared library"
248
259
${LIBCXX_ENABLE_STATIC_ABI_LIBRARY} )
249
260
261
+ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY OR LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY )
262
+ message (WARNING "The LIBCXX_ENABLE_STATIC_ABI_LIBRARY, LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY and "
263
+ "LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY options have been deprecated in favor of "
264
+ "using LIBCXX_CXX_ABI=merged-libcxxabi. This will become an error in LLVM 21." )
265
+ endif ()
266
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY )
267
+ set (LIBCXX_ABILIB_FOR_STATIC "merged-libcxxabi" CACHE STRING "" FORCE )
268
+ endif ()
269
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY )
270
+ set (LIBCXX_ABILIB_FOR_SHARED "merged-libcxxabi" CACHE STRING "" FORCE )
271
+ endif ()
272
+ #############################
273
+
250
274
# Generate and install a linker script inplace of libc++.so. The linker script
251
275
# will link libc++ to the correct ABI library. This option is on by default
252
- # on UNIX platforms other than Apple, and on the Fuchsia platform unless we
253
- # statically link libc++abi inside libc++.so, we don't build libc++.so at all
254
- # or we don't have any ABI library.
255
- if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
256
- OR NOT LIBCXX_ENABLE_SHARED
257
- OR LIBCXX_CXX_ABI STREQUAL "none" )
258
- set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF )
259
- elseif ((UNIX OR FUCHSIA ) AND NOT APPLE )
260
- set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON )
276
+ # on UNIX platforms other than Apple unless we are linking the ABI library as
277
+ # an object library. This option is also disabled when the ABI library is not
278
+ # specified or is specified to be "none".
279
+ if (LIBCXX_ENABLE_SHARED )
280
+ if ((UNIX OR FUCHSIA ) AND NOT APPLE )
281
+ if (LIBCXX_ABILIB_FOR_SHARED STREQUAL "merged-libcxxabi" OR LIBCXX_ABILIB_FOR_SHARED STREQUAL "none" )
282
+ set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF )
283
+ else ()
284
+ set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON )
285
+ endif ()
286
+ else ()
287
+ set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF )
288
+ endif ()
261
289
else ()
262
290
set (ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF )
263
291
endif ()
@@ -379,12 +407,6 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
379
407
endif ()
380
408
endif ()
381
409
382
- if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT )
383
- message (FATAL_ERROR "Conflicting options given.
384
- LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY cannot be specified with
385
- LIBCXX_ENABLE_ABI_LINKER_SCRIPT" )
386
- endif ()
387
-
388
410
if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT )
389
411
message (FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified." )
390
412
endif ()
@@ -481,10 +503,6 @@ include(config-ix)
481
503
#===============================================================================
482
504
# Setup Compiler Flags
483
505
#===============================================================================
484
-
485
- include (HandleLibC ) # Setup the C library flags
486
- include (HandleLibCXXABI ) # Setup the ABI library flags
487
-
488
506
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
489
507
# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
490
508
# so they don't get transformed into -Wno and -errors respectively.
@@ -815,7 +833,7 @@ if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
815
833
config_define (ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS )
816
834
endif ()
817
835
818
- if (WIN32 AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY )
836
+ if (WIN32 AND LIBCXX_CXX_ABI STREQUAL "merged-libcxxabi" )
819
837
# If linking libcxxabi statically into libcxx, skip the dllimport attributes
820
838
# on symbols we refer to from libcxxabi.
821
839
add_definitions (-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS )
0 commit comments