Re: [Gc] Don't use __builtin_unwind_init() with clang

Ivan Maidanski ivmai at mail.ru
Tue Apr 17 05:08:19 PDT 2012


Hi Niklas,

I've applied your patch to master. (I'll put it to release branch in several days.)

Regards.

Tue, 17 Apr 2012 09:00:30 +0200 Niklas Therning <niklas at therning.org>:
> Hi,
> 
> I've had some problems with GC allocated memory being collected even 
> though it is referenced by a CPU register. I'm using clang on mac os x:
> 
> $ clang -v
> Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
> Target: x86_64-apple-darwin11.2.0
> Thread model: posix
> 
> This is the clang that comes with XCode 4.2.1.
> 
> I've seen this problem when targeting both x86_64 and arm (iOS). It 
> turns out that the __builtin_unwind_init() function on this clang 
> version is a noop. It does nothing. I've disassembled the mach_dep.o 
> generated by clang for both x86_64 and arm with and without the call to 
> __builtin_unwind_init(). The assembly is identical.
> 
> Here's a patch that fixes this problem for me. It prevents 
> HAVE_BUILTIN_UNWIND_INIT to be set if the compiler is clang:
> 
> diff -rupN bdwgc-20120327.orig/include/private/gcconfig.h 
> bdwgc-20120327/include/private/gcconfig.h
> --- bdwgc-20120327.orig/include/private/gcconfig.h      2012-03-27 
> 16:11:13.000000000 +0200
> +++ bdwgc-20120327/include/private/gcconfig.h   2012-04-16 
> 13:59:27.000000000 +0200
> @@ -700,7 +700,8 @@
>   /* __builtin_unwind_init() to push the relevant registers onto the 
> stack. */
>   # if defined(__GNUC__) && ((__GNUC__ >= 3) \
>                              || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
> - && !defined(__INTEL_COMPILER) && !defined(__PATHCC__)
> + && !defined(__INTEL_COMPILER) && !defined(__PATHCC__) \
> + && !defined(__clang__)
>   #   define HAVE_BUILTIN_UNWIND_INIT
>   # endif
> 



More information about the Gc mailing list