[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] TCC on OS X

From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] TCC on OS X
Date: Wed, 15 Sep 2010 22:38:37 +0200
User-agent: KMail/1.13.5 (Linux/2.6.32-5-686; KDE/4.4.5; i686; ; )

Le mercredi 15 septembre 2010 21:24:57, Aaron Gough a écrit :
> Hey Thomas!
> Thanks for the patch! There were a couple of things that were still
> breaking the build once the patch was applied, but I was able to fix them.
> TCC now builds on OS X 10.5. Unfortunately the build segfaults (as does
> 'make test'). Building it with -O0 and running through GDB gives the
> following output:
What do you mean by "the build segfaults"? Do you mean that the resulting 
tinycc binary segfaults?
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: 13 at address: 0x00000000
> 0x8fe18c02 in __dyld_misaligned_stack_error ()
> Hopefully this is something trivial, but I can't proceed any further as
> I've really reached the limits of my very minimal experience with C.
> I have attached a patch for the changes that I used to get everything to
> this point. Everything was done against a checkout of release_0_9_25 that I
> got from the main repo.
Perfect. instead of patching bcheck.c try disabling bound check code. In tcc.h 
just add a #if 0 before line 97 and #endif after line 100 (in order to not 
> The biggest problem that I was unable to fix is that the malloc hooks in
> bcheck.c have to work quite differently on OS X. I started porting that
> section of code, but I was unable to get it to work. To get the build to
> complete I added another conditional that means 'install_malloc_hooks()'
> and 'restore_malloc_hooks()' do nothing on OS X. Hopefully you'll be able
> to correct these, I added some comments with links to the resources that I
> found regarding malloc hooks on OS X.
Thanks for the links, I'll read them later. Depending on the complexity on the 
differences I'd make a patch are let it to more experienced people. As to you 
patch, you can also just add the if defined(__APPLE__) statement at line 40 
(the line defining #undefining CONFIG_TCC_MALLOC_HOOKS and HAVE_MEMALIGN for 
linux and non glibc environment). It would disable malloc hooks everywhere in 
the file.

So first try this, then if it still segfaults try disabling bound check (as 
said earlier) and tell me if even without bound check it segfaults.
> The uname specs for my system (OS X 10.5) are:
> $ uname -m
> i386
> $ uname -s
> Darwin
> $ uname -a
> Darwin aaron-goughs-macbook.local 9.8.0 Darwin Kernel Version 9.8.0: Wed
> Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
Ok I found the way to distinguish macos X 10.6 from 10.5

It seems Darwin Kernel Version 9.x is Mac OS X 10.5 whereas Darwin Kernel 
Version 10.x is Mac OS X 10.6

So with the attached patch, tcc configure should set configure properly on mac 
OS X 10.6 to compile in 64 bits. Please try to apply the patch, configure and 
make without modifying config.mak and config.h. Of course you'll need to use 
patch from the previous mail and the modification I suggested for the malloc 
> OS X 10.6 is a slightly different story. From what I understand 10.5 is 32
> bit only. 10.6 is both 32 & 64 bit compatible. OS X uses a system called
> 'universal binaries' to allow both 32 and 64 bit versions of an executable
> to be stored in the same file, as well as versions built for the older PPC
> cpus.
> I'm really not able to offer any further information on how the config
> issue should be tackled for 10.6, though I was able to get a build working
> on 10.6 with the following settings:
That's all I needed. There is no Mac OS X 10.6 32 bits or 64 bits, there are 
all both.
> config.mak:
> CFLAGS=-O2 -m32
> ARCH=x86-64
> config.h:
> #define HOST_X86_64 1
> The only things I changed was forcing the architecture to x86-64 instead of
> i386 and forcing a 32bit build with -m32...
> Hope this helps somewhat! Please let me know if there's anything else I can
> do!
Thanks again for all the interaction with me and for being kind enough to do 
all the test I asked you. Hope the patch I give you and the modifications I 
suggested will be enough for tcc to work both on 10.5 and 10.6

Best regards,

Thomas Preud'homme
> -A
> ---
> Aaron Gough
> Web Developer
> +1-647-746-7083
> www.thingsaaronmade.com

Attachment: tcc_configure.diff
Description: Text Data

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]