brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 8f277aa Raw
84 lines · plain
1 2# This function generates a "unique" identifier based on various properties3# given as arguments. The idea is to encode all ABI-affecting properties4# in that identifier, so that we can store ABI information and associate it5# to a specific ABI configuration.6#7# Right now, this is done by using the ABI identifier as the filename containing8# the list of symbols exported by libc++ for that configuration, however we could9# 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  elseif("${triple}" MATCHES "aix")20    # Ignore the V.R.M.F version string of aix targets.21    string(REGEX REPLACE "aix[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" "aix" triple "${triple}")22  endif()23  list(APPEND abi_properties "${triple}")24  list(APPEND abi_properties "${abi_library}")25  list(APPEND abi_properties "v${abi_version}")26  if (${unstable})27    list(APPEND abi_properties "unstable")28  else()29    list(APPEND abi_properties "stable")30  endif()31  if (${exceptions})32    list(APPEND abi_properties "exceptions")33  else()34    list(APPEND abi_properties "noexceptions")35  endif()36  if (${new_delete_in_libcxx})37    list(APPEND abi_properties "new")38  else()39    list(APPEND abi_properties "nonew")40  endif()41 42  list(JOIN abi_properties "." tmp)43  set(${result} "${tmp}" PARENT_SCOPE)44endfunction()45 46if (CMAKE_CXX_COMPILER_TARGET)47  set(triple "${CMAKE_CXX_COMPILER_TARGET}")48else()49  set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")50endif()51cxx_abi_list_identifier(abi_list_identifier52  "${triple}"53  "${LIBCXX_CXX_ABI}"54  "${LIBCXX_ABI_VERSION}"55  "${LIBCXX_ABI_UNSTABLE}"56  "${LIBCXX_ENABLE_EXCEPTIONS}"57  "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"58)59 60if (TARGET cxx_shared)61  set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist")62 63  if (EXISTS "${abi_list_file}")64    add_custom_target(check-cxx-abilist65      "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py"66          --only-stdlib-symbols67          --strict "${abi_list_file}"68          $<TARGET_FILE:cxx_shared>69      DEPENDS cxx_shared70      COMMENT "Testing libc++'s exported symbols against the ABI list")71  else()72    message(STATUS "ABI list file not generated for configuration ${abi_list_identifier}, `check-cxx-abilist` will not be available.")73  endif()74 75  add_custom_target(generate-cxx-abilist76    COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_abi_list.py"77            --output "${abi_list_file}"78            "$<TARGET_FILE:cxx_shared>"79    DEPENDS cxx_shared80    COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}")81else()82  message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.")83endif()84