diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -876,8 +876,8 @@ endif() if (LIBCXX_INCLUDE_TESTS) - add_subdirectory(test) add_subdirectory(lib/abi) + add_subdirectory(test) endif() if (LIBCXX_INCLUDE_DOCS) diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt --- a/libcxx/lib/abi/CMakeLists.txt +++ b/libcxx/lib/abi/CMakeLists.txt @@ -55,26 +55,16 @@ ) if (TARGET cxx_shared) - set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist") + set(abi_list_file "${CMAKE_CURRENT_SOURCE_DIR}/${abi_list_identifier}.abilist" PARENT_SCOPE) - if (EXISTS "${abi_list_file}") - add_custom_target(check-cxx-abilist - "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py" - --only-stdlib-symbols - --strict "${abi_list_file}" - $ - 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 "${abi_list_file}" - "$" - DEPENDS cxx_shared - COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}") -else() - message(STATUS "Not building a shared library for libc++ -- the ABI list targets will not be available.") + if (NOT EXISTS "${abi_list_file}") + add_custom_target(generate-cxx-abilist + COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/../runtimes/utils/generate_abi_list.py" + --output "${abi_list_file}" + "$" + DEPENDS cxx_shared + COMMENT "Generating the ABI list file for configuration ${abi_list_identifier}") + else() + message(STATUS "Not building the ABI list targets - file already exists.") + endif() endif() diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in --- a/libcxx/test/configs/cmake-bridge.cfg.in +++ b/libcxx/test/configs/cmake-bridge.cfg.in @@ -31,3 +31,5 @@ config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@')) config.substitutions.append(('%{executor}', '@LIBCXX_EXECUTOR@')) config.substitutions.append(('%{test-tools}', '@LIBCXX_TEST_TOOLS_PATH@')) +config.substitutions.append(('%{abi-list-file}', '@abi_list_file@')) +config.substitutions.append(('%{shared-lib-name}', 'lib@LIBCXX_SHARED_OUTPUT_NAME@@CMAKE_SHARED_LIBRARY_SUFFIX@')) diff --git a/libcxx/test/libcxx/symbols/check_cxx_abilist.sh.cpp b/libcxx/test/libcxx/symbols/check_cxx_abilist.sh.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/symbols/check_cxx_abilist.sh.cpp @@ -0,0 +1,6 @@ +// RUN: %{python} %S/../../../../utils/sym_diff.py \ +// RUN: --only-stdlib-symbols \ +// RUN: --strict \ +// RUN: %{abi-list-file} \ +// RUN: %{lib}/%{shared-lib-name} \ +// RUN: 2>&1 diff --git a/libcxx/utils/generate_abi_list.py b/runtimes/utils/generate_abi_list.py rename from libcxx/utils/generate_abi_list.py rename to runtimes/utils/generate_abi_list.py --- a/libcxx/utils/generate_abi_list.py +++ b/runtimes/utils/generate_abi_list.py @@ -9,8 +9,8 @@ import argparse import io -import libcxx.sym_check.extract -import libcxx.sym_check.util +import sym_check.extract +import sym_check.util import pprint import sys @@ -28,10 +28,15 @@ parser.add_argument('-o', '--output', dest='output', type=OutputFile, default=sys.stdout, help='The output file to write the symbols to. It is overwritten if it already exists. ' 'If no file is specified, the results are written to standard output.') + parser.add_argument('--only-stdlib-symbols', dest='only_stdlib', + help='Filter all symbols not related to the stdlib', + action='store_true', default=False) args = parser.parse_args(argv) - symbols = libcxx.sym_check.extract.extract_symbols(args.library) - symbols, _ = libcxx.sym_check.util.filter_stdlib_symbols(symbols) + symbols = sym_check.extract.extract_symbols(args.library) + + if args.only_stdlib: + symbols, _ = sym_check.util.filter_stdlib_symbols(symbols) lines = [pprint.pformat(sym, width=99999) for sym in symbols] args.output.writelines('\n'.join(sorted(lines))) diff --git a/libcxx/utils/libcxx/sym_check/__init__.py b/runtimes/utils/sym_check/__init__.py rename from libcxx/utils/libcxx/sym_check/__init__.py rename to runtimes/utils/sym_check/__init__.py --- a/libcxx/utils/libcxx/sym_check/__init__.py +++ b/runtimes/utils/sym_check/__init__.py @@ -6,7 +6,7 @@ # #===----------------------------------------------------------------------===## -"""libcxx abi symbol checker""" +"""abi symbol checker""" __author__ = 'Eric Fiselier' __email__ = 'eric@efcs.ca' diff --git a/libcxx/utils/libcxx/sym_check/diff.py b/runtimes/utils/sym_check/diff.py rename from libcxx/utils/libcxx/sym_check/diff.py rename to runtimes/utils/sym_check/diff.py --- a/libcxx/utils/libcxx/sym_check/diff.py +++ b/runtimes/utils/sym_check/diff.py @@ -10,7 +10,7 @@ diff - A set of functions for diff-ing two symbol lists. """ -from libcxx.sym_check import util +from sym_check import util def _symbol_difference(lhs, rhs): diff --git a/libcxx/utils/libcxx/sym_check/extract.py b/runtimes/utils/sym_check/extract.py rename from libcxx/utils/libcxx/sym_check/extract.py rename to runtimes/utils/sym_check/extract.py --- a/libcxx/utils/libcxx/sym_check/extract.py +++ b/runtimes/utils/sym_check/extract.py @@ -16,7 +16,7 @@ import subprocess import sys -from libcxx.sym_check import util +from sym_check import util extract_ignore_names = ['_init', '_fini'] diff --git a/libcxx/utils/libcxx/sym_check/match.py b/runtimes/utils/sym_check/match.py rename from libcxx/utils/libcxx/sym_check/match.py rename to runtimes/utils/sym_check/match.py diff --git a/libcxx/utils/libcxx/sym_check/util.py b/runtimes/utils/sym_check/util.py rename from libcxx/utils/libcxx/sym_check/util.py rename to runtimes/utils/sym_check/util.py --- a/libcxx/utils/libcxx/sym_check/util.py +++ b/runtimes/utils/sym_check/util.py @@ -108,9 +108,9 @@ def extract_or_load(filename): - import libcxx.sym_check.extract + import sym_check.extract if is_library_file(filename): - return libcxx.sym_check.extract.extract_symbols(filename) + return sym_check.extract.extract_symbols(filename) return read_syms_from_file(filename) def adjust_mangled_name(name): diff --git a/libcxx/utils/sym_diff.py b/runtimes/utils/sym_diff.py rename from libcxx/utils/sym_diff.py rename to runtimes/utils/sym_diff.py --- a/libcxx/utils/sym_diff.py +++ b/runtimes/utils/sym_diff.py @@ -12,7 +12,7 @@ from argparse import ArgumentParser import sys -from libcxx.sym_check import diff, util +from sym_check import diff, util def main():