* net/loveruby/cflat/compiler/Compiler.java: link libcbc on making executables.

* Makefile: new file.
* lib/Makefile: new file to build libcbc.a.
* test: test varargs.
* install.sh: new file.
* README: change install.sh usage.


git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4021 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-09-15 12:19:11 +00:00
parent 30433983ca
commit ae0f46cee4
9 changed files with 82 additions and 9 deletions

View File

@ -1,3 +1,18 @@
Mon Sep 15 21:19:05 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/Compiler.java: link libcbc on making
executables.
* Makefile: new file.
* lib/Makefile: new file to build libcbc.a.
* test: test varargs.
* install.sh: new file.
* README: change install.sh usage.
Mon Sep 15 01:31:28 2008 Minero Aoki <aamine@loveruby.net>
* bin/cbc: allow overriding java runtime by setting JAVA

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
ANT = ant
default: all
all: lib/cbc.jar lib/libcbc.a
lib/cbc.jar:
$(ANT) compile
lib/libcbc.a:
cd lib; $(MAKE) libcbc.a
clean:
$(ANT) clean
cd lib; $(MAKE) clean
cd test; $(MAKE) clean
test:
cd test; $(MAKE) test

7
README
View File

@ -10,13 +10,15 @@ Requirements
* Java SDK 1.4 or later
* JavaCC 4.0 or later
* ant
* make
To run cbc and compiled program:
* Linux 2.4 or later
* util-linux (ld-linux.so.2)
* GNU libc 2.3 or later
* GNU binutils (as, ld)
* util-linux (ld-linux.so.2)
Installation
@ -26,13 +28,14 @@ Installation
or
$ prefix=$HOME/local ./install.sh
$ ./install.sh $HOME/local/cbc
Build
-----
$ ant compile
$ make
Test

4
ToDo
View File

@ -2,8 +2,6 @@
== Current
* write install.sh
* va_list
* -O (peephole optimization)
* movl $0, %eax => xorl %eax, %eax
* addl $1, %eax => incl %eax
@ -234,3 +232,5 @@
- -L
- -Wl, -Xlinker
- -Wa, -Xassembler
- write install.sh
- va_list

View File

@ -15,7 +15,7 @@ invoke() {
echo "version=$version"
echo "prefix=$prefix"
invoke mkdir -p "$prefix/bin"
invoke cp bin/cbc bin/cbci "$prefix/bin
invoke cp bin/cbc "$prefix/bin
invoke mkdir -p "$prefix/lib"
invoke cp cbc.jar lib/libcbc.o "$prefix/lib"
echo "cbc successfully installed as $prefix/bin/cbc"

10
lib/Makefile Normal file
View File

@ -0,0 +1,10 @@
.SUFFIXES:
libcbc.a: libcbc.o
ar cr libcbc.a libcbc.o
libcbc.o: libcbc.cb
../bin/cbc -c $< -o $@
clean:
rm -f libcbc.a *.o *.s

View File

@ -205,11 +205,18 @@ public class Compiler {
// FIXME: -dynamic-linker required only on dynamic linking
cmd.add("-dynamic-linker");
cmd.add("/lib/ld-linux.so.2");
if (! opts.noStartFiles()) cmd.add("/usr/lib/crt1.o");
if (! opts.noStartFiles()) cmd.add("/usr/lib/crti.o");
if (! opts.noStartFiles()) {
cmd.add("/usr/lib/crt1.o");
cmd.add("/usr/lib/crti.o");
}
cmd.addAll(opts.ldArgs());
if (! opts.noDefaultLibs()) cmd.add("-lc");
if (! opts.noStartFiles()) cmd.add("/usr/lib/crtn.o");
if (! opts.noDefaultLibs()) {
cmd.add("-lc");
cmd.add("-lcbc");
}
if (! opts.noStartFiles()) {
cmd.add("/usr/lib/crtn.o");
}
cmd.add("-o");
cmd.add(opts.exeFileName());
invoke(cmd, opts.isVerboseMode());

View File

@ -294,6 +294,10 @@ test_33_multipleinput() {
assert_status 4 ./src
}
test_34_varargs() {
assert_out "1;2;3" ./varargs
}
###
### Local Assertions
###

15
test/varargs.cb Normal file
View File

@ -0,0 +1,15 @@
import stdio;
import stdarg;
int
main(int argc, char** argv)
{
myprintf("%d;%d;%d\n", 1, 2, 3);
}
static void
myprintf(char* fmt, ...)
{
va_list ap = va_init(&fmt);
vfprintf(stdout, fmt, ap);
}