From faaa517636b990b4f6dca685d0bcc5667016cf50 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 13 May 2010 18:41:13 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20deprecate=C2=B9=20-longoptions=20in?= =?UTF-8?q?=20favour=20of=20short=20options=20=20=20=E2=80=A3=20-combine?= =?UTF-8?q?=20=E2=86=92=20-c=20combine=20=20=20=E2=80=A3=20-llvm=20?= =?UTF-8?q?=E2=86=92=20-c=20llvm=20-O=20=20=20=E2=80=A3=20-llvm=3Dx=20?= =?UTF-8?q?=E2=86=92=20-c=20llvm=20-o=20x=20=20=20=E2=80=A3=20-valgrind=20?= =?UTF-8?q?=E2=86=92=20-g=C2=B2=20=E2=80=A2=20new=20option=20-v=20(version?= =?UTF-8?q?)=20=E2=80=A2=20new=20options=20-c=20(compile=20mode=C2=B3),=20?= =?UTF-8?q?-o=20(opt=20flags),=20-O=20(reset=20opt=20flags)=20=E2=80=A2=20?= =?UTF-8?q?opt=20flags=20default=20to=20-std-compile-opts=20(llvm)=20now?= =?UTF-8?q?=20=E2=80=A2=20support=E2=81=B4=20the=20LLVM=20dragonegg=20plug?= =?UTF-8?q?in=20for=20GCC=20=E2=80=A2=20sync=20list=20of=20removed=20files?= =?UTF-8?q?=20(*.bc,=20*.ll,=20add=20missing=20Rebuild.sh)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ① old options still valid but emit a warning ② except this one ③ compile modes are: • normal • makefile (-M) • combine (old -combine, new -c combine) • dragonegg (new -c dragonegg) • llvm (old -llvm, old -llvm=*, new -c llvm) the first two are not settable via -c though… ④ sample use: tg@seduxbox:~/x$ export PATH=$PATH:/opt/llvm/bin tg@seduxbox:~/x$ CC='/opt/gcc-4.5.1/bin/gcc-4.5.1 -fplugin=/opt/llvm/lib/dragonegg.so' sh ../mksh/Build.sh -c dragonegg -r Thanks to «dileX:#grml» for giving ssh access. --- Build.sh | 138 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 38 deletions(-) diff --git a/Build.sh b/Build.sh index 3b19a78..a6637ff 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.451 2010/04/20 17:28:20 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.452 2010/05/13 18:41:13 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Thorsten Glaser @@ -283,55 +283,95 @@ if test -d mksh || test -d mksh.exe; then echo "$me: Error: ./mksh is a directory!" >&2 exit 1 fi -rmf a.exe* a.out* conftest.c *core lft mksh* no *.o \ - signames.inc stdint.h test.sh x vv.out +rmf a.exe* a.out* conftest.c *core lft mksh* no *.bc *.ll *.o \ + Rebuild.sh signames.inc stdint.h test.sh x vv.out curdir=`pwd` srcdir=`dirname "$0"` check_categories= test -n "$dirname" || dirname=. +dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\(.*\)".*$/\1/p' $srcdir/sh.h` e=echo r=0 eq=0 pm=0 cm=normal -llvm= +optflags=-std-compile-opts +last= for i do - case $i in - -j) - pm=1 + case $last:$i in + c:combine|c:dragonegg|c:llvm) + cm=$i + last= ;; - -combine) + c:*) + echo "$me: Unknown option -c '$i'!" >&2 + exit 1 + ;; + o:*) + optflags=$i + last= + ;; + :-c) + last=c + ;; + :-combine) cm=combine + echo "$me: Warning: '$i' is deprecated, use '-c combine' instead!" >&2 ;; - -llvm) - cm=llvm - llvm=-std-compile-opts - ;; - -llvm=*) - cm=llvm - llvm=`echo "x$i" | sed 's/^x-llvm=//'` - ;; - -M) - cm=makefile - ;; - -Q) - eq=1 - ;; - -r) - r=1 - ;; - -valgrind) + :-g) + # checker, debug, valgrind build CPPFLAGS="$CPPFLAGS -DDEBUG" CFLAGS="$CFLAGS -g3 -fno-builtin" ;; - *) + :-j) + pm=1 + ;; + :-llvm) + cm=llvm + optflags=-std-compile-opts + echo "$me: Warning: '$i' is deprecated, use '-c llvm -O' instead!" >&2 + ;; + :-llvm=*) + cm=llvm + optflags=`echo "x$i" | sed 's/^x-llvm=//'` + echo "$me: Warning: '$i' is deprecated, use '-c llvm -o $llvm' instead!" >&2 + ;; + :-M) + cm=makefile + ;; + :-O) + optflags=-std-compile-opts + ;; + :-o) + last=o + ;; + :-Q) + eq=1 + ;; + :-r) + r=1 + ;; + :-v) + echo "Build.sh $srcversion" + echo "for mksh $dstversion" + exit 0 + ;; + :*) echo "$me: Unknown option '$i'!" >&2 exit 1 ;; + *) + echo "$me: Unknown option -'$last' '$i'!" >&2 + exit 1 + ;; esac done +if test -n "$last"; then + echo "$me: Option -'$last' not followed by argument!" >&2 + exit 1 +fi SRCS="lalloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c" SRCS="$SRCS jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c" @@ -474,7 +514,6 @@ test 0 = $r && echo | $NROFF -v 2>&1 | grep GNU >/dev/null 2>&1 && \ NROFF="$NROFF -c" # this aids me in tracing FTBFSen without access to the buildd -dstversion=`sed -n '/define MKSH_VERSION/s/^.*"\(.*\)".*$/\1/p' $srcdir/sh.h` $e "Hi from$ao $bi$srcversion$ao on:" case $TARGET_OS in Darwin) @@ -703,7 +742,11 @@ xlc) ct=unknown ;; esac -test $cm = llvm && vv '|' "llc -version" +case $cm in +dragonegg|llvm) + vv '|' "llc -version" + ;; +esac $e "$bi==> which compiler seems to be used...$ao $ui$ct$ao" rmf conftest.c conftest.o conftest a.out* a.exe* vv.out @@ -1480,25 +1523,36 @@ chmod 755 test.sh test $HAVE_CAN_COMBINE$cm = 0combine && cm=normal if test $cm = llvm; then emitbc="-emit-llvm -c" +elif test $cm = dragonegg; then + emitbc="-S -flto" else emitbc=-c fi echo set -x >Rebuild.sh for file in $SRCS; do - of=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1.o/'` - objs="$objs$sp$of" + op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'` test -f $file || file=$srcdir/$file files="$files$sp$file" sp=' ' echo "$CC $CFLAGS $CPPFLAGS $emitbc $file || exit 1" >>Rebuild.sh + if test $cm = dragonegg; then + echo "mv ${op}s ${op}ll" >>Rebuild.sh + echo "llvm-as ${op}ll || exit 1" >>Rebuild.sh + objs="$objs$sp${op}bc" + else + objs="$objs$sp${op}o" + fi done -if test $cm = llvm; then +case $cm in +dragonegg|llvm) echo "rm -f mksh.s" >>Rebuild.sh - echo "llvm-link -o - $objs | opt $llvm | llc -o mksh.s" >>Rebuild.sh + echo "llvm-link -o - $objs | opt $optflags | llc -o mksh.s" >>Rebuild.sh lobjs=mksh.s -else + ;; +*) lobjs=$objs -fi + ;; +esac case $tcfn in a.exe) mkshexe=mksh.exe ;; *) mkshexe=mksh ;; @@ -1564,14 +1618,22 @@ elif test 1 = $pm; then wait else for file in $SRCS; do + test $cm = dragonegg && \ + op=`echo x"$file" | sed 's/^x\(.*\)\.c$/\1./'` test -f $file || file=$srcdir/$file v "$CC $CFLAGS $CPPFLAGS $emitbc $file" || exit 1 + if test $cm = dragonegg; then + v "mv ${op}s ${op}ll" + v "llvm-as ${op}ll" || exit 1 + fi done fi -if test $cm = llvm; then +case $cm in +dragonegg|llvm) rmf mksh.s - v "llvm-link -o - $objs | opt $llvm | llc -o mksh.s" -fi + v "llvm-link -o - $objs | opt $optflags | llc -o mksh.s" + ;; +esac tcfn=$mkshexe test $cm = combine || v "$CC $CFLAGS $LDFLAGS -o $tcfn $lobjs $LIBS $ccpr" test -f $tcfn || exit 1