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") 35 else() 36 list(APPEND abi_properties "nonew") 37 endif() 38 39 list(JOIN abi_properties "." tmp) 40 set(${result} "${tmp}" PARENT_SCOPE) 41endfunction() 42 43if (CMAKE_CXX_COMPILER_TARGET) 44 set(triple "${CMAKE_CXX_COMPILER_TARGET}") 45else() 46 set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}") 47endif() 48cxx_abi_list_identifier(abi_list_identifier 49 "${triple}" 50 "${LIBCXX_CXX_ABI}" 51 "${LIBCXX_ABI_VERSION}" 52 "${LIBCXX_ABI_UNSTABLE}" 53 "${LIBCXX_ENABLE_EXCEPTIONS}" 54 "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}" 55) 56 57if (TARGET cxx_shared) 58 set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist") 59 60 if (EXISTS "${abi_list_file}") 61 add_custom_target(check-cxx-abilist 62 "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py" 63 --only-stdlib-symbols 64 --strict "${abi_list_file}" 65 $<TARGET_FILE:cxx_shared> 66 DEPENDS cxx_shared 67 COMMENT "Testing libc++'s exported symbols against the ABI list") 68 else() 69 message(STATUS "ABI list file not generated for configuration ${abi_list_identifier}, `check-cxx-abilist` will not be available.") 70 endif() 71 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>" 76 DEPENDS cxx_shared 77 COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}") 78else() 79 message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.") 80endif() 81