12 filesystem/filesystem_clock.cpp
13 filesystem/filesystem_error.cpp
14 filesystem/path_parser.h
18 include/apple_availability.h
19 include/atomic_support.h
20 include/config_elast.h
24 include/ryu/d2fixed_full_table.h
26 include/ryu/d2s_full_table.h
27 include/ryu/d2s_intrinsics.h
28 include/ryu/digit_table.h
31 include/to_chars_floating_point.h
32 include/from_chars_floating_point.h
45 support/runtime/exception_fallback.ipp
46 support/runtime/exception_glibcxx.ipp
47 support/runtime/exception_libcxxabi.ipp
48 support/runtime/exception_libcxxrt.ipp
49 support/runtime/exception_msvc.ipp
50 support/runtime/exception_pointer_cxxabi.ipp
51 support/runtime/exception_pointer_glibcxx.ipp
52 support/runtime/exception_pointer_msvc.ipp
53 support/runtime/exception_pointer_unimplemented.ipp
54 support/runtime/stdexcept_default.ipp
55 support/runtime/stdexcept_vcruntime.ipp
64 if (LIBCXX_ENABLE_THREADS)
65 list(APPEND LIBCXX_SOURCES
68 condition_variable_destructor.cpp
69 condition_variable.cpp
78 if (LIBCXX_ENABLE_RANDOM_DEVICE)
79 list(APPEND LIBCXX_SOURCES
84 if (LIBCXX_ENABLE_LOCALIZATION)
85 list(APPEND LIBCXX_SOURCES
87 include/sso_allocator.h
89 ios.instantiations.cpp
99 list(APPEND LIBCXX_SOURCES
100 support/win32/compiler_rt_shims.cpp
101 support/win32/locale_win32.cpp
102 support/win32/support.cpp
105 if (NOT LIBCXX_HAS_PTHREAD_API)
106 list(APPEND LIBCXX_SOURCES
107 support/win32/thread_win32.cpp
111 list(APPEND LIBCXX_SOURCES
112 support/ibm/mbsnrtowcs.cpp
113 support/ibm/wcsnrtombs.cpp
114 support/ibm/xlocale_zos.cpp
118 if (LIBCXX_ENABLE_FILESYSTEM)
119 list(APPEND LIBCXX_SOURCES
120 filesystem/directory_entry.cpp
121 filesystem/directory_iterator.cpp
122 filesystem/file_descriptor.h
123 filesystem/operations.cpp
124 filesystem/posix_compat.h
125 filesystem/time_utils.h
127 # Filesystem uses __int128_t, which requires a definition of __muloi4 when
128 # compiled with UBSAN. This definition is not provided by libgcc_s, but is
129 # provided by compiler-rt. So we need to disable it to avoid having multiple
130 # definitions. See filesystem/int128_builtins.cpp.
131 if (NOT LIBCXX_USE_COMPILER_RT)
132 list(APPEND LIBCXX_SOURCES
133 filesystem/int128_builtins.cpp
138 if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
139 list(APPEND LIBCXX_SOURCES
144 if (APPLE AND LLVM_USE_SANITIZER)
145 if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
146 ("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
147 ("${LLVM_USE_SANITIZER}" STREQUAL "Undefined;Address"))
148 set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
149 elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
150 set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
151 elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread")
152 set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib")
154 message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X")
157 find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY)
158 get_filename_component(LIBDIR "${LIBCXX_BUILTINS_LIBRARY}" DIRECTORY)
159 if (NOT IS_DIRECTORY "${LIBDIR}")
160 message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER")
162 set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}")
163 set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE)
164 message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}")
165 add_library_flags("${LIBCXX_SANITIZER_LIBRARY}")
166 add_link_flags("-Wl,-rpath,${LIBDIR}")
170 split_list(LIBCXX_COMPILE_FLAGS)
171 split_list(LIBCXX_LINK_FLAGS)
173 include(FindLibcCommonUtils)
175 # Build the shared library.
176 add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
177 target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
178 target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared
179 PRIVATE ${LIBCXX_LIBRARIES}
180 PRIVATE llvm-libc-common-utilities)
181 set_target_properties(cxx_shared
183 EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_SHARED}>,FALSE,TRUE>"
184 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
185 LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
186 OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME}"
187 VERSION "${LIBCXX_LIBRARY_VERSION}"
188 SOVERSION "${LIBCXX_ABI_VERSION}"
191 cxx_add_common_build_flags(cxx_shared)
194 add_custom_command(TARGET cxx_shared POST_BUILD
196 ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh
197 $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME}"
198 COMMENT "Rename dll name inside the side deck file"
199 WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared>
203 # Link against libc++abi
204 if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
205 target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects)
207 target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
210 # Maybe force some symbols to be weak, not weak or not exported.
211 # TODO: This shouldn't depend on the platform, and ideally it should be done in the sources.
212 if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
213 AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
214 target_link_libraries(cxx_shared PRIVATE
215 "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
216 "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
219 # Generate a linker script in place of a libc++.so symlink.
220 if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
223 set(imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>")
224 set(output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>")
225 string(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}$<IF:$<BOOL:${imported_libname}>,${imported_libname},${output_name}>")
227 # TODO: Move to the same approach as above for the unwind library
228 if (LIBCXXABI_USE_LLVM_UNWINDER)
229 if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
230 # libunwind is already included in libc++abi
231 elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
232 string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}$<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>")
234 string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}unwind")
238 set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries})")
239 add_custom_command(TARGET cxx_shared POST_BUILD
240 COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:cxx_shared>"
241 COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:cxx_shared>"
242 COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:cxx_shared>"
247 if (LIBCXX_ENABLE_SHARED)
248 list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared")
251 if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
252 # Since we most likely do not have a mt.exe replacement, disable the
253 # manifest bundling. This allows a normal cmake invocation to pass which
254 # will attempt to use the manifest tool to generate the bundled manifest
255 if (${CMAKE_CXX_COMPILER_FRONTEND_VARIANT} STREQUAL "MSVC")
256 set_target_properties(cxx_shared PROPERTIES
257 APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO")
259 set_target_properties(cxx_shared PROPERTIES
260 APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker /MANIFEST:NO")
264 set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
266 # Build the static library.
267 add_library(cxx_static STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
268 target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
269 target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static
270 PRIVATE ${LIBCXX_LIBRARIES}
271 PRIVATE libcxx-abi-static
272 PRIVATE llvm-libc-common-utilities)
273 set_target_properties(cxx_static
275 EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_STATIC}>,FALSE,TRUE>"
276 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
277 LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
278 OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}"
280 cxx_add_common_build_flags(cxx_static)
282 if (LIBCXX_HERMETIC_STATIC_LIBRARY)
283 # If the hermetic library doesn't define the operator new/delete functions
284 # then its code shouldn't declare them with hidden visibility. They might
285 # actually be provided by a shared library at link time.
286 if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
287 append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete=force-hidden)
288 if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG)
289 append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
292 target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS})
293 # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
294 # too. Define it in the same way here, to avoid redefinition conflicts.
295 target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
298 if (LIBCXX_ENABLE_STATIC)
299 list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
301 # Attempt to merge the libc++.a archive and the ABI library archive into one.
302 if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
303 target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects)
306 # Add a meta-target for both libraries.
307 add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
309 # Build the experimental static library
310 set(LIBCXX_EXPERIMENTAL_SOURCES
311 experimental/keep.cpp
314 if (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch")
315 list(APPEND LIBCXX_EXPERIMENTAL_SOURCES
320 if (LIBCXX_ENABLE_LOCALIZATION AND LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_ENABLE_TIME_ZONE_DATABASE)
321 list(APPEND LIBCXX_EXPERIMENTAL_SOURCES
322 experimental/include/tzdb/time_zone_private.h
323 experimental/include/tzdb/types_private.h
324 experimental/include/tzdb/tzdb_list_private.h
325 experimental/include/tzdb/tzdb_private.h
326 # TODO TZDB The exception could be moved in chrono once the TZDB library
327 # is no longer experimental.
328 experimental/chrono_exception.cpp
329 experimental/time_zone.cpp
330 experimental/tzdb.cpp
331 experimental/tzdb_list.cpp
335 add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
336 target_link_libraries(cxx_experimental PUBLIC cxx-headers)
337 if (LIBCXX_ENABLE_SHARED)
338 target_link_libraries(cxx_experimental PRIVATE cxx_shared)
340 target_link_libraries(cxx_experimental PRIVATE cxx_static)
343 if (LIBCXX_HERMETIC_STATIC_LIBRARY)
344 # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
345 # too. Define it in the same way here, to avoid redefinition conflicts.
346 target_compile_definitions(cxx_experimental PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
349 set_target_properties(cxx_experimental
351 COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
352 OUTPUT_NAME "c++experimental"
354 cxx_add_common_build_flags(cxx_experimental)
355 target_compile_options(cxx_experimental PUBLIC -D_LIBCPP_ENABLE_EXPERIMENTAL)
357 if (LIBCXX_INSTALL_SHARED_LIBRARY)
358 install(TARGETS cxx_shared
359 ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
360 LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
361 RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx)
364 if (LIBCXX_INSTALL_STATIC_LIBRARY)
365 install(TARGETS cxx_static
366 ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
367 LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
368 RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx)
371 if (LIBCXX_INSTALL_LIBRARY)
372 install(TARGETS cxx_experimental
373 LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
374 ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx
375 RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx)
378 # NOTE: This install command must go after the cxx install command otherwise
379 # it will not be executed after the library symlinks are installed.
380 if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
381 install(FILES "$<TARGET_LINKER_FILE:cxx_shared>"
382 DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR}
386 if (NOT CMAKE_CONFIGURATION_TYPES)
387 if(LIBCXX_INSTALL_LIBRARY)
388 set(lib_install_target "cxx;cxx_experimental")
390 if(LIBCXX_INSTALL_HEADERS)
391 set(header_install_target install-cxx-headers)
393 if(LIBCXX_INSTALL_MODULES)
394 set(module_install_target install-cxx-modules)
396 add_custom_target(install-cxx
397 DEPENDS ${lib_install_target}
399 ${header_install_target}
400 ${module_install_target}
401 COMMAND "${CMAKE_COMMAND}"
402 -DCMAKE_INSTALL_COMPONENT=cxx
403 -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
404 add_custom_target(install-cxx-stripped
405 DEPENDS ${lib_install_target}
407 ${header_install_target}
408 ${module_install_target}
409 COMMAND "${CMAKE_COMMAND}"
410 -DCMAKE_INSTALL_COMPONENT=cxx
411 -DCMAKE_INSTALL_DO_STRIP=1
412 -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")