Le mercredi 15 septembre 2010 21:24:57, Aaron Gough a écrit :
> Hey Thomas!What do you mean by "the build segfaults"? Do you mean that the resulting
> 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:
tinycc binary segfaults?
>Perfect. instead of patching bcheck.c try disabling bound check code. In tcc.h
> 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.
just add a #if 0 before line 97 and #endif after line 100 (in order to not
>Thanks for the links, I'll read them later. Depending on the complexity on the
> 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.
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 non
linux and non glibc environment). It would disable malloc hooks everywhere in
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.
>Ok I found the way to distinguish macos X 10.6 from 10.5
> The uname specs for my system (OS X 10.5) are:
> $ uname -m
> $ uname -s
> $ 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
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 the
patch from the previous mail and the modification I suggested for the malloc
>That's all I needed. There is no Mac OS X 10.6 32 bits or 64 bits, there are
> 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
> 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:
>Thanks again for all the interaction with me and for being kind enough to do
> CFLAGS=-O2 -m32
> #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
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