gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
434 stars 118 forks source link

Compile error with clang on armbian aarch64 #193

Closed iamleeg closed 3 years ago

iamleeg commented 3 years ago

Environment

clang 3.8.1, cmake 3.15.4, on Armbian (Debian 9.13)

Steps to reproduce

export CC=clang
export CXX=clang++
cmake ..
make -j4

Error message

[  7%] Building CXX object CMakeFiles/objc.dir/objcxx_eh.cc.o
/home/leeg/Projects/libobjc2/objcxx_eh.cc:19:18: error: exception specification
      in declaration does not match previous declaration
extern "C" void *__cxa_allocate_exception(size_t) noexcept;
                 ^
/home/leeg/Projects/libobjc2/objcxx_eh.h:18:7: note: previous declaration is
      here
void *__cxa_allocate_exception(size_t thrown_size) CXA_ALLOCATE_EXCEPTIO...
      ^
1 error generated.

What I tried

Installing llvm libc++, and using ccmake to -DCXX_RUNTIME_LIB=/usr/lib/aarch64-linux-gnu/libc++.so yielded this error:

 CMake Error at CMakeLists.txt:321 (separate_arguments):
   separate_arguments given unknown argument NATIVE_COMMAND

So I then just tried passing that constructed argument to cmake. That worked, but I get the same error.

Notes

In fairness the comment right above this line says that clang would throw a type mismatch error, I would switch to gcc except the cmake configure phase strongly advises against that:

WARNING: It is strongly recommended that you compile with clang

davidchisnall commented 3 years ago

Thanks for the report.

I'm not sure why I added that line, but can you try deleting line 19 of objcxxeh.cc? It appears to be duplicating a declaration from the header, incorrectly. If that works, please raise a PR that does it.

Note: clang 3.8.1 is ancient (2016). I doubt that it will work, it definitely won't support the v2 ABI. I'd strongly recommend that you use clang 9 (2019) or later.

iamleeg commented 3 years ago

Thanks for your help @davidchisnall, I confirm that fixes the immediate issue and clang 3.8.1 fails because it doesn't understand class properties. I'm using that version because it's "whatever's in Debian", but I'll make the PR then upgrade the compiler and move on.