Browse code

- added test cc ver & options scripts

Andrei Pelinescu-Onciul authored on 07/11/2002 15:26:11
Showing 2 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,127 @@
0
+#!/bin/sh
1
+
2
+#$Id$
3
+#
4
+# returns the CFLAGS for the given compiler (maximum optimizations)
5
+#
6
+
7
+
8
+ARCH=`uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ `
9
+
10
+# gcc 3.x optimize for:
11
+x86CPU=athlon
12
+WARN_ARCH="WARNING: Not tested on architecture $ARCH, using default flags"
13
+
14
+if [ $# -lt 1 ]
15
+then 
16
+	echo "ERROR: you must specify the compiler name" 1>&2
17
+	exit 1
18
+fi
19
+
20
+if [ "$1" = "-h" ]
21
+then
22
+	echo "Usage: "
23
+	echo "      $0 compiler_name"
24
+	exit 1
25
+fi
26
+
27
+
28
+if  CCVER=`./ccver.sh $1` 
29
+then
30
+	NAME=`echo "$CCVER"|cut -d" " -f 1`
31
+	VER=`echo "$CCVER"|cut -d" " -f 2`
32
+	MAJOR_VER=`echo "$CCVER"|cut -d" " -f 3`
33
+else
34
+	echo "ERROR executing ./ccver.sh" 2>&1
35
+	exit 1
36
+fi
37
+
38
+echo "name=$NAME, ver=$VER, mver=$MAJOR_VER"
39
+case $NAME
40
+in
41
+gcc) 
42
+		#common stuff
43
+		CFLAGS="-O9 -funroll-loops -Winline -Wall"
44
+		case $MAJOR_VER
45
+		in
46
+			3)
47
+				case $ARCH
48
+				in
49
+					i386)
50
+						CFLAGS="$CFLAGS -minline-all-stringops -malign-double"
51
+						CFLAGS="$CFLAGS -falign-loops -march=$x86CPU"
52
+						;;
53
+					sparc64)
54
+						CFLAGS="$CFLAGS -mcpu=ultrasparc -mtune=ultrasparc"
55
+						CFLAGS="$CFLAGS -m32"
56
+						#other interesting options:
57
+						# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
58
+						#-mno-epilogue #try to inline function exit code
59
+						#-mflat # omit save/restore
60
+						#-faster-structs #faster non Sparc ABI structure copy
61
+						;;
62
+					armv4l)
63
+						CFLAGS="$CFLAGS -mcpu=strongarm1100"
64
+						;;
65
+						*)
66
+						echo "$WARN_ARCH" 1>&2
67
+						;;
68
+				esac
69
+				;;
70
+			2|*)
71
+				case $ARCH
72
+				in
73
+					i386)
74
+						CFLAGS="$CFLAGS -m486 -malign-loops=4"
75
+						;;
76
+					sparc64)
77
+						CFLAGS="$CFLAGS -mv8 -Wa,-xarch=v8plus"
78
+						;;
79
+					armv4l)
80
+						;;
81
+						*)
82
+						echo "$WARN_ARCH" 1>&2
83
+						;;
84
+				esac
85
+				;;
86
+		esac
87
+		;;
88
+
89
+icc)
90
+	CFLAGS="-O3 -ipo -ipo_obj -unroll"
91
+	case $ARCH
92
+	in
93
+		i386)
94
+			CFLAGS="$CFLAGS -tpp6 -xK"
95
+			#-openmp  #optimize for PIII 
96
+			# -prefetch doesn't seem to work
97
+			#( ty to inline acroos files, unroll loops,prefetch,
98
+			# optimize for PIII, use PIII instructions & vect.,
99
+			# mutlithread loops)
100
+		;;
101
+		*)
102
+			echo "$WARN_ARCH" 1>&2
103
+		;;
104
+	esac
105
+	;;
106
+
107
+suncc)
108
+	CFLAGS="-xO5 -fast -native -xCC -xc99"
109
+	case $ARCH
110
+	in
111
+		sparc64)
112
+			CFLAGS="$CFLAGS -xarch=v8plusa"
113
+			;;
114
+		*)
115
+			echo "$WARN_ARCH" 1>&2
116
+			;;
117
+	esac
118
+	;;
119
+
120
+*)
121
+	echo "WARNING: unknown compiler $NAME, trying _very_ generic flags" 1>&2
122
+	CFLAGS="-O2"
123
+esac
124
+
125
+
126
+echo "CFLAGS=$CFLAGS"
0 127
new file mode 100755
... ...
@@ -0,0 +1,83 @@
0
+#!/bin/sh
1
+
2
+#$Id$
3
+#
4
+# finds CC version and prints it in the following format:
5
+# compiler_name version major_version
6
+#
7
+
8
+
9
+
10
+if [ $# -lt 1 ]
11
+then 
12
+	echo "Error: you must specify the compiler name" 1>&2
13
+	exit 1
14
+fi
15
+
16
+if [ "$1" = "-h" ]
17
+then
18
+	echo "Usage: "
19
+	echo "      $0 compiler_name"
20
+	exit 1
21
+fi
22
+
23
+
24
+CC=$1
25
+
26
+if  which $CC >/dev/null
27
+then
28
+	(test ! -x `which $CC`) && echo "Error: $CC not executable" 1>&2 && exit 1
29
+else
30
+	echo "Error: $CC not found or not executable" 1>&2
31
+	exit 1 
32
+fi
33
+
34
+
35
+if $CC -v 2>/dev/null 1>/dev/null
36
+then
37
+	FULLVER=`$CC -v 2>&1` 
38
+else
39
+	FULLVER=`$CC -V 2>&1`
40
+fi
41
+
42
+
43
+
44
+if [ -n "$FULLVER" ]
45
+then
46
+	# check if gcc
47
+	if echo "$FULLVER"|grep gcc >/dev/null
48
+	then
49
+		NAME=gcc
50
+		VER=`$CC --version|head -1| \
51
+				sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
52
+				    -e 's/.*[^.0-9]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
53
+	elif echo "$FULLVER"|grep Sun >/dev/null
54
+	then
55
+		NAME=suncc
56
+		VER=`echo "$FULLVER"|head -1| \
57
+				sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
58
+	elif echo "$FULLVER"|grep "Intel(R) C++ Compiler" >/dev/null
59
+	then
60
+		NAME=icc
61
+		VER=`echo "$FULLVER"|head -1| \
62
+				sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/' ` 
63
+	fi
64
+	
65
+	# find major ver
66
+	if [  -n "$VER"  -a -z "$MAJOR_VER" ]
67
+	then
68
+		MAJOR_VER=`echo "$VER" |cut -d. -f1`
69
+	fi
70
+fi	
71
+
72
+
73
+#unknown
74
+if [ -z "$NAME" ]
75
+then
76
+	NAME="unknown"
77
+	VER="unknown"
78
+	MAJOR_VER="unkown"
79
+fi
80
+
81
+
82
+echo "$NAME $VER $MAJOR_VER"