summaryrefslogtreecommitdiff
path: root/tools/pipol/nightly/multiopt
blob: 2b85aa4a3960ae23b1c94a577b69a582c65da611 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
SCRIPTS_DIR=$PIPOL_HOMEDIR/.pipol/scripts

# Return value (set it to 1 if a script fails)
RET=0

#
# Set RANDOM_OPT to random compiler options
# [no parameter]
#
# Setting random seed enables replay
RANDOM=$PIPOL_JOB

function random_opt()
{
CONFIGURE_OPTIONS=(\
    --enable-assert=full \
    --enable-thread-safe \
    --disable-shared)
# some options are not available everywhere
if [[ $PIPOL_IMAGE == *i386-linux* || $PIPOL_IMAGE == *amd64* ]]; then
    CONFIGURE_OPTIONS[${#CONFIGURE_OPTIONS[*]}]=--disable-alloca
fi

# we did already compile with --enable-assert=full, so don't use zero value
local number=${RANDOM:-3}

unset RANDOM_OPT
for ((i=0; i < ${#CONFIGURE_OPTIONS[*]}; i++)); do
    if [ $(($((2**i)) & number)) -ne 0 ]; then
        RANDOM_OPT+=" "${CONFIGURE_OPTIONS[$i]}
    fi
done

unset CFLAGS_OPT
CFLAGS_OPTIONS=(\
    -O3 \
    -ansi \
    "-std=c99 -D _XOPEN_SOURCE=500" \
    "-D _FORTIFY_SOURCE=2" \
    -fno-common)
for ((i=0; i < ${#CFLAGS_OPTIONS[*]}; i++)); do
    j=$i+${#CONFIGURE_OPTIONS[*]}
    if [ $(($((2**j)) & number)) -ne 0 ]; then
        CFLAGS_OPT+=${CFLAGS_OPTIONS[$i]}" "
    fi
done
if [ -n "$CFLAGS_OPT" ]; then
    RANDOM_OPT+=" CFLAGS=\"$CFLAGS_OPT\""
fi
}

#
# Write script result in LOG_FILE
# [first parameter: command to be executed while logging results]
# [optional other parameters: command parameters]
#
LOG_FILE=$PIPOL_HOMEDIR/.pipol/log/`date +%y%m%d`-`basename $0`

function log()
{
# execute and log in a temp file
if $* >$PIPOL_WDIR/execution.tmp; then
    RESULT="OK:    "
else
    # something wrong happened: record execution log
    cat $PIPOL_WDIR/execution.tmp
    RESULT="FAILED:"
    RET=1
fi;
# write result in images global file
SCRIPT_NAME=`basename $1`
shift
echo $RESULT $REVISION $PIPOL_IMAGE $PIPOL_JOB_ID $SCRIPT_NAME $* >>$LOG_FILE
}

#
# Set REVISION to the current revision number of the parameter
# [parameter: svn directory]
#
function get_revision()
{
REVISION=$(cd $1; svn info|sed -n 's/Revision: // p')
} 

#
# Make clean in compile directory without changing current working dir
# [parameter: build directory]
#
function clean_compile_dir()
{
(
    cd $1; 
    make clean >$PIPOL_WDIR/clean.tmp
    if [ $? != 0 ]; then
        # something wrong happened: save log file
	cat $PIPOL_WDIR/clean.tmp
    fi
)
}


###

#
# Deploy images
#
#PIPOL esn amd64-linux-fedora-core8.dd.gz none 02:00 --silent --user
#PIPOL esn i386-linux-fedora-core8.dd.gz  none 02:00 --silent --user

### #PIPOL esn amd64-linux-redhatEL-5.0.dd.gz none 02:00 --silent --user
### #PIPOL esn i386-linux-redhatEL-5.0.dd.gz  none 02:00 --silent --user
#PIPOL esn ia64-linux-redhatEL-5.0.dd     none 02:00 --silent --user
### #PIPOL esn ia64-linux-fedora-core9.dd none 02:00 --silent --user

#PIPOL esn i386_mac-mac-osx-server-leopard.dd.gz none 02:00 --silent --user

###
### Following commands are executed on each and all deployed images
###

#
# image-dependant configurations
#
# architecture-dependant
case $PIPOL_IMAGE in
    *i386-linux*) # set path to SUN studio compiler
        export PATH=/net/i386/sunstudio/sunstudio12/bin:$PATH
	;;
    *amd64-linux*) # set path to Intel compiler (bin, lib, and so on)
        . /net/amd64/icc/11.0.074/bin/intel64/iccvars_intel64.sh
	;;
esac

# system-dependant
case $PIPOL_IMAGE in
    *mac*)  # new packages are installed in /opt subdirectories
        export C_INCLUDE_PATH=/opt/local/include:$C_INCLUDE_PATH
        export LD_LIBRARY_PATH=/opt/local/lib:$LD_LIBRARY_PATH
        export LIBRARY_PATH=/opt/local/lib:$LIBRARY_PATH
	;;
    *redhatEL*) # path to recent mpfr lib
        export C_INCLUDE_PATH=$PIPOL_WDIR/include:$C_INCLUDE_PATH
        export LD_LIBRARY_PATH=$PIPOL_WDIR/lib:$LD_LIBRARY_PATH
        export LIBRARY_PATH=$PIPOL_WDIR/lib:$LIBRARY_PATH
        ;;
esac

# this is understood by both mpc and mpfr compilation processes
export GMP_CHECK_RANDOMIZE=1

#
# Get mpfr trunk and compile it with various options
#
unset REVISION
log $SCRIPTS_DIR/get-svn.sh mpfr/trunk mpfr-trunk
get_revision $PIPOL_WDIR/mpfr-trunk
REVISION="mpfr(r$REVISION)"
export MPFR_CHECK_MAX=1
export MPFR_CHECK_ALL=1
log $SCRIPTS_DIR/compile-svn.sh mpfr-trunk

clean_compile_dir $PIPOL_WDIR/mpfr-trunk
log $SCRIPTS_DIR/compile-svn.sh mpfr-trunk --enable-assert=full

clean_compile_dir $PIPOL_WDIR/mpfr-trunk
random_opt
log $SCRIPTS_DIR/compile-svn.sh mpfr-trunk $RANDOM_OPT

# Compile mpfr with non-GNU compilers
case $PIPOL_IMAGE in
    *i386-linux*)
        # SUN Studio compiler
        clean_compile_dir $PIPOL_WDIR/mpfr-trunk
	log $SCRIPTS_DIR/compile-svn.sh mpfr-trunk CC="cc"
	;;
    *amd64-linux*)
        # Intel compiler
        clean_compile_dir $PIPOL_WDIR/mpfr-trunk
	log $SCRIPTS_DIR/compile-svn.sh mpfr-trunk CC="icc"
	;;
esac

#
# Get mpc trunk and compile it
#
unset REVISION
log $SCRIPTS_DIR/get-svn.sh mpc/trunk mpc-trunk
get_revision $PIPOL_WDIR/mpc-trunk
REVISION="mpc(r$REVISION)"
log $SCRIPTS_DIR/compile-svn.sh mpc-trunk

clean_compile_dir $PIPOL_WDIR/mpc-trunk
log $SCRIPTS_DIR/compile-svn.sh mpc-trunk --disable-shared

clean_compile_dir $PIPOL_WDIR/mpc-trunk
log $SCRIPTS_DIR/compile-svn.sh mpc-trunk --disable-static

# Compile mpc with non-GNU compilers
case $PIPOL_IMAGE in
    *i386-linux*)
        # SUN Studio compiler
	clean_compile_dir $PIPOL_WDIR/mpc-trunk
        log $SCRIPTS_DIR/compile-svn.sh mpc-trunk CC="cc"
	;;
    *amd64-linux*)
        # Intel compiler
	clean_compile_dir $PIPOL_WDIR/mpc-trunk
        log $SCRIPTS_DIR/compile-svn.sh mpc-trunk CC=icc CFLAGS=\"-Wno-error\"
	;;
esac

#
# Return value is 0 if no script failed
#
exit $RET;