plan9port/bin/9c

158 lines
3.5 KiB
Text
Raw Normal View History

#!/bin/sh
test -f "$PLAN9/config" && . "$PLAN9/config"
usegcc()
{
cc=${CC9:-gcc}
cflags=" \
-O2 \
-c \
-Wall \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
2004-02-09 19:33:05 +00:00
-Wno-comment \
2003-11-25 02:36:46 +00:00
-Wno-sign-compare \
-Wno-unknown-pragmas \
-Wno-misleading-indentation \
-Wno-stringop-truncation \
-Wno-stringop-overflow \
-Wno-format-truncation \
2024-06-15 14:55:15 +00:00
-Wno-deprecated-pragma \
-Wno-unused-but-set-variable \
-Wno-deprecated-declarations \
-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"
}
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 \
fix clang 3.4 warnings and ignore uninteresting ones fixed warnings: src/cmd/fossil/disk.c:37:14: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator] src/cmd/fossil/disk.c:38:14: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator] src/cmd/fossil/disk.c:39:14: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator] src/cmd/fossil/disk.c:40:13: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator] src/cmd/fossil/disk.c:41:14: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator] src/libndb/ndbreorder.c:41:55: warning: for loop has empty body [-Wempty-body] ignored warnings: src/cmd/acid/dbg.y:393:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/bc.y:1327:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/bc.y:1327:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/grep/grep.y:420:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/grep/grep.y:420:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/hoc/hoc.y:692:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/hoc/hoc.y:692:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/lex/parser.y:886:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/rc/syn.y:303:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/cmd/units.y:1003:9: warning: array index -1 is before the beginning of the array [-Warray-bounds] src/libregexp/regcomp.c:19:16: warning: variable 'reprog' is not needed and will not be emitted [-Wunneeded-internal-declaration] LGTM=rsc R=rsc https://codereview.appspot.com/158250043
2014-10-21 12:22:12 +00:00
-Wno-array-bounds \
-Wno-unneeded-internal-declaration \
2024-06-15 14:55:15 +00:00
-Wno-deprecated-pragma \
-Wno-unused-but-set-variable \
-fsigned-char \
-fno-caret-diagnostics \
2020-12-30 05:06:35 +00:00
-fcommon \
"
cflags="$cflags -g"
cflags="$cflags $CC9FLAGS"
}
usexlc()
{
cc=${CC9:-xlc_r}
cflags=" \
-c \
-O2 \
-qmaxmem=-1 \
-qsuppress=1506-236 \
-qsuppress=1506-358 \
-qsuppress=1500-010 \
-qsuppress=1506-224 \
-qsuppress=1506-1300 \
-qsuppress=1506-342 \
"
cflags="$cflags -g -qdbxextra -qfullpath"
cflags="$cflags $CC9FLAGS"
}
tag="${SYSNAME:-`uname`}-${CC9:-cc}"
case "$tag" in
*DragonFly*gcc*|*BSD*gcc*) usegcc ;;
*DragonFly*clang|*BSD*clang*) useclang ;;
*Darwin*)
useclang
cflags="$cflags -g3 -m64"
;;
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
*Linux*) usegcc
2005-07-22 18:56:31 +00:00
case "${CC9:-gcc}" in
tcc)
cc=tcc
cflags="-c -g"
;;
esac
;;
*OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;;
2004-03-26 05:01:11 +00:00
*SunOS*-cc) cc=cc;
cflags="-mt -g -O -c -xCC -D__sun__"
2004-03-26 05:01:11 +00:00
u=`uname`
2004-03-26 05:05:33 +00:00
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
2005-01-19 16:45:27 +00:00
cflags="$cflags -D__${s}__"
2004-03-26 05:01:11 +00:00
;;
*SunOS*-gcc) usegcc
u=`uname`
2004-03-26 05:05:33 +00:00
v=`uname -r`
s=`echo $u$v | tr '. ' '__'`
cflags="$cflags -g"
2008-05-31 16:09:43 +00:00
cflags="$cflags -D__sun__ -D__${s}__"
2004-03-26 05:01:11 +00:00
;;
2020-05-19 02:38:54 +00:00
*AIX*) usexlc
cflags="$cflags -g -D__AIX__"
2009-07-15 05:55:52 +00:00
;;
*)
echo 9c does not know how to compile on "$tag" 1>&2
exit 1
esac
# Must use temp file to avoid pipe; pipe loses status.
xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out
$cc -DPLAN9PORT -I"$PLAN9/include" $cflags "$@" 2>"$xtmp"
2005-01-07 07:15:31 +00:00
status=$?
quiet "$xtmp"
rm -f "$xtmp"
exit $status