[linux-elitists] Adventures in Compiling

Shlomi Fish shlomif at iglu.org.il
Mon May 25 10:26:01 PDT 2009


I've generally been using GCC ( http://gcc.gnu.org/ ) exclusively for
compiling Freecell Solver ( http://fc-solve.berlios.de/ ) under Linux for
its constant development. For a time, I used to compile the Windows binaries
using Microsoft Visual C ("cl.exe") and a really hideous batch file I wrote
for the purpose that would work on the Technion's computer. Lately, however,
I've switched to compiling using MinGW on Windows, which is gcc based.

A few weeks ago, I decided to try out what other compilers had to offer. I
downloaded the proprietary icc (Intel's C Compiler), which is gcc-compatible
and has a Linux trial version. It was a huge download and a huge installation. 
At first, I could not get it to emit working code, but after messing a little
with my makefiles, I was successful. It is about the same speed as gcc for
compiling my ANSI C program (maybe a bit slower), and generates somewhat 
faster
code.

icc kept emitting many of the so-called "remarks" which I eventually took upon
myself to eliminate. This improved the quality of my code. But it worked
properly with these many remarks being emitted. After installing icc,
msec (the Mandriva security mechanism) complained about world-writable files
in the icc installation, so I reported it on the Intel forum. 

The next compiler I tried was tcc, the Tiny/Turbo C Compiler ( 
http://bellard.org/tcc/ ). The version in the Mandriva repositories was old
and did not yield a working binary, and so I tried upgrading to version 0.9.24
and then to the git version, but none of them worked either. I reported my
attempt here:

http://lists.gnu.org/archive/html/tinycc-devel/2009-05/msg00032.html

However, later on, after cleaning up my makefile, tcc produced perfectly
working binaries. I don't know what the problem was, but it was solved. (I
reported that in a reply). Compiling with tcc is much faster than with gcc,
but the resulting code is much slower than gcc's, and occupies more space on 
the disk.

I also tried icc's -fast flag, which is supposed to make the output faster,
but it actually made the binaries slower (much slower than even gcc).

---------------

The next compiler was TenDRA. Now http://www.tendra.org/ returned a 403 (and
still does) and so I went on Freenode and asked. I eventually did:

$ svn co http://svn.tendra.org/trunk/

Only to discover that http://svn.tendra.org/trunk/tendra/INSTALL is empty
except for a reference to the Trac web-site. So I needed to use the guidance
of the people from Freenode's #tendra to build it.

In the process, I had to install bmake 
( http://www.crufty.net/help/sjg/bmake.html ) because that's the only make
that would compile TenDRA. The ./configure in the standard distribution
failed to work here, but I was able to find an .src.rpm which compiled 
and installed fine. TenDRA also complained about one of my system's header
which had a list or enum with a trailing comma, and I had to manually remove
that comma.

But I was able to build TenDRA and install it, and it was able to compile
a working program. Before it did, though, I had to fix many compilation
errors it reported, as TenDRA is stricter than gcc. It also didn't recognise
my use of strdup, and I had to specify -Ysystem for it to work (the previous
-Y's I tried did not work properly). But then it worked. 

TenDRA generated larger and slower executables than gcc but it worked.

---------------------

I failed to get lcc ( http://www.cs.princeton.edu/software/lcc/ - it isn't
strictly open source ) and pcc ( http://pcc.ludd.ltu.se/ - open source ) to 
either compile  or produce working code. Seems like neither of them are ready
- at least not here on Mandriva Linux Cooker.

-------------------------------------------

So after a lot of frustration, my experiments with different compilers
were mostly successful. As a result, my code is more strict, and better
tested. So I guess it was worth it.

----------------

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://xrl.us/bjn8s

God gave us two eyes and ten fingers so we will type five times as much as we
read.



More information about the linux-elitists mailing list