Blame toolchains/runtest.sh

675b60e
#!/bin/sh -eux
c7a6ef0
c7a6ef0
set pipefail
c7a6ef0
675b60e
if [ -z "${CXXLIBS:-}" ]; then
675b60e
  echo "CXXLIBS variable is a required input but it's not specified!"
675b60e
  echo "Test metadata should have picked a proper value, depending on distro."
675b60e
  exit 1
675b60e
fi
675b60e
c7a6ef0
status=0
c7a6ef0
c7a6ef0
test_toolchain() {
c7a6ef0
c7a6ef0
    toolchain=$@
c7a6ef0
    args=""
c7a6ef0
c7a6ef0
    while [ $# -gt 0 ]; do
c7a6ef0
        case $1 in
c7a6ef0
            clang)
c7a6ef0
                compiler=$1
c7a6ef0
                src=hello.c
c7a6ef0
                ;;
c7a6ef0
            clang++)
c7a6ef0
                compiler=$1
c7a6ef0
                src=hello.cpp
c7a6ef0
                ;;
c7a6ef0
            compiler-rt)
c7a6ef0
                args="$args -rtlib=$1"
c7a6ef0
                ;;
c7a6ef0
            libc++)
c7a6ef0
                args="$args -stdlib=$1"
c7a6ef0
                ;;
675b60e
            libstdc++)
675b60e
                args="$args -stdlib=$1"
675b60e
                ;;
c7a6ef0
            lld)
c7a6ef0
                args="$args -fuse-ld=$1"
c7a6ef0
                ;;
c7a6ef0
            *)
c7a6ef0
                args="$args $1"
c7a6ef0
                ;;
c7a6ef0
        esac
c7a6ef0
    shift
c7a6ef0
    done
c7a6ef0
c7a6ef0
    cmd="$compiler $args $src"
c7a6ef0
    rm -f a.out
c7a6ef0
    echo "* $toolchain"
c7a6ef0
    echo "  command: $cmd"
c7a6ef0
    if $cmd && ./a.out | grep -q 'Hello World'; then
c7a6ef0
        echo "  PASS"
c7a6ef0
    else
c7a6ef0
        echo "  FAIL"
c7a6ef0
        status=1
c7a6ef0
    fi
c7a6ef0
}
c7a6ef0
061565d
clang --version
675b60e
# Repoquery is needed instead yum info for compatibility with RHEL-7
675b60e
repoquery -i --installed $(rpm -qf $(which clang)) | grep ^Source
061565d
echo ""
061565d
c7a6ef0
for compiler in clang clang++; do
c7a6ef0
    for rtlib in "" compiler-rt; do
c7a6ef0
        for linker in "" lld; do
675b60e
            for cxxlib in "" $CXXLIBS; do
c7a6ef0
                if [ "$compiler" = "clang" -a -n "$cxxlib" ]; then
c7a6ef0
                    continue
c7a6ef0
                fi
c7a6ef0
                for args in "" -static; do
c7a6ef0
                    # Skip known failures
c7a6ef0
                    # TODO: Fix these
061565d
                    if [[ "$args" = "-static" && "$rtlib" = "compiler-rt" ]]; then
c7a6ef0
                        continue
c7a6ef0
                    fi
061565d
061565d
                    # Static libc++ needs -pthread
061565d
                    if [[ "$args" = "-static" && "$cxxlib" = "libc++" ]]; then
061565d
                      args="$args -pthread"
061565d
                    fi
061565d
675b60e
                    # lld is not supported in s390x and ppc64
675b60e
                    if [[ "$(uname -m)" = "s390x" || "$(uname -m)" = "ppc64" ]] \
675b60e
                        && [[ "$linker" = "lld" ]];
675b60e
                    then
675b60e
                      continue
675b60e
                    fi
675b60e
675b60e
                    # compiler-rt does not provide builtins for s390x
675b60e
                    if [[ "$(uname -m)" = "s390x" && "$rtlib" = "compiler-rt" ]]; then
675b60e
                      continue
675b60e
                    fi
675b60e
c7a6ef0
                    test_toolchain $compiler $rtlib $linker $cxxlib $args
c7a6ef0
                done
c7a6ef0
            done
c7a6ef0
        done
c7a6ef0
    done
c7a6ef0
done
c7a6ef0
c7a6ef0
exit $status