2 # This function generates a "unique" identifier based on various properties
3 # given as arguments. The idea is to encode all ABI-affecting properties
4 # in that identifier, so that we can store ABI information and associate it
5 # to a specific ABI configuration.
7 # Right now, this is done by using the ABI identifier as the filename containing
8 # the list of symbols exported by libc++ for that configuration, however we could
9 # make it more sophisticated if the number of ABI-affecting parameters grew.
10 function(cxx_abi_list_identifier result triple abi_library abi_version unstable exceptions new_delete_in_libcxx)
13 if ("${triple}" MATCHES "darwin")
14 # Ignore the major, minor, and patchlevel versions of darwin targets.
15 string(REGEX REPLACE "darwin[0-9]+\\.[0-9]+\\.[0-9]+" "darwin" triple "${triple}")
16 elseif("${triple}" MATCHES "freebsd")
17 # Ignore the major and minor versions of freebsd targets.
18 string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd" triple "${triple}")
20 list(APPEND abi_properties "${triple}")
21 list(APPEND abi_properties "${abi_library}")
22 list(APPEND abi_properties "v${abi_version}")
24 list(APPEND abi_properties "unstable")
26 list(APPEND abi_properties "stable")
29 list(APPEND abi_properties "exceptions")
31 list(APPEND abi_properties "noexceptions")
33 if (${new_delete_in_libcxx})
34 list(APPEND abi_properties "new")
36 list(APPEND abi_properties "nonew")
39 list(JOIN abi_properties "." tmp)
40 set(${result} "${tmp}" PARENT_SCOPE)
43 if (CMAKE_CXX_COMPILER_TARGET)
44 set(triple "${CMAKE_CXX_COMPILER_TARGET}")
46 set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
48 cxx_abi_list_identifier(abi_list_identifier
51 "${LIBCXX_ABI_VERSION}"
52 "${LIBCXX_ABI_UNSTABLE}"
53 "${LIBCXX_ENABLE_EXCEPTIONS}"
54 "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"
57 if (TARGET cxx_shared)
58 set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist")
60 if (EXISTS "${abi_list_file}")
61 add_custom_target(check-cxx-abilist
62 "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py"
64 --strict "${abi_list_file}"
65 $<TARGET_FILE:cxx_shared>
67 COMMENT "Testing libc++'s exported symbols against the ABI list")
69 message(STATUS "ABI list file not generated for configuration ${abi_list_identifier}, `check-cxx-abilist` will not be available.")
72 add_custom_target(generate-cxx-abilist
73 COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_abi_list.py"
74 --output "${abi_list_file}"
75 "$<TARGET_FILE:cxx_shared>"
77 COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}")
79 message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.")