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