diff --git a/flang/test/evaluate/CMakeLists.txt b/flang/test/evaluate/CMakeLists.txt index 65531677b917..87bc2f9de3dd 100644 --- a/flang/test/evaluate/CMakeLists.txt +++ b/flang/test/evaluate/CMakeLists.txt @@ -135,6 +135,15 @@ add_test(RESHAPE reshape-test) add_test(ISO-binding ISO-Fortran-binding-test) add_test(folding folding-test) +set(TEST_LIBPGMATH "-pgmath=false") +if (LIBPGMATH_DIR) + find_library(LIBPGMATH pgmath PATHS ${LIBPGMATH_DIR}) + if(LIBPGMATH) + set(TEST_LIBPGMATH "-pgmath=true") + endif() +endif() + foreach(test ${FOLDING_TESTS}) - add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_folding.sh ${test}) + add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_folding.sh + ${test} ${TEST_LIBPGMATH}) endforeach() diff --git a/flang/test/evaluate/test_folding.sh b/flang/test/evaluate/test_folding.sh index 8a27851ada33..1e273deaf803 100755 --- a/flang/test/evaluate/test_folding.sh +++ b/flang/test/evaluate/test_folding.sh @@ -33,35 +33,16 @@ # - test_x is not folded (it is neither .true. nor .false.). This means the # compiler could not fold the expression. -# Return ldd or similar tool to use to check for libpgmath -function get_ldd() { - case $(uname -s) in - Linux) echo 'ldd' ;; - Darwin) echo 'otool -L' ;; - *) - >&2 echo "Warning: cannot detect libpgmath on $(uname -s)" - echo 'true' ;; - esac -} - PATH=/usr/bin:/bin srcdir=$(dirname $0) F18CC=${F18:-../../tools/f18/f18} CMD="$F18CC -fdebug-dump-symbols -fparse-only" -# Check if libpgmath has been linked -lpgmath=$($(get_ldd) $F18CC | grep "pgmath") -if [ -z "$lpgmath" ]; then - echo "Assuming no libpgmath support" -else - CMD="$CMD -DTEST_LIBPGMATH" - echo "Assuming libpgmath support" -fi - -if [[ $# != 1 ]]; then - echo "Usage: $0 " +if [[ $# < 1 ]]; then + echo "Usage: $0 [-pgmath=]" exit 1 fi + src=$srcdir/$1 [[ ! -f $src ]] && echo "File not found: $src" && exit 1 @@ -70,6 +51,12 @@ rm -rf $temp mkdir $temp [[ $KEEP ]] || trap "rm -rf $temp" EXIT +# Check if tests should assume folding is using libpgmath +if [[ $# > 1 && "$2" = "-pgmath=true" ]]; then + CMD="$CMD -DTEST_LIBPGMATH" + echo "Assuming libpgmath support" +fi + src1=$temp/symbols.log src2=$temp/all_parameters.log src3=$temp/tested_parameters.log