Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on msys/clang64 #276

Merged
merged 4 commits into from
Feb 12, 2024
Merged

Conversation

qmfrederik
Copy link
Collaborator

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:

  • Sets CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES to match CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES to avoid cmake injecting the -isystem argument
  • Sets CMAKE_LINK_LIBRARY_SUFFIX and CMAKE_SHARED_LIBRARY_PREFIX, to avoid trying to add linking with c++ via -lc++.lib (the link library name on msys is libc++.dll.a)
  • Sets CMAKE_IMPORT_LIBRARY_SUFFIX to generate libobjc.dll.a (in line with the msys naming convention)
  • Sets CMAKE_INSTALL_BINDIR if not set

@qmfrederik
Copy link
Collaborator Author

qmfrederik commented Feb 6, 2024

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
Copy link
Collaborator Author

qmfrederik commented Feb 7, 2024

@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)

@qmfrederik qmfrederik marked this pull request as ready for review February 7, 2024 13:50
@qmfrederik qmfrederik merged commit 1ff5e12 into gnustep:master Feb 12, 2024
53 checks passed
@qmfrederik qmfrederik deleted the msys/clang64 branch February 12, 2024 10:20
qmfrederik added a commit to qmfrederik/MINGW-packages that referenced this pull request Feb 12, 2024
Upstream libobjc2 now has clang64 support (via
gnustep/libobjc2#276).

Cherry-pick that commit and add clang64 to the build matrix for
libobjc2.  This cherry-picked commit also fixes the ".dll.a" suffix for
library objects.
qmfrederik added a commit to qmfrederik/MINGW-packages that referenced this pull request Feb 12, 2024
Upstream libobjc2 now has clang64 support (via
gnustep/libobjc2#276).

Cherry-pick that commit and add clang64 to the build matrix for
libobjc2.  This cherry-picked commit also fixes the ".dll.a" suffix for
library objects.
qmfrederik added a commit to qmfrederik/MINGW-packages that referenced this pull request Feb 13, 2024
Upstream libobjc2 now has clang64 support (via
gnustep/libobjc2#276).

Cherry-pick that commit and add clang64 to the build matrix for
libobjc2.  This cherry-picked commit also fixes the ".dll.a" suffix for
library objects.
qmfrederik added a commit that referenced this pull request Mar 21, 2024
* Support building on msys/clang64
* Support libc++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants