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
Unified · Split
| @@ -51,11 +51,17 @@ PROGS+=c67-tcc$(EXESUF) i386-win32-tcc$(EXESUF) · 50 unmodified lines | |||
| 51 | endif | 51 | endif |
| 52 | endif | 52 | endif |
| 53 | 53 | ||
| 54 | ifdef CONFIG_USE_LIBGCC | ||
| 55 | LIBTCC1= | ||
| 56 | else | ||
| 57 | LIBTCC1=libtcc1.a | ||
| 58 | endif | ||
| 59 | |||
| 54 | # run local version of tcc with local libraries and includes | 60 | # run local version of tcc with local libraries and includes |
| 55 | TCC=./tcc -B. -I. | 61 | TCC=./tcc -B. -I. |
| 56 | 62 | ||
| 57 | all: $(PROGS) \ | 63 | all: $(PROGS) \ |
| 58 | libtcc1.a $(BCHECK_O) tcc-doc.html tcc.1 libtcc.a \ | 64 | $(LIBTCC1) $(BCHECK_O) tcc-doc.html tcc.1 libtcc.a \ |
| 59 | libtcc_test$(EXESUF) | 65 | libtcc_test$(EXESUF) |
| 60 | 66 | ||
| 61 | Makefile: config.mak | 67 | Makefile: config.mak |
| @@ -214,7 +220,7 @@ bcheck.o: bcheck.c · 152 unmodified lines | |||
| 214 | 220 | ||
| 215 | install: tcc_install libinstall | 221 | install: tcc_install libinstall |
| 216 | 222 | ||
| 217 | tcc_install: $(PROGS) tcc.1 libtcc1.a $(BCHECK_O) tcc-doc.html | 223 | tcc_install: $(PROGS) tcc.1 $(LIBTCC1) $(BCHECK_O) tcc-doc.html |
| 218 | mkdir -p "$(DESTDIR)$(bindir)" | 224 | mkdir -p "$(DESTDIR)$(bindir)" |
| 219 | $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)$(bindir)" | 225 | $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)$(bindir)" |
| 220 | ifndef CONFIG_WIN32 | 226 | ifndef CONFIG_WIN32 |
| @@ -225,11 +231,14 @@ endif · 4 unmodified lines | |||
| 225 | mkdir -p "$(DESTDIR)$(tccdir)/include" | 231 | mkdir -p "$(DESTDIR)$(tccdir)/include" |
| 226 | ifdef CONFIG_WIN32 | 232 | ifdef CONFIG_WIN32 |
| 227 | mkdir -p "$(DESTDIR)$(tccdir)/lib" | 233 | mkdir -p "$(DESTDIR)$(tccdir)/lib" |
| 228 | $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(DESTDIR)$(tccdir)/lib" | 234 | $(INSTALL) -m644 $(LIBTCC1) win32/lib/*.def "$(DESTDIR)$(tccdir)/lib" |
| 229 | cp -r win32/include/. "$(DESTDIR)$(tccdir)/include" | 235 | cp -r win32/include/. "$(DESTDIR)$(tccdir)/include" |
| 230 | cp -r win32/examples/. "$(DESTDIR)$(tccdir)/examples" | 236 | cp -r win32/examples/. "$(DESTDIR)$(tccdir)/examples" |
| 231 | else | 237 | else |
| 232 | $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(DESTDIR)$(tccdir)" | 238 | ifndef CONFIG_USE_LIBGCC |
| 239 | $(INSTALL) -m644 libtcc1.a "$(DESTDIR)$(tccdir)" | ||
| 240 | endif | ||
| 241 | $(INSTALL) -m644 $(BCHECK_O) "$(DESTDIR)$(tccdir)" | ||
| 233 | $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ | 242 | $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \ |
| 234 | tcclib.h "$(DESTDIR)$(tccdir)/include" | 243 | tcclib.h "$(DESTDIR)$(tccdir)/include" |
| 235 | endif | 244 | endif |
| @@ -19,6 +19,7 @@ TMPH="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h" · 18 unmodified lines | |||
| 19 | 19 | ||
| 20 | # default parameters | 20 | # default parameters |
| 21 | build_cross="no" | 21 | build_cross="no" |
| 22 | use_libgcc="no" | ||
| 22 | prefix="" | 23 | prefix="" |
| 23 | execprefix="" | 24 | execprefix="" |
| 24 | bindir="" | 25 | bindir="" |
| @@ -127,6 +128,8 @@ for opt do · 102 unmodified lines | |||
| 127 | ;; | 128 | ;; |
| 128 | --enable-cross) build_cross="yes" | 129 | --enable-cross) build_cross="yes" |
| 129 | ;; | 130 | ;; |
| 131 | --with-libgcc) use_libgcc="yes" | ||
| 132 | ;; | ||
| 130 | esac | 133 | esac |
| 131 | done | 134 | done |
| 132 | 135 | ||
| @@ -224,6 +227,7 @@ echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" · 91 unmodified lines | |||
| 224 | echo " --sysroot=PREFIX prepend PREFIX to library/include paths []" | 227 | echo " --sysroot=PREFIX prepend PREFIX to library/include paths []" |
| 225 | echo " --cc=CC use C compiler CC [$cc]" | 228 | echo " --cc=CC use C compiler CC [$cc]" |
| 226 | echo " --make=MAKE use specified make [$make]" | 229 | echo " --make=MAKE use specified make [$make]" |
| 230 | echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a" | ||
| 227 | echo "" | 231 | echo "" |
| 228 | #echo "NOTE: The object files are build at the place where configure is launched" | 232 | #echo "NOTE: The object files are build at the place where configure is launched" |
| 229 | exit 1 | 233 | exit 1 |
| @@ -279,6 +283,7 @@ echo "CPU $cpu" · 49 unmodified lines | |||
| 279 | echo "Big Endian $bigendian" | 283 | echo "Big Endian $bigendian" |
| 280 | echo "gprof enabled $gprof" | 284 | echo "gprof enabled $gprof" |
| 281 | echo "cross compilers $build_cross" | 285 | echo "cross compilers $build_cross" |
| 286 | echo "use libgcc $use_libgcc" | ||
| 282 | 287 | ||
| 283 | echo "Creating config.mak and config.h" | 288 | echo "Creating config.mak and config.h" |
| 284 | 289 | ||
| @@ -345,6 +350,10 @@ fi · 60 unmodified lines | |||
| 345 | if test "$build_cross" = "yes" ; then | 350 | if test "$build_cross" = "yes" ; then |
| 346 | echo "CONFIG_CROSS=yes" >> config.mak | 351 | echo "CONFIG_CROSS=yes" >> config.mak |
| 347 | fi | 352 | fi |
| 353 | if test "$use_libgcc" = "yes" ; then | ||
| 354 | echo "#define CONFIG_USE_LIBGCC" >> $TMPH | ||
| 355 | echo "CONFIG_USE_LIBGCC=yes" >> config.mak | ||
| 356 | fi | ||
| 348 | version=`head $source_path/VERSION` | 357 | version=`head $source_path/VERSION` |
| 349 | echo "VERSION=$version" >>config.mak | 358 | echo "VERSION=$version" >>config.mak |
| 350 | echo "#define TCC_VERSION \"$version\"" >> $TMPH | 359 | echo "#define TCC_VERSION \"$version\"" >> $TMPH |
| @@ -992,7 +992,9 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 991 unmodified lines | |||
| 992 | /* add tcc runtime libraries */ | 992 | /* add tcc runtime libraries */ |
| 993 | static void tcc_add_runtime(TCCState *s1) | 993 | static void tcc_add_runtime(TCCState *s1) |
| 994 | { | 994 | { |
| 995 | #if defined(CONFIG_TCC_BCHECK) || !defined(CONFIG_USE_LIBGCC) | ||
| 995 | char buf[1024]; | 996 | char buf[1024]; |
| 997 | #endif | ||
| 996 | 998 | ||
| 997 | #ifdef CONFIG_TCC_BCHECK | 999 | #ifdef CONFIG_TCC_BCHECK |
| 998 | if (do_bounds_check) { | 1000 | if (do_bounds_check) { |
| @@ -1028,8 +1030,12 @@ static void tcc_add_runtime(TCCState *s1) · 29 unmodified lines | |||
| 1028 | if (!s1->nostdlib) { | 1030 | if (!s1->nostdlib) { |
| 1029 | tcc_add_library(s1, "c"); | 1031 | tcc_add_library(s1, "c"); |
| 1030 | 1032 | ||
| 1033 | #ifdef CONFIG_USE_LIBGCC | ||
| 1034 | tcc_add_file(s1, CONFIG_SYSROOT "/lib/libgcc_s.so.1"); | ||
| 1035 | #else | ||
| 1031 | snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a"); | 1036 | snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a"); |
| 1032 | tcc_add_file(s1, buf); | 1037 | tcc_add_file(s1, buf); |
| 1038 | #endif | ||
| 1033 | } | 1039 | } |
| 1034 | /* add crt end if not memory output */ | 1040 | /* add crt end if not memory output */ |
| 1035 | if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) { | 1041 | if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) { |