[libcxx-commits] [libcxx] da1b50d - [libc++] Formalize what configurations are covered by the ABI lists

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 27 07:01:25 PST 2020


Author: Louis Dionne
Date: 2020-11-27T10:01:07-05:00
New Revision: da1b50d7df213a3eaf583d576b8d7d2ec77bd97f

URL: https://github.com/llvm/llvm-project/commit/da1b50d7df213a3eaf583d576b8d7d2ec77bd97f
DIFF: https://github.com/llvm/llvm-project/commit/da1b50d7df213a3eaf583d576b8d7d2ec77bd97f.diff

LOG: [libc++] Formalize what configurations are covered by the ABI lists

By encoding ABI-affecting properties in the name of the ABI list, it
makes it clear when an ABI list test should or should not be available,
and what results we should expect.

Note that we clearly don't encode all ABI-affecting parameters in the
name right now -- I just ported over what we supported in the code that
was there previously. As we encounter configurations that we wish to
support but produce different ABI lists, we can add those to the ABI
identifier and start supporting them.

This commit also starts checking the ABI list in the CI jobs that run
a supported configuration. Eventually, all configurations should have
a generated ABI list and the test should even run implicitly as part of
the Lit test suite.

Differential Revision: https://reviews.llvm.org/D92194

Added: 
    libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
    libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist

Modified: 
    libcxx/lib/abi/CMakeLists.txt
    libcxx/utils/ci/run-buildbot

Removed: 
    libcxx/lib/abi/x86_64-apple-darwin.v1.abilist
    libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist


################################################################################
diff  --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index 98cfe8bf1e14..e25c09b7a348 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -1,43 +1,75 @@
 
-if (DEFINED TARGET_TRIPLE)
-    if (TARGET_TRIPLE MATCHES "darwin")
-        # Ignore the major, minor, and patchlevel versions of darwin targets.
-        string(REGEX REPLACE "darwin[0-9]+\\.[0-9]+\\.[0-9]+" "darwin"
-               GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
-    elseif(TARGET_TRIPLE MATCHES "freebsd")
-        # Ignore the major and minor versions of freebsd targets.
-        string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd"
-               GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
-    else()
-        set(GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
-    endif()
-endif()
+# This function generates a "unique" identifier based on various properties
+# given as arguments. The idea is to encode all ABI-affecting properties
+# in that identifier, so that we can store ABI information and associate it
+# to a specific ABI configuration.
+#
+# Right now, this is done by using the ABI identifier as the filename containing
+# the list of symbols exported by libc++ for that configuration, however we could
+# make it more sophisticated if the number of ABI-affecting parameters grew.
+function(cxx_abi_list_identifier result triple abi_library abi_version unstable exceptions new_delete_in_libcxx)
+  set(abi_properties)
+
+  if ("${triple}" MATCHES "darwin")
+    # Ignore the major, minor, and patchlevel versions of darwin targets.
+    string(REGEX REPLACE "darwin[0-9]+\\.[0-9]+\\.[0-9]+" "darwin" triple "${triple}")
+  elseif("${triple}" MATCHES "freebsd")
+    # Ignore the major and minor versions of freebsd targets.
+    string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd" triple "${triple}")
+  endif()
+  list(APPEND abi_properties "${triple}")
+  list(APPEND abi_properties "${abi_library}")
+  list(APPEND abi_properties "v${abi_version}")
+  if (${unstable})
+    list(APPEND abi_properties "unstable")
+  else()
+    list(APPEND abi_properties "stable")
+  endif()
+  if (${exceptions})
+    list(APPEND abi_properties "exceptions")
+  else()
+    list(APPEND abi_properties "noexceptions")
+  endif()
+  if (${new_delete_in_libcxx})
+    list(APPEND abi_properties "new_in_libcxx")
+  else()
+    list(APPEND abi_properties "no_new_in_libcxx")
+  endif()
+
+  list(JOIN abi_properties "." tmp)
+  set(${result} "${tmp}" PARENT_SCOPE)
+endfunction()
+
+cxx_abi_list_identifier(abi_list_identifier
+  "${TARGET_TRIPLE}"
+  "${LIBCXX_CXX_ABI_LIBNAME}"
+  "${LIBCXX_ABI_VERSION}"
+  "${LIBCXX_ABI_UNSTABLE}"
+  "${LIBCXX_ENABLE_EXCEPTIONS}"
+  "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"
+)
+
+if (TARGET cxx_shared)
+  set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist")
 
-# Detect if we are building in the same configuration used to generate
-# the abilist files.
-set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${GENERIC_TARGET_TRIPLE}.v${LIBCXX_ABI_VERSION}.abilist")
-if (EXISTS "${ABILIST_FILE}"
-    AND TARGET cxx_shared
-    AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
-         (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default"))
-    AND NOT LIBCXX_ABI_UNSTABLE
-    AND LIBCXX_ENABLE_EXCEPTIONS
-    AND NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
+  if (EXISTS "${abi_list_file}")
     add_custom_target(check-cxx-abilist
-            ${Python3_EXECUTABLE} "${LIBCXX_SOURCE_DIR}/utils/sym_
diff .py"
-                --only-stdlib-symbols
-                --strict ${ABILIST_FILE}
-                $<TARGET_SONAME_FILE:cxx_shared>
-            DEPENDS cxx_shared
-            COMMENT "Testing ABI compatibility...")
+      "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_
diff .py"
+          --only-stdlib-symbols
+          --strict "${abi_list_file}"
+          $<TARGET_SONAME_FILE:cxx_shared>
+      DEPENDS cxx_shared
+      COMMENT "Testing libc++'s exported symbols against the ABI list")
+  else()
+    message(STATUS "ABI list file not generated for configuration ${abi_list_identifier}, `check-cxx-abilist` will not be available.")
+  endif()
 
-    add_custom_target(generate-cxx-abilist
-        COMMAND ${Python3_EXECUTABLE} "${LIBCXX_SOURCE_DIR}/utils/generate_abi_list.py"
-                 --output "${ABILIST_FILE}"
-                 "$<TARGET_SONAME_FILE:cxx_shared>"
-        DEPENDS cxx_shared
-        COMMENT "Generating the ABI list for the current configuration")
+  add_custom_target(generate-cxx-abilist
+    COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_abi_list.py"
+            --output "${abi_list_file}"
+            "$<TARGET_SONAME_FILE:cxx_shared>"
+    DEPENDS cxx_shared
+    COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}")
 else()
-    message(STATUS "there is no pre-generated ABI list for the requested libc++ configuration. "
-            "check-cxx-abilist target is not supported")
+  message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.")
 endif()

diff  --git a/libcxx/lib/abi/x86_64-apple-darwin.v1.abilist b/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-apple-darwin.v1.abilist
rename to libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist

diff  --git a/libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist b/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist
similarity index 100%
rename from libcxx/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
rename to libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 5a6ea64db62a..a9b49d4384e3 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -88,6 +88,13 @@ function check-cxx-cxxabi() {
     ninja -C "${BUILD_DIR}" install-cxx install-cxxabi
 }
 
+# TODO: The goal is to test this against all configurations. We should also move
+#       this to the Lit test suite instead of being a separate CMake target.
+function check-abi-list() {
+    echo "+++ Running the libc++ ABI list test"
+    ninja -C "${BUILD_DIR}" check-cxx-abilist
+}
+
 function check-cxx-benchmarks() {
     echo "--- Running the benchmarks"
     ninja -C "${BUILD_DIR}" check-cxx-benchmarks
@@ -100,6 +107,7 @@ generic-cxx03)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
     check-cxx-cxxabi
+    check-abi-list
 ;;
 generic-cxx11)
     export CC=clang
@@ -107,6 +115,7 @@ generic-cxx11)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"
     check-cxx-cxxabi
+    check-abi-list
 ;;
 generic-cxx14)
     export CC=clang
@@ -114,6 +123,7 @@ generic-cxx14)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"
     check-cxx-cxxabi
+    check-abi-list
 ;;
 generic-cxx17)
     export CC=clang
@@ -121,6 +131,7 @@ generic-cxx17)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"
     check-cxx-cxxabi
+    check-abi-list
 ;;
 generic-cxx2a)
     export CC=clang
@@ -128,6 +139,7 @@ generic-cxx2a)
     clean
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx2a.cmake"
     check-cxx-cxxabi
+    check-abi-list
 ;;
 generic-noexceptions)
     export CC=clang


        


More information about the libcxx-commits mailing list