Support for tcc as a linker

2014-07-31 Thread Reuben Thomas
Last year, libtool gained support for tcc as a compiler, but up to now it
didn't always work as a linker (configuring a project using:

CC=tcc LD=tcc ./configure

; if the LD=tcc setting is omitted then configure assumes that ld is
being used, diagnoses GNU ld (typically), and then fails e.g. with
--whole-archive not being supported when it tries to link by running tcc
(which does not call ld, but does its own linking).

The attached patch against current git HEAD adds tcc support on Linux in
the non-GNU ld section _LT_LINKER_SHLIBS. I guess it could be added for
other kernels that tcc supports, but I'm not sure what they are, nor how to
add the support without unfortunate duplication (the logic seems to be set
up to assume either gcc or a system compiler).

At present, tcc can't be treated like GNU ld, because it doesn't understand
--{no,}-whole-archive, though there is a patch for that from some years ago
which I'm going to see if I can fix up.'

With my attached libtool.m4 patch, I am able to build and run FontForge,
which is ~500kLOC of C dating from all parts of the last 14 years, using
tcc and libtool git HEAD. I'd say that's quite impressive for both tcc and
libtool! (My motivation is to have a quicker build, which tcc certainly
gives.)

-- 
http://rrt.sc3d.org
From 10695a219fe0de117a72a3408ee5f1f12409fd56 Mon Sep 17 00:00:00 2001
From: Reuben Thomas r...@sc3d.org
Date: Thu, 31 Jul 2014 15:32:13 +0100
Subject: [PATCH] libtool.m4: add support for tcc as linker

---
 m4/libtool.m4 | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 320d8b3..91b460e 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -5515,6 +5515,16 @@ _LT_EOF
   _LT_TAGVAR(link_all_deplibs, $1)=yes
   ;;
 
+linux*)
+  case $cc_basename in
+  tcc*)
+	# Fabrice Bellard et al's Tiny C Compiler
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+  esac
+  ;;
+
 netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ /dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-- 
1.9.1



Add dynamic export support for tcc

2014-07-31 Thread Reuben Thomas
The attached patch adds support for tcc's -rdynamic, the equivalent of GNU
ld's -Wl,--export-dynamic.

-- 
http://rrt.sc3d.org
From 33d504492e36cb875d15c12515a2ab6b160931f6 Mon Sep 17 00:00:00 2001
From: Reuben Thomas r...@sc3d.org
Date: Thu, 31 Jul 2014 16:53:58 +0100
Subject: [PATCH] Add dynamic export support for tcc

---
 m4/libtool.m4 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 91b460e..6c6b2f2 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -5015,6 +5015,9 @@ _LT_EOF
 fi
 
 	case $cc_basename in
+tcc*)
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+	  ;;
 	xlf* | bgf* | bgxlf* | mpixlf*)
 	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
 	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
-- 
1.9.1