# HG changeset patch # User Rob Landley # Date 1199394261 21600 # Node ID 9778e985b450310c78569c8843363487fb96b828 # Parent 3f683703c8dba301e846a77d4ca040f3ed8b489c Rename runtime library to libtinyccrt-$ARCH.a, build libtinycc-$ARCH.so to use the compiler itself as a dynamic code generation library. diff -r 3f683703c8db -r 9778e985b450 make/install.sh --- a/make/install.sh Fri Dec 28 17:33:06 2007 -0600 +++ b/make/install.sh Thu Jan 03 15:04:21 2008 -0600 @@ -11,7 +11,7 @@ # Install libraries and headers $DEBUG mkdir -p "$TINYCC_INSTALLDIR"/{lib,include} && -$DEBUG cp libtinycc-*.a "$TINYCC_INSTALLDIR"/lib && +$DEBUG cp libtinyccrt-*.a libtinycc-*.so "$TINYCC_INSTALLDIR"/lib && $DEBUG cp include/* "$TINYCC_INSTALLDIR"/include && # Install binaries diff -r 3f683703c8db -r 9778e985b450 make/make.sh --- a/make/make.sh Fri Dec 28 17:33:06 2007 -0600 +++ b/make/make.sh Thu Jan 03 15:04:21 2008 -0600 @@ -9,20 +9,30 @@ DOLOCAL="-B. -I./include -I." +# Invoke the compiler with all the appropriate arguments + +function compile_tinycc() +{ + OUTFILE=$1 + shift + $DEBUG $CC $@ -o $OUTFILE $CFLAGS $LIBS \ + -DTINYCC_TARGET_$(echo $ARCH | tr a-z A-Z) \ + -DTINYCC_TARGET='"'$ARCH'"' \ + -DTINYCC_VERSION='"'$TINYCC_VERSION'"' \ + -DTINYCC_INSTALLDIR='"'$TINYCC_INSTALLDIR'"' \ + -DCC_CRTDIR='"'$CC_CRTDIR'"' \ + -DCC_LIBPATH='"'$CC_LIBPATH'"' \ + -DCC_HEADERPATH='"'$CC_HEADERPATH'"' +} + + function build() { source ./configure -v # Build tinycc with a specific architecture and search paths. - $DEBUG $CC tcc.c options.c -o $1-tinycc_unstripped $CFLAGS $LIBS \ - -DTINYCC_TARGET_$(echo $1 | tr a-z A-Z) \ - -DTINYCC_TARGET='"'$1'"' \ - -DTINYCC_VERSION='"'$TINYCC_VERSION'"' \ - -DTINYCC_INSTALLDIR='"'$TINYCC_INSTALLDIR'"' \ - -DCC_CRTDIR='"'$CC_CRTDIR'"' \ - -DCC_LIBPATH='"'$CC_LIBPATH'"' \ - -DCC_HEADERPATH='"'$CC_HEADERPATH'"' && + ARCH=$1 compile_tinycc $1-tinycc_unstripped tcc.c options.c && $DEBUG $STRIP $1-tinycc_unstripped -o $1-tinycc [ $? -ne 0 ] && exit 1 @@ -33,7 +43,11 @@ $DEBUG ln -s $1-tinycc tinycc #fi - # Build libtinycc1.a + # Compile tinycc as a shared library. + + ARCH=$1 compile_tinycc libtinycc-$1.so -shared -fPIC -DLIBTCC tcc.c && + + # Build libtinyccrt-$ARCH.a (which compiled programs link against) if [ -f $1/alloca.S ] then @@ -41,7 +55,7 @@ $DEBUG ./$1-tinycc $DOLOCAL -o libtinycc1-$1.o -c libtinycc1.c && $DEBUG ./$1-tinycc $DOLOCAL -o alloca-$1.o -c $1/alloca.S && $DEBUG ./$1-tinycc $DOLOCAL -o bound-alloca-$1.o -c $1/bound-alloca.S && - $DEBUG $AR rcs libtinycc-$1.a {libtinycc1,alloca,bound-alloca}-$1.o + $DEBUG $AR rcs libtinyccrt-$1.a {libtinycc1,alloca,bound-alloca}-$1.o fi } diff -r 3f683703c8db -r 9778e985b450 tccelf.c --- a/tccelf.c Fri Dec 28 17:33:06 2007 -0600 +++ b/tccelf.c Thu Jan 03 15:04:21 2008 -0600 @@ -1011,7 +1011,7 @@ // add libc if (!s1->nostdlib) { tcc_add_library(s1, "c"); - tcc_add_library(s1, "tinycc-" TINYCC_TARGET); + tcc_add_library(s1, "tinyccrt-" TINYCC_TARGET); // add crt end if not memory output if (s1->output_type != TCC_OUTPUT_MEMORY) tcc_add_file(s1, CC_CRTDIR "/crtn.o"); diff -r 3f683703c8db -r 9778e985b450 tests/libtcc_test.c --- a/tests/libtcc_test.c Fri Dec 28 17:33:06 2007 -0600 +++ b/tests/libtcc_test.c Thu Jan 03 15:04:21 2008 -0600 @@ -6,7 +6,7 @@ #include #include -#include "../libtcc.h" +#include "../libtinycc.h" /* this function is called by the generated code */ int add(int a, int b) @@ -44,7 +44,7 @@ } /* MUST BE CALLED before any compilation or file loading */ - tcc_set_output_type(s, TCC_OUTPUT_MEMORY); + init_output_type(s, TCC_OUTPUT_MEMORY); tcc_compile_string(s, my_program);