gnustep / libobjc2

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

Clang++ provides its own exception types on Linux. #68

Closed nsailor closed 6 years ago

nsailor commented 6 years ago

Without disabling the existing definitions, clang will refuse to build libobjc2 on Ubuntu Linux 18.04. With this patch, the library compiles without problems.

davidchisnall commented 6 years ago

These changes don't build and it's not clear what they're actually trying to do.

nsailor commented 6 years ago

Note that I am using Clang 6, while Travis has Clang 5. Without the changes, one gets the following error:

[  0%] Building CXX object CMakeFiles/objc.dir/objcxx_eh.cc.o
In file included from /home/nsailor/Projects/GNUstep/libobjc2/objcxx_eh.cc:5:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/exception:142:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/exception_ptr.h:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/cxxabi_init_exception.h:63:7: error: exception specification in declaration does not match
      previous declaration
      __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW;
      ^
/home/nsailor/Projects/GNUstep/libobjc2/objcxx_eh.h:10:7: note: previous declaration is here
void *__cxa_allocate_exception(size_t thrown_size);
      ^
/home/nsailor/Projects/GNUstep/libobjc2/objcxx_eh.cc:26:8: error: redefinition of 'type_info'
        class type_info
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/typeinfo:88:9: note: previous definition is here
  class type_info
davidchisnall commented 6 years ago

A fix that breaks existing systems won't be committed. A fix that does not explain the problem that it's trying to solve will not be committed.

I believe that this is related to namespace pollution in recent versions of the libstdc++ headers, which include Itanium C++ ABI functions when including C++ standard library headers.

nsailor commented 6 years ago

Understood, the problem still remains though, libobjc2 does not build on the default Ubuntu 18.04 installation. I'll see what I can do.

davidchisnall commented 6 years ago

Okay, so it appears that you are seeing the same issue as #66. Does #67 fix it? If so, then we'll merg that. If not, then please see the discussion in #66 for the correct fix: we need to add a check that tests whether we need to add a nothrow qualifier on the function. We also want to name the check correctly. The standard does not put a nothrow qualifier on this definition, so it is a work around for a platform toolchain not providing definitions that are compatible with the standard ones.

nsailor commented 6 years ago

Yeah, sorry I missed the issue. Working on a platform test right now.

nsailor commented 6 years ago

Unfortunately #67 does not fix the problem, at least on my system. Adding -stdlib=libc++, gives exception: File not found for #include <exception>.