0

There are two link errors in this project.

The first, pointed out by @Steve, is the lack of void *__gxx_personality_v0;

If anyone can explain why a C++ project compiled with clang++3.5 under cygwin would create a reference to this, I would like to understand. Anyway, I defined the symbol as a workaround.

The other problem appears to be references to 32-bit relative addressing in 64-bit. I am looking for a way to tell clang++ to compile 32 bit or 64 bit. I will try on native linux as well, but again, if anyone can explain why this is happening, I would like to understand.

I am thinking it might be a static variable, located down low in the address space, being accessed by something on the stack, but again, clang is generating everything so as far as I can see, this is a bug in the compiler.

clang++ -std=c++11 -O2 -g -I include/ -pthread -c RequestHandler.cc
clang++ -std=c++11 -O2 -g Config.o Logger.o RequestHandler.o FileSys.\
o Buffer.o server.o CspServlet.o -pthread -o server
RequestHandler.o:fake:(.debug_info+0x54bd): relocation truncated to f\
it: R_X86_64_32 against `.debug_ranges'
...
FileSys.o:fake:(.eh_frame$_ZNSt10_HashtableISsSt4pairIKSsP2FLESaIS4_E\
NSt8__detail10_Select1stESt8equal_toISsESt4hashISsENS6_18_Mod_range_h\
ashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_H\
ashtable_traitsILb1ELb0ELb1EEEE21_M_insert_unique_nodeEmmPNS6_10_Hash\
_nodeIS4_Lb1EEE+0x13): undefined reference to `__gxx_personality_v0'
FileSys.o:fake:(.eh_frame$_ZNSt8__detail16_Hashtable_allocISaINS_10_H\
ash_nodeISt4pairIKSsP2FLELb1EEEEE16_M_allocate_nodeIJRKS6_EEEPS7_DpOT\
_+0x13): more undefined references to `__gxx_personality_v0' follow
collect2: error: ld returned 1 exit status
Dov
  • 8,000
  • 8
  • 46
  • 75
  • This question has a possible workaround: http://stackoverflow.com/questions/329059/what-is-gxx-personality-v0-for, at least for the `undefined references to __gxx_personality_v0` part, which is defining `void *__gxx_personality_v0;` somewhere – Steve Mar 30 '15 at 14:33
  • Ok, I added the __gxx_personality_v0 definition, but given that I am compiling and linking with clang, I don't understand the reason. It should be linking with libc++. – Dov Mar 30 '15 at 14:39
  • Good point, I'm not sure. I just did a Google search for the error. Perhaps something else in your project has some dependency on GCC that you're not aware of. – Steve Mar 30 '15 at 14:41
  • I didn't want to put in the entire code, or the entire make, but this is a standalone linux project. It users -pthread, but that's it – Dov Mar 30 '15 at 14:43
  • 1
    are you sure that *all* objects have been compiled with `clang++`? – umläute Mar 30 '15 at 15:10
  • 1
    `_ZNSt8__detail16_Hashtable_allocISaINS_10_Hash_nodeISt4pairIKSsP2FLELb1EEEEE16_M_allocate_nodeIJRKS6_EEEPS7_DpOT_` is a libstdc++ symbol, not libc++, so you should re-check your assumptions about which library you're using – Jonathan Wakely Mar 30 '15 at 15:12
  • Defining `__gxx_personality_v0` yourself is a really bad idea. – Jonathan Wakely Mar 30 '15 at 15:14
  • 1
    @JonathanWakely clang++ uses libstdc++ under cygwin by default (libc++ may or may not exist for that platform). – n. m. could be an AI Mar 30 '15 at 15:21
  • Try compiling with -fPIC (no promise it will work). – n. m. could be an AI Mar 30 '15 at 15:32
  • @n.m. tell the OP, I'm not the one saying "It should be linking with libc++" :-) – Jonathan Wakely Mar 31 '15 at 09:57

1 Answers1

1

Ok, it turns out that on cygwin, when I installed clang, it doesn't fully use the clang toolchain. clang is compiling, but g++ is linking (I think). Bear in mind all these tools could be aliased to something else, but it's very suspicious.

I built on Unix and it worked. Same makefile. So the problem is that when I wrote clang, it wasn't using clang to link. And that is weird.

Dov
  • 8,000
  • 8
  • 46
  • 75