Compiling ELinks with Tiny C Compiler
=====================================

ELinks has been successfully compiled with http://www.tinycc.org/[Tiny
C Compiler] version 0.9.23, however there are several problems.
This file lists some of these problems and their possible solutions.

Perl uses unsupported -Wl,-E
----------------------------

----------------------------------------------------------------------
checking for Perl... no
----------------------------------------------------------------------

`config.log` reveals:

----------------------------------------------------------------------
configure:18039: checking for Perl
configure:18082: tcc -o conftest ... -rdynamic conftest.c -Wl,-E ... -lperl ... >&5
tcc: unsupported linker option '-E'
configure:18088: $? = 1
...
configure:18106: result: no
----------------------------------------------------------------------

The `-Wl,-E` option comes from this command:

----------------------------------------------------------------------
perl -MExtUtils::Embed -e ldopts
----------------------------------------------------------------------

TCC 0.9.23 does not support the option, so ELinks builds without Perl.

Python uses unsupported -Xlinker -export-dynamic
------------------------------------------------

----------------------------------------------------------------------
checking for Python... yes
checking for python... /usr/bin/python
...
Browser scripting ............... Guile, Lua, SpiderMonkey
----------------------------------------------------------------------

`config.log` reveals:

----------------------------------------------------------------------
configure:18204: checking for Python
configure:18208: result: yes
configure:18219: checking for python
configure:18237: found /usr/bin/python
configure:18250: result: /usr/bin/python
configure:18287: tcc -o conftest ... -rdynamic conftest.c -Xlinker -export-dynamic ... -lpython2.3 ... >&5
tcc: invalid option -- '-Xlinker'
configure:18293: $? = 1
----------------------------------------------------------------------

The `-Xlinker -export-dynamic` options come from this command:

----------------------------------------------------------------------
python -c 'from distutils import sysconfig; print sysconfig.get_config_var("LINKFORSHARED")'
----------------------------------------------------------------------

TCC 0.9.23 does not support `-Xlinker`, so ELinks builds without
Python.

Ruby uses unsupported -Wl,-export-dynamic
-----------------------------------------

----------------------------------------------------------------------
checking for Ruby... yes
checking for ruby... /usr/bin/ruby
checking Ruby version... 1.8.3
checking for Ruby header files... /usr/lib/ruby/1.8/i486-linux
configure: error: Ruby not found
----------------------------------------------------------------------

`config.log` reveals:

----------------------------------------------------------------------
configure:18617: checking for Ruby
configure:18641: result: yes
configure:18653: checking for ruby
configure:18671: found /usr/bin/ruby
configure:18684: result: /usr/bin/ruby
configure:18694: checking Ruby version
configure:18698: result: 1.8.3
configure:18701: checking for Ruby header files
configure:18706: result: /usr/lib/ruby/1.8/i486-linux
configure:18765: tcc -o conftest ... -rdynamic -Wl,-export-dynamic ... conftest.c -lruby1.8 ... >&5
tcc: unsupported linker option '-export-dynamic'
configure:18771: $? = 1
configure:18808: error: Ruby not found
----------------------------------------------------------------------

The `-rdynamic -Wl,-export-dynamic` options come from this command:

----------------------------------------------------------------------
ruby -r rbconfig -e 'print Config::CONFIG["LDFLAGS"]'
----------------------------------------------------------------------

TCC 0.9.23 supports the former but not the latter.  To work around the
error, configure `\--without-ruby`.

Stabs entry has invalid string index
------------------------------------

----------------------------------------------------------------------
ld -r -o lib.o frames.o parser.o renderer.o tables.o parser/lib.o
ld: parser/lib.o(.stab+0x2688): Stabs entry has invalid string index.
parser/lib.o: could not read symbols: Bad value
----------------------------------------------------------------------

Apparently, GNU ld 2.16.91 does not like the debug information
generated by TCC 0.9.23.  To work around the error, either set
`LD=tcc` or remove `-g` from `CFLAGS`.

Linker segfault
---------------

If you configure ELinks with both `\--with-gnutls` and `\--with-guile`,
TCC 0.9.23 crashes when it's trying to link ELinks.

http://bugs.debian.org/418360[Debian bug #418360] has a patch that
fixes this.

Undefined symbol alloca
-----------------------

----------------------------------------------------------------------
    [LINK]   src/elinks
tcc: undefined symbol 'alloca'
----------------------------------------------------------------------

GNU libc 2.3.6 declares `alloca()` in `<alloca.h>` but does not
actually define it as a function, perhaps because the definition must
be specific to each compiler.  TCC 0.9.23 does not define `alloca()`
either and fails to generate an executable but stupidly exits with
code 0.

In ELinks, only `intl/gettext/plural.c` uses `alloca()`, so you can
avoid the error with `configure --disable-nls`.

Unexpanded @HAVE_ALLOCA_H@ in <see/type.h>
------------------------------------------

----------------------------------------------------------------------
.../include/see/type.h:180: identifier expected
----------------------------------------------------------------------

`<see/type.h>` of
http://www.adaptive-enterprises.com.au/~d/software/see/[Simple
ECMAScript Engine] 2.0.1131 has an unexpanded `@HAVE_ALLOCA_H@` inside
`#ifndef __GNUC__`.  Of course, TCC 0.9.23 does not define `__GNUC__`,
so an error results.  To avoid the error, either configure ELinks
`\--without-see`, or edit `<see/type.h>`.

Reported as
http://www.adaptive-enterprises.com.au/bugs/show_bug.cgi?id=65[SEE bug 65].

Advanced: Compiling SEE with TCC
--------------------------------

If you want even more problems, try compiling Simple ECMAScript Engine
with Tiny C Compiler as well.

Wrong precedence of sizeof
~~~~~~~~~~~~~~~~~~~~~~~~~~

----------------------------------------------------------------------
.../see-2.0.1131/libsee/unicase.c:86: pointer expected
----------------------------------------------------------------------

TCC 0.9.23 misparses `sizeof (a)[0]` used in the `lengthof` macro.
To work around the bug, change it to `sizeof ((a)[0])`.

Reported as http://bugs.debian.org/419203[Debian bug #419203].

Linker option -soname not supported
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----------------------------------------------------------------------
tcc: invalid option -- '-soname'
----------------------------------------------------------------------

To construct a proper ELF library, the build system of SEE 2.0.1131
must specify the shared object name.  Unfortunately, TCC 0.9.23 does
not appear to support any such option.  So, use some other linker.
