History

Allow to use libgcc instead of libtcc1

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

Daniel Glöckner committed 18 years ago

Commit 15e0dc01 parent 256f6e63 files · +28 −4Browse files

Unified · Split

3 files
  1. Makefile +13 −4
  2. configure +9 −0
  3. tccelf.c +6 −0
Makefile+13−4
@@ -51,11 +51,17 @@ PROGS+=c67-tcc$(EXESUF) i386-win32-tcc$(EXESUF) · 50 unmodified lines
51endif51endif
52endif52endif
53 53
54ifdef CONFIG_USE_LIBGCC
55LIBTCC1=
56else
57LIBTCC1=libtcc1.a
58endif
59
54# run local version of tcc with local libraries and includes60# run local version of tcc with local libraries and includes
55TCC=./tcc -B. -I.61TCC=./tcc -B. -I.
56 62
57all: $(PROGS) \63all: $(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
61Makefile: config.mak67Makefile: config.mak
@@ -214,7 +220,7 @@ bcheck.o: bcheck.c · 152 unmodified lines
214 220
215install: tcc_install libinstall221install: tcc_install libinstall
216 222
217tcc_install: $(PROGS) tcc.1 libtcc1.a $(BCHECK_O) tcc-doc.html223tcc_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)"
220ifndef CONFIG_WIN32226ifndef CONFIG_WIN32
@@ -225,11 +231,14 @@ endif · 4 unmodified lines
225 mkdir -p "$(DESTDIR)$(tccdir)/include"231 mkdir -p "$(DESTDIR)$(tccdir)/include"
226ifdef CONFIG_WIN32232ifdef 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"
231else237else
232 $(INSTALL) -m644 libtcc1.a $(BCHECK_O) "$(DESTDIR)$(tccdir)"238ifndef CONFIG_USE_LIBGCC
239 $(INSTALL) -m644 libtcc1.a "$(DESTDIR)$(tccdir)"
240endif
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"
235endif244endif
configure+9−0
@@ -19,6 +19,7 @@ TMPH="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h" · 18 unmodified lines
19 19
20# default parameters20# default parameters
21build_cross="no"21build_cross="no"
22use_libgcc="no"
22prefix=""23prefix=""
23execprefix=""24execprefix=""
24bindir=""25bindir=""
@@ -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 esac133 esac
131done134done
132 135
@@ -224,6 +227,7 @@ echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" · 91 unmodified lines
224echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"227echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
225echo " --cc=CC use C compiler CC [$cc]"228echo " --cc=CC use C compiler CC [$cc]"
226echo " --make=MAKE use specified make [$make]"229echo " --make=MAKE use specified make [$make]"
230echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a"
227echo ""231echo ""
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"
229exit 1233exit 1
@@ -279,6 +283,7 @@ echo "CPU $cpu" · 49 unmodified lines
279echo "Big Endian $bigendian"283echo "Big Endian $bigendian"
280echo "gprof enabled $gprof"284echo "gprof enabled $gprof"
281echo "cross compilers $build_cross"285echo "cross compilers $build_cross"
286echo "use libgcc $use_libgcc"
282 287
283echo "Creating config.mak and config.h"288echo "Creating config.mak and config.h"
284 289
@@ -345,6 +350,10 @@ fi · 60 unmodified lines
345if test "$build_cross" = "yes" ; then350if test "$build_cross" = "yes" ; then
346 echo "CONFIG_CROSS=yes" >> config.mak351 echo "CONFIG_CROSS=yes" >> config.mak
347fi352fi
353if test "$use_libgcc" = "yes" ; then
354 echo "#define CONFIG_USE_LIBGCC" >> $TMPH
355 echo "CONFIG_USE_LIBGCC=yes" >> config.mak
356fi
348version=`head $source_path/VERSION`357version=`head $source_path/VERSION`
349echo "VERSION=$version" >>config.mak358echo "VERSION=$version" >>config.mak
350echo "#define TCC_VERSION \"$version\"" >> $TMPH359echo "#define TCC_VERSION \"$version\"" >> $TMPH
tccelf.c+6−0
@@ -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 */
993static void tcc_add_runtime(TCCState *s1)993static 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_BCHECK999#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) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t