115 Commits (2855d1771478e1e368fcfeb4d56aecbb4d9429ca)

Author SHA1 Message Date
Niels Grewe 2855d17714 feat(blocks runtime): Enable using libBlocksRuntime instead of the embedded runtime 2 years ago
Hugo Melder dc031d2741
Windows on ARM64: Support Visual Studio ABI sret mechanism for non-trivial data types (#289)
* Add objc_msgSend_stret2

* Guard and Export objc_msgSend_stret2

* Remove architecture hackery in CMake

* Add objc_msgSend test for WoA64

* Add doc comment for objc_msgSend_stret2
2 years ago
Frederik Carlier 51b9a076f0 Generate CMake Configuration File
Installs:
- lib/cmake/libobjc/libobjcConfig.cmake
- lib/cmake/libobjc/libobjcTargets.cmake
- lib/cmake/libobjc/libobjcConfigVersion.cmake
- lib/cmake/libobjc/libobjcTargets-noconfig.cmake
2 years ago
Frederik Carlier 4a0c2f1afe Don't use CXXFLAGS when compiling eh_trampoline.cc
We don't want the user to override these flags because that file
needs to be compiled in a very specific way.

Re-applies #178 (365e53632e)
Related to #183
Fixes #177
2 years ago
Frederik Carlier 6bd3db5866
MinGW: Use _Unwind_RaiseException to throw exceptions (#278)
The current implementation uses Vectored Exception Handlers. This implementation is too greedy, and invokes _objc_unexpected_exception for (certain) exceptions which would be handled by the application itself.
2 years ago
Frederik Carlier f983cdbf68
MinGW: Remove manual setting of library prefix/suffix (#277)
We no longer need to manually set these suffixes/prefixes as CMake in MSYS2 now knows about Objective C.

See msys2/MINGW-packages#20028
See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9244
See msys2/MINGW-packages#20024 (comment)
2 years ago
Hugo Melder e882423e5a
PowerPC {32, 64}-bit Block Trampolines (#272)
* Implement PowerPC block trampoline

* Adjust pagesize on ppc64

* Skip UnexpectedException test for PowerPC

* Move PAGE_SIZE to asmconstants.h

* Use PAGE_SIZE and PAGE_SHIFT macros for PowerPC

* Add ppc64el and powerpc qemu-crossbuild targets

* Add NO_SAFE_CACHING definition and guards

* Do not export objc_method_cache_version on ppc32

---------

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
2 years ago
Frederik Carlier 1ff5e1298d
Support building on msys/clang64 (#276)
* Support building on msys/clang64
* Support libc++
2 years ago
Frederik Carlier 639c676bb8
Install runtime files in CMAKE_INSTALL_BINDIR when GNUstep is not installed (#275) 2 years ago
Sergii Stoian 7f44d19e6b CMakeLists.txt: fixed mistyped name `tsl-robin-map_FOUND` variable.
This change let package maintainers use `tsl-robin-map_DIR` cmake parameter
with path set to cloned and built robin-map repo.
2 years ago
David Chisnall 377a81d237 Add support for fast-path alloc / init methods and direct methods.
The fast paths follow the pattern that we established for fast ARC:
Framework base classes can opt in by implementing a `+_TrivialAllocInit`
method.

This opt-in behaviour is inherited and is removed implicitly in any
subclass that implements alloc or init methods (alloc and init are
treated independently).

Compilers can emit calls to `objc_alloc(cls)` instead of `[cls alloc]`,
`objc_allocWithZone(cls)` instead of `[cls allocWithZone: NULL]`, and
`objc_alloc_init` instead of `[[cls alloc] init]`.

Direct methods don't require very much support in the runtime.  Apple
reuses their fast path for `-self` (which is supported only in the Apple
fork of clang, not the upstream version) for a fast init.  Given that
the first few fields of the runtime's class structure have been stable
for around 30 years, I'm happy moving the flags word (and the
initialised bit, in particular) into the public ABI.  This lets us do a
fast-path check for whether a class is initialised in class methods and
call `objc_send_initialize` if it isn't.  This function is now exposed
as part of the public ABI, it was there already and does the relevant
checks without invoking any of the message-sending machinery.

Fixes #165 #169
2 years ago
Frederik Carlier 65280908eb
Use C++ exceptions unconditionally for Objective-C[++] on MinGW (#267) 2 years ago
Frederik Carlier 0771ddf3e5 Don't -fobjc-runtime=gnustep-2.0 as a global flag
The legacy tests will override this flag.
2 years ago
Frederik Carlier a61309b0d3 Support compiling on mingw (no exception handling) 2 years ago
Frederik Carlier 32c09c0029
Prefer system-provided robin-map (#248)
* Prefer system-provided robin-map

* Use find_package

* Use submodule

* PR feedback

* Include FetchContent
2 years ago
Hugo Melder ab23f14fd7
Initial Windows on ARM (AArch64) Support (#249)
* Conditionally include ntdll.dll

* Use text relocation instead of GOT

* Use FlushInstructionCache instead of clear_cache for arm64

* Load address in two stages (adrp, add)

* objc_msgSend.aarch64.S add comments

* Add seh directives

* Move .seh_proc into slow sloop section

* Comment out cfi directives

* Substitute raw .seh directives with macros

* Add documentation of SEH annotations

* Detect CPU Architecture with preprocessor

* Cleanup CMakeLists.txt

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>

* Remove line in objc_msgSend.aarch64.S

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>

* Change Test CMakeList to use ARCHITECTURE var

* Use existing clear cache macro

* Change _WIN64 to _WIN32 and reorder labels

* Remove macro and replace _WIN64 with _WIN32

* Remove argument from non-win32 macro

---------

Co-authored-by: David Chisnall <davidchisnall@users.noreply.github.com>
2 years ago
Frederik Seiffert 3b6b960810 Add objc_setUncaughtExceptionHandler() API 2 years ago
David Chisnall e23882fb23 Rewrite the selector table in C++.
This replaces a few home-grown datastructures with third-party ones that
get a lot more testing:

 - The home-grown hopscotch hash table is moved to using robin map.  The
   original was designed to be lock free, but we've been using it behind
   a lock for ages.
 - The selector list is now a std::vector.
 - The types list now use std::forward_list.

This also removes a couple of code paths that haven't been used since we
started using the new ABI data structures internally and upgrading at
load time.

The new code tries to differentiate in the static type system between
registered and unregistered selectors.  The check for whether a selector
is registered is fragile and depends on no selector being mapped or
allocated in memory below the total number of selectors.  This check can
now disappear on most code paths.

On a single test machine (not guaranteed to be representative) the test
suite now completes around 20% faster.
3 years ago
David Chisnall 7c23a07bb4 Various CMake cleanups and modernisations.
This adds a dependency on a version of CMake with support for Objective-C,
removing a number of hacks to make CMake work and introduces a few
modernisations:

 - Options use CMake's `option` mechanism.
 - A lot of things now use generator expressions, which should improve the
   things like the multi-config Ninja generator.
 - We no longer depend on hacks to build in CI.

At the same time, a few other things are simplified:

 - There is no longer support for building without C++ support and we depend on
   a C++ standard library, not just a runtime. This makes it possible to use
   more C++ features inside the runtime.
 - We no longer support clang-cl on Windows and instead require clang.exe.
 - Support for the Boehm GC has been removed.
3 years ago
Frederik Seiffert 35ac9bc072 Don't pass ANDROID_ARM_NEON testing C++ runtime
Fixes building for Android arm64-v8a with NDK r25, which no longer supports this flag. Since we were passing this unconditionally we were previously inadvertently disabling NEON support if the flag wasn't set.
3 years ago
Bernard Cafarelli 2deec335f6 Add pthreads to link libraries, not link flags
This fixes linking errors with --as-needed like:
ld: libobjc.so.4.6: undefined reference to `pthread_mutexattr_destroy'

Fixes #180
5 years ago
Niels Grewe 014f386f58 Add support for libc++abi.
Extends C++ interop with autodetected support for libc++abi in addition to the existing support for libcxxrt and libsubc++.

Fixes #142.
5 years ago
Frederik Seiffert ac9a837e69 Fix eh_trampoline.s generation when cross compiling. 5 years ago
David Chisnall 7914c5707a Fix cross building.
When we stopped using CXXFLAGS in eh_personality.s generation, we lost
the ability to propagate -m32 or -target through, so cross-compile
didn't work.  These flags are now passed through correctly, so (so
'-pipe -O2' will appear as two arguments, rather than being combined as
a single value that then causes clang to abort with an unknown argument
error, which was the original motivation for this change).

This is the correct fix for #177
5 years ago
David Chisnall 365e53632e Don't use CXXFLAGS when compiling eh_trampoline.cc
The way that we were doing this didn't handle multiple flags and we
actually don't want the user to override these flags because that file
needs to be compiled in a very specific way.

Fixes #177
5 years ago
David Chisnall 00ca954ae6 Check that the submodule exits.
Print an informative message if someone forgets to fetch the
submodule.
5 years ago
David Chisnall a575db7392 Fix C++ runtime detection.
- Don't try to detect libc++abi.  It doesn't actually work, so don't
   try it.
 - Correctly try to link the standard library.

This should fix the build on GNU/Linux systems with libc++abi.so
installed (including our Ubuntu CI!).
5 years ago
Frederik Seiffert cca84b183c Fix building without ObjC++ support. 6 years ago
David Chisnall b39a42252e Hide ARC warnings behind an off-by-default flag. 6 years ago
David Chisnall 65d6b279a0 Rework C++ exception interop again.
We now, the first time we encounter a foreign exception, throw a C++
exception through a frame that has a custom personality function and
probe the layout of the __cxa_exception structure.
We then use the offsets learned from this along with the public ABI
functions for allocating the structure.

At the same time, add a test that we are correctly setting the count of
uncaught exceptions.

Fixes #146
6 years ago
David Chisnall 76e081dc48 Initial run-time detection of C++ EH ABI variant.
On Itanium C++ ABI platforms, there are a lot of different variations
that have subtly different structure layouts.  This commit adds a
run-time test that throws a C++ exception through a function that has
its personality function replaced with a wrapper so that we can inspect
a C++ exception in controlled conditions.

Initially, this just detects the exception type value used for C++
exceptions.
6 years ago
Niels Grewe ecdc4ffbd4 check both for the full and the short name of the C++ ABI library, unset cache if the library is not usable 6 years ago
Niels Grewe 5578072611
Write a correct .pc file for gnustep-make installs
Fixes #140
6 years ago
David Chisnall 8e59872681 Require C++14 in CMake. 6 years ago
Niels Grewe 8249036318 generate a pkg-config file 6 years ago
David Chisnall 55819ce107 Move the libstdc++ code path to a separate file.
We need to #include <exception> for this to work, but this brings in the
public definition of `std::type_info` and, unfortunately, that breaks
the private definition that we need in this compilation unit.
6 years ago
David Chisnall 3f38f691af Rework ARC code as C++.
Move the weak references hash table to use a well-tested third-party
implementation instead of the hand-rolled version.
7 years ago
Frederik Seiffert 61eee9e0a2 Pass on Android toolchain flags for CXX runtime check. 7 years ago
Jordan Schidlowsky f5f452bcb9 cmake fails when project is used in other cmake projects. CMAKE_CURRENT_LIST_DIR should be a more portable path 7 years ago
David Chisnall 52ca9b207b Make it easier to override the assembler on Windows.
This is necessary for building with Visual Studio (msbuild)
7 years ago
Niels Grewe e627c14b5f fix(libBlocksRuntime compatibility): Install proper compatibiltiy headers for libBlocksRuntime 7 years ago
David Chisnall c489cc909d Fix header symlink installation. 7 years ago
David Chisnall 455a4758f1 Make CMake install the dll on Windows. 7 years ago
David Chisnall f4be4d5696 Disable old ABI compat by default on Windows. 7 years ago
Marvin Scholz c498a65fe6 Add missing header file to CMakeLists 8 years ago
David Chisnall f7a21aaf4d Bump the CPack version to 2.0. 8 years ago
David Chisnall 2978cbb760 Don't try to symlink headers on Windows 8 years ago
David Chisnall bab334acd4 Fix cmake configuration for Windows builds. 8 years ago
David Chisnall 934cd13a7a Initial pass at Windows support.
All tests now pass with the new ABI on x86-64, with the new ABI.  Some
of the code is ugly and other platforms are probably broken.
8 years ago
David Chisnall c9e8743095 GC some dead code and move another legacy-compat file under the correct
option.
8 years ago