blob: a22a0a087a5d0c415dd85ca90874640cbd23b258 (
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
|
#!/bin/sh
test -f $PLAN9/config && . $PLAN9/config
usegcc()
{
cc=${CC9:-gcc}
cflags=" \
-O2 \
-c \
-Wall \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
-Wno-comment \
-Wno-sign-compare \
-Wno-unknown-pragmas \
-Wno-misleading-indentation \
-Wno-stringop-truncation \
-Wno-stringop-overflow \
-Wno-format-truncation \
-fno-omit-frame-pointer \
-fsigned-char \
-fcommon \
"
# want to put -fno-optimize-sibling-calls here but
# that option only works with gcc3+ it seems
cflags="$cflags -ggdb"
cflags="$cflags $CC9FLAGS"
case "$cflags" in
*sanitize=address*)
cflags="$cflags -DPLAN9PORT_ASAN"
esac
}
quiet()
{
# The uniq at the end is for gcc's strcmp/etc. built-in nonsense,
# which multiplies single errors as a result of its expansion.
# The "Cursor. is deprecated" kills off warnings from Apple
# about using SetCursor/InitCursor. (Okay, they're deprecated,
# but you could at least tell us what to use instead, Apple!)
ignore=': error: .Each undeclared identifier'
ignore=$ignore'|: error: for each function it appears'
ignore=$ignore'|is dangerous, better use'
ignore=$ignore'|is almost always misused'
ignore=$ignore'|: In function '
ignore=$ignore'|: At top level:'
ignore=$ignore'|support .long long.'
ignore=$ignore'|In file included from'
ignore=$ignore'| from'
ignore=$ignore'|use of C99 long long'
ignore=$ignore'|ISO C forbids conversion'
ignore=$ignore'|marked deprecated'
ignore=$ignore'|is deprecated'
ignore=$ignore'|warn_unused_result'
ignore=$ignore'|expanded from macro'
grep -v '__p9l_autolib_' $1 |
egrep -v "$ignore" |
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
$(which uniq) 1>&2 # avoid built-in uniq on SunOS
}
useclang()
{
cc=${CC9:-clang}
cflags=" \
-O2 \
-c \
-Wall \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
-Wno-comment \
-Wno-sign-compare \
-Wno-unknown-pragmas \
-Wno-empty-body \
-Wno-unused-value \
-Wno-array-bounds \
-Wno-gnu-designator \
-Wno-array-bounds \
-Wno-unneeded-internal-declaration \
-fsigned-char \
-fno-caret-diagnostics \
"
cflags="$cflags -g"
cflags="$cflags $CC9FLAGS"
case "$cflags" in
*sanitize=address*)
cflags="$cflags -DPLAN9PORT_ASAN"
esac
}
usexlc()
{
cc=${CC9:-xlc_r}
cflags=" \
-c \
-O0 \
-qmaxmem=-1 \
-qsuppress=1506-236 \
-qsuppress=1506-358 \
-qsuppress=1500-010 \
-qsuppress=1506-224 \
-qsuppress=1506-1300 \
-qsuppress=1506-342 \
"
cflags="$cflags -g -qfullpath"
cflags="$cflags $CC9FLAGS"
}
tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
case "$tag" in
*DragonFly*gcc*|*BSD*gcc*) usegcc ;;
*DragonFly*clang|*BSD*clang*) useclang ;;
*Darwin-x86_64*)
useclang
cflags="$cflags -g3 -m64"
;;
*Darwin*clang*)
useclang
cflags="$cflags -g3 -m32"
;;
*Darwin*) usegcc
cflags="$cflags -g3 -no-cpp-precomp -m32" ;;
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
*Linux*) usegcc
case "${CC9:-gcc}" in
tcc)
cc=tcc
cflags="-c -g"
;;
esac
;;
*OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;;
*SunOS*-cc) cc=cc;
cflags="-mt -g -O -c -xCC -D__sun__"
u=`uname`
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
cflags="$cflags -D__${s}__"
;;
*SunOS*-gcc) usegcc
u=`uname`
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
cflags="$cflags -g"
cflags="$cflags -D__sun__ -D__${s}__"
;;
*AIX*) usexlc
cflags="$cflags -g -D__AIX__"
;;
*)
echo 9c does not know how to compile on "$tag" 1>&2
exit 1
esac
# N.B. Must use temp file to avoid pipe; pipe loses status.
xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
status=$?
quiet $xtmp
rm -f $xtmp
exit $status
|