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
5151 endif
5252 endif
5353
54+ifdef CONFIG_USE_LIBGCC
55+LIBTCC1=
56+else
57+LIBTCC1=libtcc1.a
58+endif
59+
5460 # run local version of tcc with local libraries and includes
5561 TCC=./tcc -B. -I.
5662
5763 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 \
5965 libtcc_test$(EXESUF)
6066
6167 Makefile: config.mak
@@ -214,7 +220,7 @@ bcheck.o: bcheck.c · 152 unmodified lines
214220
215221 install: tcc_install libinstall
216222
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
218224 mkdir -p "$(DESTDIR)$(bindir)"
219225 $(INSTALL) -s -m755 $(PROGS) "$(DESTDIR)$(bindir)"
220226 ifndef CONFIG_WIN32
@@ -225,11 +231,14 @@ endif · 4 unmodified lines
225231 mkdir -p "$(DESTDIR)$(tccdir)/include"
226232 ifdef CONFIG_WIN32
227233 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"
229235 cp -r win32/include/. "$(DESTDIR)$(tccdir)/include"
230236 cp -r win32/examples/. "$(DESTDIR)$(tccdir)/examples"
231237 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)"
233242 $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
234243 tcclib.h "$(DESTDIR)$(tccdir)/include"
235244 endif
configure+9−0
@@ -19,6 +19,7 @@ TMPH="${TMPDIR1}/tcc-conf-${RANDOM}-$$-${RANDOM}.h" · 18 unmodified lines
1919
2020 # default parameters
2121 build_cross="no"
22+use_libgcc="no"
2223 prefix=""
2324 execprefix=""
2425 bindir=""
@@ -127,6 +128,8 @@ for opt do · 102 unmodified lines
127128 ;;
128129 --enable-cross) build_cross="yes"
129130 ;;
131+ --with-libgcc) use_libgcc="yes"
132+ ;;
130133 esac
131134 done
132135
@@ -224,6 +227,7 @@ echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" · 91 unmodified lines
224227 echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
225228 echo " --cc=CC use C compiler CC [$cc]"
226229 echo " --make=MAKE use specified make [$make]"
230+echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc1.a"
227231 echo ""
228232 #echo "NOTE: The object files are build at the place where configure is launched"
229233 exit 1
@@ -279,6 +283,7 @@ echo "CPU $cpu" · 49 unmodified lines
279283 echo "Big Endian $bigendian"
280284 echo "gprof enabled $gprof"
281285 echo "cross compilers $build_cross"
286+echo "use libgcc $use_libgcc"
282287
283288 echo "Creating config.mak and config.h"
284289
@@ -345,6 +350,10 @@ fi · 60 unmodified lines
345350 if test "$build_cross" = "yes" ; then
346351 echo "CONFIG_CROSS=yes" >> config.mak
347352 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
348357 version=`head $source_path/VERSION`
349358 echo "VERSION=$version" >>config.mak
350359 echo "#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
992992 /* add tcc runtime libraries */
993993 static void tcc_add_runtime(TCCState *s1)
994994 {
995+#if defined(CONFIG_TCC_BCHECK) || !defined(CONFIG_USE_LIBGCC)
995996 char buf[1024];
997+#endif
996998
997999 #ifdef CONFIG_TCC_BCHECK
9981000 if (do_bounds_check) {
@@ -1028,8 +1030,12 @@ static void tcc_add_runtime(TCCState *s1) · 29 unmodified lines
10281030 if (!s1->nostdlib) {
10291031 tcc_add_library(s1, "c");
10301032
1033+#ifdef CONFIG_USE_LIBGCC
1034+ tcc_add_file(s1, CONFIG_SYSROOT "/lib/libgcc_s.so.1");
1035+#else
10311036 snprintf(buf, sizeof(buf), "%s/%s", tcc_lib_path, "libtcc1.a");
10321037 tcc_add_file(s1, buf);
1038+#endif
10331039 }
10341040 /* add crt end if not memory output */
10351041 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