tags:

views:

52

answers:

1

Has anyone successfully compiled TCC on OS X?

From what I know it should be possible but when I run make I get the following error:

$ make
gcc -o tcc tcc.c -DTCC_TARGET_I386 -O2 -g -Wall -fno-strict-aliasing -mpreferred-stack-                boundary=2 -march=i386 -falign-functions=0 -Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0 -lm -ldl
tcc.c:1: error: CPU you selected does not support x86-64 instruction set
tcc.c:1: error: CPU you selected does not support x86-64 instruction set
tcc.c:1: error: -mpreferred-stack-boundary=2 is not between 4 and 12
make: *** [tcc] Error 1

./configure runs fine and gives the following output:

$ ./configure 
Binary  directory   /usr/local/bin
TinyCC directory    /usr/local/lib/tcc
Library directory   /usr/local/lib
Include directory   /usr/local/include
Manual directory    /usr/local/man
Doc directory       /usr/local/share/doc/tcc
Target root prefix  
Source path      /Users/aaron/Downloads/tcc-0.9.25
C compiler       gcc
CPU              x86
Big Endian       no
gprof enabled    no
cross compilers  no
use libgcc       no
Creating config.mak and config.h

I'm pretty sure the issue is something simple, but I haven't compiled enough programs on OS X to be aware of the pratfalls...

The primary purpose for installing TCC was to get libtcc so I could start experimenting with dynamic code generation from Ruby (in case that makes a difference :-p)

Thanks!

+1  A: 

I'll consolidate by comments now.

There seem to be several issues.

  1. There has been a change in the naming scheme for the x86 register access as of Mac OS 10.5. See Access EIP and EBP via ucontext on OS X. This will require hacking the source until the maintainer can be convinced to support Mac OS X.
  2. The executable formats supported by tcc do not overlap with those that Mac OS X will run natively. However, XBinary may address this. (I didn't find either a fink package or a MacPorts package, however and don't have it installed yet. Not sure that I will---this is deep magic, and could in theory do very bad things indeed.) Ah...this was already on SO too: Possiblity of loading/executing ELF files on OSX.
dmckee
Thanks for your answer! I was able to add the alternate code for register access under OS X and get TCC to compile. However the second issue you pointed out is a show-stopper... I going to leave it alone as there would be a lot of work to do to extend TCC for MACH-0 binaries.Thanks for your help!
Aaron Gough