Re: libobjc2 on OpenBSD 6.8 build errors - C++ runtime not found

Riccardo Mottola <[email protected]> Wed, 17 Feb 2021 17:50:04 +0100
Newsgroups gmane.comp.lib.gnustep.devel
Message-ID <[email protected]>
Hi David,

sorry for the delay - I still want to get libobjc2 on OpenBSD and NetBSD 
working!
Back to OpenBSD

David Chisnall wrote:
> Hi,
>
> This looks as if we’re still compiling in the code that calls the function that figures out the the C++ ABI at run time dynamically.  This is added here:
>
> https://github.com/gnustep/libobjc2/blob/93fbf4d4bcf8b7bdb2dd2f11207a2e6eeba9c46c/CMakeLists.txt#L325
>
> I believe it should be pulled out into a separate if block, because we disable ObjC++ here:
>
> https://github.com/gnustep/libobjc2/blob/93fbf4d4bcf8b7bdb2dd2f11207a2e6eeba9c46c/CMakeLists.txt#L318
>
> Can you try moving it out and raise a PR if it fixes the build for you?  We shouldn’t break the no-C++ case, at least, though it should be working on OpenBSD.

do you mean removing all the trampoline block, line 325 and subsequent?

-               add_custom_command(OUTPUT eh_trampoline.s
-                       COMMAND ${CMAKE_CXX_COMPILER} ARGS 
${EH_PERSONALITY_FLAGS} -fPIC -S "${CMAKE_SOURCE_DIR}/eh_trampoline.cc" 
-o - -fexceptions -fno-inline | sed 
"s/__gxx_personality_v0/test_eh_personality/g" > 
"${CMAKE_BINARY_DIR}/eh_trampoline.s"
-                       MAIN_DEPENDENCY eh_trampoline.cc)
-               list(APPEND libobjc_ASM_SRCS eh_trampoline.s)


That's a little bit too much:

[ 12%] Linking C executable BoxedForeignException_optimised
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)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** 
[Test/CMakeFiles/BoxedForeignException_optimised.dir/build.make:108: 
Test/BoxedForeignException_optimised] Error 1

>
>>
>> (which, if memory serves me, was one of the tests failing on 6.7, but at leaste everything compiled)
>>
>> I am suspicious that I do not find the CXX_RUNTIME_LIB set by cmake.
>>
>> While runing cmake, I saw this:
>>
>> -- Testing C++ interop
>> -- Testing /usr/lib/libsupc++.a as the C++ runtime library
>> -- Testing /usr/lib/libc++abi.so.3.0 as the C++ runtime library
>> -- Testing C++ standard library
>> -- Using /usr/bin/cc
>> -- No useable C++ runtime found
>>
>>
>> why doesn't it like my runtime library?
> The file that it tries to compile is in the cmake directory, can you try compiling it and see what happens?  The line that tries to compile it is here:
>
> https://github.com/gnustep/libobjc2/blob/93fbf4d4bcf8b7bdb2dd2f11207a2e6eeba9c46c/CMakeLists.txt#L231
>
> I don’t know why this would fail with either libc++abi.so.3.0 or with your C++ standard library.  Either should work and so I don’t know why this test would fail.

I don't know, if I can give you the test results, is there a log, 
equivalent to configure's config.log ?

Line 231 is for Android...
I think it is test "test_cxx_stdlib" perhaps?

I tried:
rohan$ ./test_cxx_stdlib
rohan$ echo $?
1

it runs but returns non-zero.

Riccardo