I just committed Anton's patch for PR973. This should greatly improve static ctor/dtor handling on linux.
-Chris Index: crtstuff.c =================================================================== --- crtstuff.c (revision 119298) +++ crtstuff.c (working copy) @@ -51,9 +51,6 @@ This file must be compiled with gcc. */ -/* APPLE LOCAL begin LLVM */ -#ifndef __llvm__ /* FIXME: add inline asm support */ - /* It is incorrect to include config.h here, because this file is being compiled for the target, and hence definitions concerning only the host do not apply. */ @@ -69,6 +66,13 @@ #include "tm.h" #include "unwind-dw2-fde.h" +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ + /* FIXME: Remove when external weak linkage will be alive. */ + #undef JCR_SECTION_NAME +#endif +/* APPLE LOCAL end LLVM */ + #ifndef FORCE_CODE_SECTION_ALIGN # define FORCE_CODE_SECTION_ALIGN #endif @@ -177,11 +181,25 @@ static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { }; asm (CTORS_SECTION_ASM_OP); STATIC func_ptr __CTOR_LIST__[1] +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__ ((__used__, aligned(sizeof(func_ptr)))) +#else __attribute__ ((__unused__, aligned(sizeof(func_ptr)))) +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) (-1) }; #else STATIC func_ptr __CTOR_LIST__[1] - __attribute__ ((__unused__, section(".ctors"), aligned(sizeof (func_ptr)))) +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__ ((__used__, section(".ctors"), aligned(sizeof (func_ptr)))) +#else + __attribute__ ((__unused__, section(".ctors"), aligned(sizeof (func_ptr)))) +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) (-1) }; #endif /* __CTOR_LIST__ alternatives */ @@ -449,11 +467,25 @@ #elif defined(DTORS_SECTION_ASM_OP) asm (DTORS_SECTION_ASM_OP); STATIC func_ptr __DTOR_END__[1] +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ +__attribute__ ((__used__, aligned(sizeof(func_ptr)))) +#else __attribute__ ((unused, aligned(sizeof(func_ptr)))) +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) 0 }; #else STATIC func_ptr __DTOR_END__[1] - __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr)))) +/* APPLE LOCAL begin LLVM */ +#ifdef __llvm__ +/* FIXME: Remove when external weak linkage will be alive. */ + __attribute__((__used__, section(".dtors"), aligned(sizeof (func_ptr)))) +#else + __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr)))) +#endif +/* APPLE LOCAL end LLVM */ = { (func_ptr) 0 }; #endif @@ -558,5 +590,3 @@ #error "One of CRT_BEGIN or CRT_END must be defined." #endif -#endif -/* APPLE LOCAL end LLVM */ _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits