This patch adds a switch --with-libgcc to configure.
When passed it prevents libtcc1.a from being built and links to
/lib/libgcc_s.so.1 instead of PREFIX/lib/tcc/libtcc1.a.

It will work on ARM when using libgcc from GCC >= 4.2.0.
Prior versions don't have the __floatun[sd]i[sdx]f functions.

It won't work on i386 because of two missing symbols emitted when
floats are cast to integers, but users can provide those symbols
(global short constants) in their code if needed.

  Daniel
diff -rud tcc-0.9.24-immed3/Makefile tcc-0.9.24-immed4/Makefile
--- tcc-0.9.24-immed3/Makefile  Fri Sep  5 18:13:06 2008
+++ tcc-0.9.24-immed4/Makefile  Fri Sep  5 18:17:55 2008
@@ -51,11 +51,17 @@
 endif
 endif
 
+ifdef CONFIG_USE_LIBGCC
+LIBTCC1=
+else
+LIBTCC1=libtcc1.a
+endif
+
 # run local version of tcc with local libraries and includes
 TCC=./tcc -B. -I.
 
 all: $(PROGS) \
-     libtcc1.a $(BCHECK_O) tcc-doc.html tcc.1 libtcc.a \
+     $(LIBTCC1) $(BCHECK_O) tcc-doc.html tcc.1 libtcc.a \
      libtcc_test$(EXESUF)
 
 Makefile: config.mak
@@ -214,7 +220,7 @@
 
 install: tcc_install libinstall
 
-tcc_install: $(PROGS) tcc.1 libtcc1.a $(BCHECK_O) tcc-doc.html
+tcc_install: $(PROGS) tcc.1 $(LIBTCC1) $(BCHECK_O) tcc-doc.html
        mkdir -p "$(bindir)"
        $(INSTALL) -s -m755 $(PROGS) "$(bindir)"
 ifndef CONFIG_WIN32
@@ -225,11 +231,14 @@
        mkdir -p "$(tccdir)/include"
 ifdef CONFIG_WIN32
        mkdir -p "$(tccdir)/lib"
-       $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib"
+       $(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(tccdir)/lib"
        cp -r win32/include/. "$(tccdir)/include"
        cp -r win32/examples/. "$(tccdir)/examples"
 else
-       $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(tccdir)"
+ifndef CONFIG_USE_LIBGCC
+       $(INSTALL) -m644 libtcc1.a "$(tccdir)"
+endif
+       $(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
        $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
                    tcclib.h "$(tccdir)/include"
 endif
diff -rud tcc-0.9.24-immed3/configure tcc-0.9.24-immed4/configure
--- tcc-0.9.24-immed3/configure Fri Sep  5 18:13:24 2008
+++ tcc-0.9.24-immed4/configure Fri Sep  5 18:17:55 2008
@@ -19,6 +19,7 @@
 
 # default parameters
 build_cross="no"
+use_libgcc="no"
 prefix=""
 execprefix=""
 bindir=""
@@ -127,6 +128,8 @@
   ;; 
   --enable-cross) build_cross="yes"
   ;;
+  --with-libgcc) use_libgcc="yes"
+  ;;
   esac
 done
 
@@ -224,6 +227,7 @@
 echo "  --sysroot=PREFIX         prepend PREFIX to library/include paths []"
 echo "  --cc=CC                  use C compiler CC [$cc]"
 echo "  --make=MAKE              use specified make [$make]"
+echo "  --with-libgcc            use /lib/libgcc_s.so.1 instead of libtcc1.a"
 echo ""
 #echo "NOTE: The object files are build at the place where configure is 
launched"
 exit 1
@@ -279,6 +283,7 @@
 echo "Big Endian       $bigendian"
 echo "gprof enabled    $gprof"
 echo "cross compilers  $build_cross"
+echo "use libgcc       $use_libgcc"
 
 echo "Creating config.mak and config.h"
 
@@ -344,6 +349,10 @@
 fi
 if test "$build_cross" = "yes" ; then
   echo "CONFIG_CROSS=yes" >> config.mak
+fi
+if test "$use_libgcc" = "yes" ; then
+  echo "#define CONFIG_USE_LIBGCC" >> $TMPH
+  echo "CONFIG_USE_LIBGCC=yes" >> config.mak
 fi
 version=`head $source_path/VERSION`
 echo "VERSION=$version" >>config.mak
diff -rud tcc-0.9.24-immed3/tccelf.c tcc-0.9.24-immed4/tccelf.c
--- tcc-0.9.24-immed3/tccelf.c  Mon Mar 31 09:24:00 2008
+++ tcc-0.9.24-immed4/tccelf.c  Fri Sep  5 18:17:55 2008
@@ -992,7 +992,9 @@
 /* add tcc runtime libraries */
 static void tcc_add_runtime(TCCState *s1)
 {
+#if defined(CONFIG_TCC_BCHECK) || !defined(CONFIG_USE_LIBGCC)
     char buf[1024];
+#endif
 
 #ifdef CONFIG_TCC_BCHECK
     if (do_bounds_check) {
@@ -1028,8 +1030,12 @@
     if (!s1->nostdlib) {
         tcc_add_library(s1, "c");
 
+#ifdef CONFIG_USE_LIBGCC
+        tcc_add_file(s1, CONFIG_SYSROOT "/lib/libgcc_s.so.1");
+#else
         snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a");
         tcc_add_file(s1, buf);
+#endif
     }
     /* add crt end if not memory output */
     if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) {

Attachment: pgpFUyFXnEE22.pgp
Description: PGP signature

_______________________________________________
Tinycc-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to