[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Crash occurs when catching std::exception in Objective-C++ code comp
From: |
Lobron, David |
Subject: |
Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2 |
Date: |
Mon, 20 Nov 2017 18:07:53 +0000 |
Hi David,
> I think the best option is probably to give up trying to avoid the libstdc++
> dependency and just build a single libobjc.so that links against libstdc++.so
> if lib{supc++,cxxrt,c++abi}.so is not available.
I added the following to CMakeLists.txt:
target_link_libraries(objc stdc++)
target_link_libraries(objc objcxx)
All unit tests now pass for me. However, my test program still crashes when I
try to catch a std::exception in ObjC++.
Looking at the tests more closely, it appears that the CXXExceptions tests are
compiled as pure ObjC and C++ (i.e., with .m and .cc suffixes, respectively).
I don't see a test with a .mm suffix, so I'm not sure if the tests really cover
the bug that's biting me.
I tried making a .mm version of CXXExceptions.cc. The test compiled, but I've
been having trouble linking it (I've copied my link error below- I'm linking
explicitly with libobjcxx.so and libobjc.o, but the linker isn't finding
objc_autorelease or throw_int).
Do you think I'm barking up the wrong tree here? Do the existing tests
actually cover the case of ObjC++, and I'm just not seeing it?
Thank you,
David
Linker error when trying to add a .mm version of CXXException to the tests:
(ALSI8)dlobron@bos-lps80:~/build/clangport/akamai/libobjc2/libobjc2-1.8.1/build/Test$
/home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang
-std=gnu99 -fexceptions -rdynamic
CMakeFiles/CXXException.dir/CXXException.mm.o -o CXXException
-Wl,-rpath,/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/build
../libobjc.so.4.6 -lstdc++ ../libobjcxx.so.4.6
-L/home/dlobron/build/clangport/akamai/common/lib -lobjcxx -lobjc
CMakeFiles/CXXException.dir/CXXException.mm.o: In function
`_i_Test__autorelease':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0x98):
undefined reference to `objc_autorelease(objc_object*)'
CMakeFiles/CXXException.dir/CXXException.mm.o: In function `_i_Test__retain':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0xc8):
undefined reference to `objc_retain(objc_object*)'
CMakeFiles/CXXException.dir/CXXException.mm.o: In function `_i_Test__release':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0xf8):
undefined reference to `objc_release(objc_object*)'
CMakeFiles/CXXException.dir/CXXException.mm.o: In function
`_c_NSAutoreleasePool__addObject_':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0x149):
undefined reference to `objc_autorelease(objc_object*)'
CMakeFiles/CXXException.dir/CXXException.mm.o: In function `finally()':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0x18d):
undefined reference to `throw_int()'
CMakeFiles/CXXException.dir/CXXException.mm.o: In function `main':
/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.mm:(.text+0x3a2):
undefined reference to `catchall()'
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, (continued)
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/16
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/16
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/16
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/16
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/17
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/17
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/17
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/17
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/18
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2,
Lobron, David <=
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/20
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/20
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/21
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/21
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/21
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/21
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, David Chisnall, 2017/11/22
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/22
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Wolfgang Lux, 2017/11/22
- Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2, Lobron, David, 2017/11/22