1 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. 6# 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. 10function(cxx_abi_list_identifier result triple abi_library abi_version unstable exceptions new_delete_in_libcxx) 11 set(abi_properties) 12 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}") 19 endif() 20 list(APPEND abi_properties "${triple}") 21 list(APPEND abi_properties "${abi_library}") 22 list(APPEND abi_properties "v${abi_version}") 23 if (${unstable}) 24 list(APPEND abi_properties "unstable") 25 else() 26 list(APPEND abi_properties "stable") 27 endif() 28 if (${exceptions}) 29 list(APPEND abi_properties "exceptions") 30 else() 31 list(APPEND abi_properties "noexceptions") 32 endif() 33 if (${new_delete_in_libcxx}) 34 list(APPEND abi_properties "new_in_libcxx") 35 else() 36 list(APPEND abi_properties "no_new_in_libcxx") 37 endif() 38 39 list(JOIN abi_properties "." tmp) 40 set(${result} "${tmp}" PARENT_SCOPE) 41endfunction() 42 43cxx_abi_list_identifier(abi_list_identifier 44 "${LIBCXX_TARGET_TRIPLE}" 45 "${LIBCXX_CXX_ABI_LIBNAME}" 46 "${LIBCXX_ABI_VERSION}" 47 "${LIBCXX_ABI_UNSTABLE}" 48 "${LIBCXX_ENABLE_EXCEPTIONS}" 49 "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}" 50) 51 52if (TARGET cxx_shared) 53 set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist") 54 55 if (EXISTS "${abi_list_file}") 56 add_custom_target(check-cxx-abilist 57 "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py" 58 --only-stdlib-symbols 59 --strict "${abi_list_file}" 60 $<TARGET_FILE:cxx_shared> 61 DEPENDS cxx_shared 62 COMMENT "Testing libc++'s exported symbols against the ABI list") 63 else() 64 message(STATUS "ABI list file not generated for configuration ${abi_list_identifier}, `check-cxx-abilist` will not be available.") 65 endif() 66 67 add_custom_target(generate-cxx-abilist 68 COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_abi_list.py" 69 --output "${abi_list_file}" 70 "$<TARGET_FILE:cxx_shared>" 71 DEPENDS cxx_shared 72 COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}") 73else() 74 message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.") 75endif() 76