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