libobjc2
libobjc2 copied to clipboard
OpenBSD build fails - undefined symbols - Unwind
a standard OpenBSD build with system clang and configured OOB,
[ 13%] Linking C executable ExceptionTest
ld: error: undefined symbol: _Unwind_Resume
>>> referenced by ExceptionTest.m
>>> CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o:(finally)
>>> referenced by ExceptionTest.m
>>> CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o:(rethrow_id)
>>> referenced by ExceptionTest.m
>>> CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o:(rethrow_test)
>>> referenced by ExceptionTest.m
>>> CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o:(rethrow_catchall)
>>> referenced by ExceptionTest.m
>>> CMakeFiles/ExceptionTest.dir/ExceptionTest.m.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error 1 in . (Test/CMakeFiles/ExceptionTest.dir/build.make:107 'Test/ExceptionTest')
*** Error 2 in . (CMakeFiles/Makefile2:5324 'Test/CMakeFiles/ExceptionTest.dir/all')
Hi,
You're either running -stable or an old -current version, i'm right?
These issues have been fixed in -current by adding libexecinfo into base (https://github.com/openbsd/src/commit/771fbea0148a7fe458cf2c657edb98b32659f150). I can build the current HEAD (646c142f3c459e47aea6cb7b10cca5905750e0d7) without issues on OpenBSD/amd64.
If you're still wanting to not use -current, by experience (https://github.com/openbsd/ports/commit/025717b78e04dc6d3754adb7160cde803687274f), you may want to drop -fexceptions
, but i'm not sure it would solve the issue.
I'm running release, which a normal user is supposed to do: in this case 6.9
Sorry, I didn't see this when it was reported. This symbol is part of the generic unwinder. This is normally provided by libgcc_s and should be added to the link step by the compiler automatically. It might be in a separate libUnwind on OpenBSD, so you can try adding -lunwind
or -lUnwind
to the CMake EXE linker flags and see if that fixes it.
Is the same undefined symbol in libobjc.so or only in the tests? If it's in only the tests, you should be able to just build without tests.
Dropping -fexceptions
will give you compile failures instead of link failures (you can't throw and catch exceptions without it).
I just upgraded to OpenBSD 7.0 - and I still have that issue, so I am unsure @julianaito spotted commit was the fix?
ld: error: unable to find library -lUnwind
Tells us -lUnwind is not present and -lunwind gives me the same error
ld: error: unable to find library -lunwind
Now on 7.0 the full error actually is:
ld: error: undefined symbol: _Unwind_RaiseException
>>> referenced by BoxedForeignException.m
>>> CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o:(throw)
>>> referenced by BoxedForeignException.m
>>> CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o:(finally)
ld: error: undefined symbol: _Unwind_Resume
>>> referenced by BoxedForeignException.m
>>> CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o:(finally)
>>> referenced by BoxedForeignException.m
>>> CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o:(main)
ld: error: undefined symbol: _Unwind_Resume_or_Rethrow
>>> referenced by BoxedForeignException.m
>>> CMakeFiles/BoxedForeignException_optimised.dir/BoxedForeignException.m.o:(_i_BoxedException__rethrow)
I am having this same issue with OpenBSD 7.1. I tried to build libunwind from source but it requires getcontext
and OpenBSD does not provide getcontext
from POSIX (see here).
Some folks have created a libucontext implementation but, I am trying to compile on ppc which these implementations do not support without having getcontext already available. I may be stuck.
Can you see what OpenBSD's C++ runtime (libcxxrt, libsupc++, or libc++abi) links to? It might be statically linked into the C++ standard library (libc++ or libstdc++).
Some folks have created a libucontext implementation but, I am trying to compile on ppc which these implementations do not support without having getcontext already available. I may be stuck.
Even if you manage to build libobjc2 with OpenBSD getcontext
patches, there is currently no PowerPC (32bit big-endian, 64bit big/little-endian) support for libobjc2. The required msgSend trampoline assembly is missing.
It should still work with the C fallback (clang won't generate objc_msgSend
calls on PowerPC, it will generate calls to the slower C paths).
Can you see what OpenBSD's C++ runtime (libcxxrt, libsupc++, or libc++abi) links to?
I'd be happy to, but I must admit, I'm pretty novice to C on unix/linux world so I'm not exactly sure how to figure this out.
Just updated to OpenBSD 7.2 - still fails
[ 21%] Linking C executable BlockImpTest
ld: error: undefined symbol: _Unwind_Resume
>>> referenced by BlockImpTest.m
>>> CMakeFiles/BlockImpTest.dir/BlockImpTest.m.o:(main)
Checking libc++abi.so.6.0
ldd doesn't say much:
libc++abi.so.6.0:
Start End Type Open Ref GrpRef Name
0d0dd000 2d0e1000 dlib 1 0 0 /usr/lib/libc++abi.so.6.0
however, I find this symbol using nm:
00015a00 W unw_resume
Could it be related to _Unwind_Resume ?
unw_resume
is an internal symbol used by the unwinder. I believe that it's only present in the nongnu / GCC implementation of libunwind, not the LLVM one. I'm not sure what OpenBSD's stack looks like here. We aren't using that symbol directly but you might see an error like that if you statically link against the GCC unwinder and then dynamically link against the LLVM one? _Unwind_Resume
is one of the symbols defined by the language-agnostic portion of the ABI, so should be present everywhere.
On OpenBSD 7.5 / i386:
[ 16%] Built target AssociatedObject2_legacy_optimised
ld: error: undefined symbol: _Unwind_Resume
>>> referenced by BlockImpTest.m
>>> CMakeFiles/BlockImpTest.dir/BlockImpTest.m.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
[ 17%] Building OBJC object Test/CMakeFiles/BlockImpTest_optimised.dir/BlockImpTest.m.o
this happens if TESTS are enabled
If I build without TESTS, I can build & install, but later building of gnustep base will fail:
ld: error: undefined symbol: _Unwind_Resume
>>> referenced by cvtenc.m:0
>>> ./obj/cvtenc.obj/cvtenc.m.o:(gnustep_base_user_main)