Closed iamleeg closed 5 years ago
This is odd. I would expect it to show up as U
in both cases, because it's an extern
symbol. I believe that the bug is caused by a missing extern "C"
in this file.
Thanks @davidchisnall, I've patched that change into slot.h locally and it doesn't change the result :(
I think there's something weird in your config then. I can compile the C and C++ versions of the file and link them together (after renaming the main
function in one to avoid that conflict). Please can you submit a complete test case that fails for you?
But you helped me track down the problem :). In the FreeBSD package, slot.h
doesn't have the extern
modifier (or the OBJC_PUBLIC
modifier). I was wrong in thinking it was using the upstream sources.
Sorry, the FreeBSD port is based on 0db500a which does indeed exhibit this bug.
Environment: tested on freebsd 12 with libobjc2 2.0 (from
pkg
, which looks identical to the released source). I used both clang 6.0 and 8.0 (again from FreeBSD packages), and got the same behavior.Here's my file:
If I compile this as an ObjC file:
But if I compile it as an ObjC++ file:
It looks like in ObjC++,
objc_method_cache_version
is zero-initialized and gets written as a public symbol in BSS. But that means that I can't link two files that both includedobjc/objc.h
and were both compiled as ObjC++ into the same executable:I would like to be able to do that.