iPhone static library Clang/LLVM error: non_lazy_symbol_pointers
        Posted  
        
            by 
                Bekenn
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Bekenn
        
        
        
        Published on 2012-03-15T03:26:01Z
        Indexed on 
            2012/03/23
            23:29 UTC
        
        
        Read the original article
        Hit count: 400
        
After several hours of experimentation, I've managed to reduce the problem to the following example (C++):
extern "C" void foo();
struct test
{
    ~test() { }
};
void doTest()
{
    test t; // 1
    foo();  // 2
}
This is being compiled for iOS devices in XCode 4.2, using the provided Clang compiler (Apple LLVM compiler 3.0) and the iOS 5.0 SDK.  The project is configured as a Cocoa Touch Static Library, and "Enable Linking With Shared Libraries" is set to No because I'm building an AIR native extension.  The function foo is defined in another external library.  (In my actual project, this would be any of the C API functions defined by Adobe for use in AIR native extensions.)
When attempting to compile this code, I get back the error:
FATAL:incompatible feature used: section type non_lazy_symbol_pointers (must specify "-dynamic" to be used)
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
The error goes away if I comment out either of the lines marked 1 or 2 above, or if I change the build setting "Enable Linking With Shared Libraries" to Yes.  (However, if I change the build setting, then I get multiple ld warning: unexpected srelocation type 9 warnings when linking the library into the final project, and the application crashes when running on the device.)  The build error also goes away if I remove the destructor from test.
So: Is this a bug in Clang? Am I missing some all-important and undocumented build setting? The interaction between an externally-provided function and a struct with a destructor is very peculiar, to say the least.
© Stack Overflow or respective owner