gnustep / libobjc2

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

Support building on msys/clang64 #276

Closed qmfrederik closed 4 months ago

qmfrederik commented 5 months ago

For some reason, CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES was not set when compiling on MSYS, which would cause CMake to add -isystem C:/msys64/clang64/include when compiling arc.mm.

That, in turn, resulted in build warnings like this:

FAILED: CMakeFiles/objc.dir/arc.mm.o
C:\msys64\clang64\bin\c++.exe -DCXA_ALLOCATE_EXCEPTION_SPECIFIER=noexcept -DGNUSTEP -DNO_LEGACY -DTYPE_DEPENDENT_DISPATCH -D__OBJC_RUNTIME_INTERNAL__=1 -Dobjc_EXPORTS -isystem C:/msys64/clang64/include -x objective-c++ -std=gnu++17 -fPIC -Wno-deprecated-objc-isa-usage -Wno-objc-root-class -fobjc-runtime=gnustep-2.0 -MD -MT CMakeFiles/objc.dir/arc.mm.o -MF CMakeFiles\objc.dir\arc.mm.o.d -o CMakeFiles/objc.dir/arc.mm.o -c C:/msys64/home/fredcarl/git/libobjc2/arc.mm
In file included from C:/msys64/home/fredcarl/git/libobjc2/arc.mm:9:
In file included from C:/msys64/clang64/include/c++/v1/vector:304:
In file included from C:/msys64/clang64/include/c++/v1/__algorithm/copy.h:12:
In file included from C:/msys64/clang64/include/c++/v1/__algorithm/copy_move_common.h:12:
In file included from C:/msys64/clang64/include/c++/v1/__algorithm/iterator_operations.h:12:
In file included from C:/msys64/clang64/include/c++/v1/__algorithm/iter_swap.h:14:
In file included from C:/msys64/clang64/include/c++/v1/__utility/swap.h:16:
In file included from C:/msys64/clang64/include/c++/v1/__type_traits/is_nothrow_move_constructible.h:15:
In file included from C:/msys64/clang64/include/c++/v1/__type_traits/is_nothrow_constructible.h:17:
C:/msys64/clang64/include/c++/v1/cstddef:46:5: error: <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
   46 | #   error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
      |     ^
C:/msys64/clang64/include/c++/v1/cstddef:59:9: error: no member named 'nullptr_t' in the global namespace
   59 | using ::nullptr_t;
      |       ~~^

This PR:

qmfrederik commented 5 months ago

Hmm -- looks like there's a problem with exception interop when using libc++ instead of libstdc++ (see https://www.msys2.org/docs/environments/). The following tests fail:

The following tests FAILED:
     19 - ExceptionTest (Exit code 0xc0000409)
     31 - NestedExceptions (Exit code 0xc0000409)
     43 - RuntimeTest (Failed)
     63 - objc_msgSend (Exit code 0xc0000409)
     67 - NilException (Exit code 0xc0000409)
     81 - UnexpectedException (Exit code 0xc0000409)
     93 - CXXExceptions (Exit code 0xc0000409)
     97 - ObjCXXEHInterop (SEGFAULT)
     99 - ObjCXXEHInteropTwice (SEGFAULT)
    101 - ObjCXXEHInterop_arc (SEGFAULT)
qmfrederik commented 5 months ago

@davidchisnall ok - so it seems the __do_catch semantics differ between libc++ and stdc++, and using dereference_thrown_object_pointer consistently addresses this.

The only test which still fails on the msys2/clang environment (i.e. with libc++) is the unexpected exception handler. Looks like __cxa_current_exception_type() is returning NULL, any thoughts?

Does get us down to only one failing test, though:

The following tests FAILED:
     81 - UnexpectedException (Exit code 0xc0000409)