Index: test/builtins/CMakeLists.txt =================================================================== --- test/builtins/CMakeLists.txt +++ test/builtins/CMakeLists.txt @@ -44,6 +44,33 @@ string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}") endif() + # Compute builtins available in library and add them as lit features. + if(APPLE) + # TODO: Support other Apple platforms. + set(BUILTIN_LIB_TARGET_NAME "clang_rt.builtins_${arch}_osx") + else() + set(BUILTIN_LIB_TARGET_NAME "clang_rt.builtins-${arch}") + endif() + if (NOT TARGET "${BUILTIN_LIB_TARGET_NAME}") + message(FATAL_ERROR "Target ${BUILTIN_LIB_TARGET_NAME} does not exist") + endif() + get_target_property(BUILTIN_LIB_SOURCES "${BUILTIN_LIB_TARGET_NAME}" SOURCES) + list(LENGTH BUILTIN_LIB_SOURCES BUILTIN_LIB_SOURCES_LENGTH) + if (BUILTIN_LIB_SOURCES_LENGTH EQUAL 0) + message(FATAL_ERROR "Failed to find source files for ${arch} builtin library") + endif() + set(BUILTINS_LIT_SOURCE_FEATURES "") + foreach (file_name ${BUILTIN_LIB_SOURCES}) + # Strip off any directories and file extensions. This approach means we add + # add a single feature if there is a C source file or assembly override + # present in the builtin library. + # E.g. + # "hexagon/udivsi3.S" => "udivsi3" + # "udivsi3.c" => "udivsi3" + get_filename_component(FILE_NAME_FILTERED "${file_name}" NAME_WE) + list(APPEND BUILTINS_LIT_SOURCE_FEATURES "crt_has_${FILE_NAME_FILTERED}") + endforeach() + string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( Index: test/builtins/Unit/comparedf2_test.c =================================================================== --- test/builtins/Unit/comparedf2_test.c +++ test/builtins/Unit/comparedf2_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_comparedf2 //===-- cmpdf2_test.c - Test __cmpdf2 -------------------------------------===// // Index: test/builtins/Unit/comparesf2_test.c =================================================================== --- test/builtins/Unit/comparesf2_test.c +++ test/builtins/Unit/comparesf2_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_comparesf2 //===-- cmpsf2_test.c - Test __cmpsf2 -------------------------------------===// // Index: test/builtins/Unit/divdf3_test.c =================================================================== --- test/builtins/Unit/divdf3_test.c +++ test/builtins/Unit/divdf3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_divdf3 //===--------------- divdf3_test.c - Test __divdf3 ------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/divmodsi4_test.c =================================================================== --- test/builtins/Unit/divmodsi4_test.c +++ test/builtins/Unit/divmodsi4_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_divmodsi4 //===-- divmodsi4_test.c - Test __divmodsi4 -------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/divsf3_test.c =================================================================== --- test/builtins/Unit/divsf3_test.c +++ test/builtins/Unit/divsf3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_divsf3 //===--------------- divsf3_test.c - Test __divsf3 ------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/divsi3_test.c =================================================================== --- test/builtins/Unit/divsi3_test.c +++ test/builtins/Unit/divsi3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_divsi3 //===-- divsi3_test.c - Test __divsi3 -------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/lit.cfg.py =================================================================== --- test/builtins/Unit/lit.cfg.py +++ test/builtins/Unit/lit.cfg.py @@ -94,3 +94,7 @@ if not config.emulator: config.available_features.add('native-run') + +# Add features for available sources +builtins_source_features = config.builtins_lit_source_features.split(';') +config.available_features.update(builtins_source_features) Index: test/builtins/Unit/lit.site.cfg.py.in =================================================================== --- test/builtins/Unit/lit.site.cfg.py.in +++ test/builtins/Unit/lit.site.cfg.py.in @@ -6,6 +6,8 @@ config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@" config.is_msvc = @MSVC_PYBOOL@ config.builtins_is_msvc = @BUILTINS_IS_MSVC_PYBOOL@ +config.builtins_lit_source_features = "@BUILTINS_LIT_SOURCE_FEATURES@" + # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") Index: test/builtins/Unit/modsi3_test.c =================================================================== --- test/builtins/Unit/modsi3_test.c +++ test/builtins/Unit/modsi3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_modsi3 /* ===-- modsi3_test.c - Test __modsi3 -------------------------------------=== * * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/truncdfsf2_test.c =================================================================== --- test/builtins/Unit/truncdfsf2_test.c +++ test/builtins/Unit/truncdfsf2_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_truncdfsf2 //===--------------- truncdfsf2_test.c - Test __truncdfsf2 ----------------===// // Index: test/builtins/Unit/udivmodsi4_test.c =================================================================== --- test/builtins/Unit/udivmodsi4_test.c +++ test/builtins/Unit/udivmodsi4_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_udivmodsi4 //===-- udivmodsi4_test.c - Test __udivmodsi4 -----------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/udivsi3_test.c =================================================================== --- test/builtins/Unit/udivsi3_test.c +++ test/builtins/Unit/udivsi3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_udivsi3 //===-- udivsi3_test.c - Test __udivsi3 -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. Index: test/builtins/Unit/umodsi3_test.c =================================================================== --- test/builtins/Unit/umodsi3_test.c +++ test/builtins/Unit/umodsi3_test.c @@ -1,4 +1,5 @@ // RUN: %clang_builtins %s %librt -o %t && %run %t +// REQUIRES: crt_has_umodsi3 //===-- umodsi3_test.c - Test __umodsi3 -----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.