WikiStart: bgclang

File bgclang, 1.5 KB (added by hfinkel, 5 years ago)
Line 
1#!/bin/sh
2
3CLANG=/home/projects/llvm/bin/clang
4BGSYS_TOOLCHAIN_HOME=/bgsys/drivers/ppcfloor/gnu-linux
5BGCLANG_TARGET_FLAGS="-ccc-host-triple powerpc64-bgq-linux -gcc-toolchain $BGSYS_TOOLCHAIN_HOME -mcpu=a2q"
6BGCLANG_UNROLL_OPTS="-mllvm -unroll-allow-partial -mllvm -unroll-runtime"
7BGCLANG_VECTOR_OPTS="-mllvm -vectorize -mllvm -bb-vectorize-vector-bits=256 -mllvm -bb-vectorize-req-chain-depth=3 -mllvm -bb-vectorize-aligned-only -mllvm -bb-vectorize-no-ints -mllvm -bb-vectorize-no-select"
8if [ "x$BGCLANG_VECTORIZE" = xno ]; then
9        BGCLANG_VECTOR_OPTS=
10fi
11
12if [ "x$BGCLANG_STATIC_LINKING" != xno ]; then
13        BGCLANG_TARGET_FLAGS="$BGCLANG_TARGET_FLAGS -static"
14fi
15
16if basename $0 | grep -q '[+]\{2\}$'; then
17        CLANG="$CLANG++"
18        BGCLANG_TARGET_FLAGS="$BGCLANG_TARGET_FLAGS -Xclang -internal-isystem -Xclang /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/include/c++/4.4.6 -Xclang -internal-isystem -Xclang /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/include/c++/4.4.6/powerpc64-bgq-linux"
19fi
20
21BGCLANG_TARGET_FLAGS="$BGCLANG_TARGET_FLAGS -Xclang -isystem -Xclang /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/sys-include"
22
23user_params="$@"
24will_compile=0
25is_O3=0
26for arg in $user_params; do
27        case "$arg" in
28        -O3)
29                is_O3=1
30        ;;
31        -*)
32                :
33        ;;
34        *)
35                if ! file -b -- "$arg" 2>&1 | grep -q -E '^ELF|current ar archive|cannot open'; then
36                        will_compile=1
37                fi
38        ;;
39        esac
40done
41
42script_params=
43if [ $is_O3 = 1 -a $will_compile = 1 ]; then
44        script_params="$BGCLANG_UNROLL_OPTS $BGCLANG_VECTOR_OPTS"
45fi
46
47exec $CLANG $BGCLANG_TARGET_FLAGS $script_params "$@"
48exit 1