summaryrefslogtreecommitdiffstats
path: root/config.tests/unix/fvisibility.test
blob: b2bcc075ed46d093ee1276e42e9a0f21ce075ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh

FVISIBILITY_SUPPORT=no
COMPILER=$1
VERBOSE=$2

RunCompileTest() {
    cat >>fvisibility.c << EOF
__attribute__((visibility("default"))) void blah();
#if !defined(__GNUC__)
# error "Visiblility support requires GCC"
#elif __GNUC__ < 4
# error "GCC3 with backported visibility patch is known to miscompile Qt"
#endif
EOF

    if [ "$VERBOSE" = "yes" ] ; then
        "$COMPILER" -c -fvisibility=hidden fvisibility.c && FVISIBILITY_SUPPORT=yes
    else
        "$COMPILER" -c -fvisibility=hidden fvisibility.c >/dev/null 2>&1 && FVISIBILITY_SUPPORT=yes
    fi
    rm -f fvisibility.c fvisibility.o
}

case "$COMPILER" in
aCC*)
    ;;

icpc)
    ICPC_VERSION=`icpc -dumpversion`
    case "$ICPC_VERSION" in
    8.*|9.*|10.0)
        # 8.x, 9.x, and 10.0 don't support symbol visibility
        ;;
    *)
        # the compile test works for the intel compiler because it mimics gcc's behavior
        RunCompileTest
        ;;
    esac
    ;;

    *)
    RunCompileTest
    ;;
esac

# done
if [ "$FVISIBILITY_SUPPORT" != "yes" ]; then
    [ "$VERBOSE" = "yes" ] && echo "Symbol visibility control disabled."
    exit 0
else
    [ "$VERBOSE" = "yes" ] && echo "Symbol visibility control enabled."
    exit 1
fi