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

From 10695a219fe0de117a72a3408ee5f1f12409fd56 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <>
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
+      ;;
       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

Reply via email to