1362 Commits (main)
 

Author SHA1 Message Date
David Chisnall 5a4d0959b3 Update objc/runtime.h
Co-authored-by: Frederik Seiffert <frederik@algoriddim.com>
3 years ago
David Chisnall a094ad0a45 Add returns-retained annotation to class_createInstance. 3 years ago
Frederik Seiffert 7dee32ad1e CI: upgrade to Windows 2022 VM 4 years ago
Frederik Seiffert a357cb999c
tests: Test that we can throw and catch the same exception multiple times sequentially. (#188)
This originally came up as an issue with libc++abi support (#152), but is not specific to that ABI.

* Use the C++ runtime to check for uncaught C++ exceptions.

As discussed in #152, use the function defined in the Itanium C++ ABI to
check whether the thrown exception is the current caught C++ exception
and needs rethrowing via `__cxa_rethrow()`.

Co-authored-by: Niels Grewe <grewe@ocean-insights.com>
Co-authored-by: David Chisnall <gnustep@theravensnest.org>
4 years ago
Graham--M 14619f2905
Fix autorelease pool emptying when new references are added (#218)
* Add test for emptying autorelease pool

* Fix arc autorelease pool emptying when adding further references
When releasing a reference in the arc autorelease pool, it is
possible and anticipated that new references may added to the pool.
This fix addresses an edge case where releasing a reference in the
same pool page as the stop position can add more references which
cause the insertion of a new page and emptyPool() returns early
after emptying the new page.
4 years ago
Frederik Seiffert b32ee7787d
Fix weak ref handling during dealloc (#215)
Add test for setting weak ref during dealloc

Fixes #214
4 years ago
Frederik Seiffert bdf03cb55d Update runtime defines to match Apple platforms 4 years ago
Alex Myczko 646c142f3c
fix typo (#208) 5 years ago
David Chisnall 396c9b553a
Delete some dead code containing bugs. (#205)
Fixes #203
5 years ago
mischievous 1094eb7a1c
Updated the class_copyMethodList (#206)
Updated the class_copyMethodList to clear the stack garbage for outCount if preset before checking the class is null
5 years ago
Graham--M 921e3c3386 Strong retain calls should always return the instance pointer.
This fixes a regression in 73132a6 (#200) where nil was returned
from a retain call after the object begins deallocating. Normal
retains of a deallocating object are still expected to return an
instance pointer inside its dealloc method and code compiled with ARC
will generate calls to objc_storeStrong() when a block captures the
self pointer inside the dealloc method.
5 years ago
Graham--M 38f44a8752 Remove unused declares 5 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
Frederik Seiffert 2d976b61e2 Export objc_enumerationMutation() function. 5 years ago
Frederik Seiffert 06da6a91c3 Suppress EH debug logs in release builds. 5 years ago
Graham--M 73132a6c98
Avoid dangling weak references to deallocating objects. (#200)
The previous checks for a deallocating object with negative reference count did not work because:
    1. the sign bit has to be recreated as was happening in objc_delete_weak_refs()
    2. there was no distinction between a saturated count and a negative reference count

refcount_max now indicates when the refcount has saturated and should no longer be mutated.
An underflow to -1 still maps to refcount_mask, allowing us to detect when an object is supposed to be deallocated.
Neither objc_release_fast_no_destroy_np() nor objc_retain_fast_np() mutate the refcount when it is one of those values, so the comment in objc_delete_weak_refs() was adjusted.
5 years ago
Graham Lee c399119694 Remove redundant declaration of __cxa_allocate_exception
Fixes #193
5 years ago
David Chisnall 93fbf4d4bc Increase testing matrix.
Add 32-bit x86-Linux builds.
Add building with the nightly LLVM releases.  There are some regressions
since LLVM 8 that would have been caught by this that we can hopefully
fix in time for the LLVM 12 release.
5 years ago
Frederik Seiffert a08828291c Add missing extern "C" in unwind-arm.h. 5 years ago
David Chisnall 15ae929a2c Add libc++abi note to ANNOUNCE. 5 years ago
David Chisnall b685cc94eb Reset ANNOUNCE after 2.1 release. 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 bd274a7c3c Fix visibility of hooks on Windows. 5 years ago
Frederik Seiffert d20947bab9 Export encoding functions. 5 years ago
Riccardo Mottola b660bdb91e add 4 bytes of padding for stack alignment, as suggested by David. 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 41808111aa Fix compiling with libc++ but not linking with libc++. 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 282486deb6 Copy ANNOUNCE for 2.1 release. 5 years ago
David Chisnall e753b97615 Finish announcement for 2.1 release. 5 years ago
David Chisnall f78b684db3 Fix build with -fno-common
Several of the hooks were being generated with common linkage in hooks.c
and as normal initialised symbols in sendmsg2.c.  Recent clang defaults
to -fno-common, which causes the common linkage versions to become
strong symbols and then causes a linkage failure from duplicate
definitions: one zero initialised, one initialised with a real value.

This removes copy in hooks.c, retaining only the initialised version.

Fixes #171
5 years ago
David Chisnall 48c875fa44 Update the release announcement for version 2.1 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 4cf4ad145c
Correctly copy inner exception structs when building for ARM. (#166)
Fixes #164.
6 years ago
Frederik Seiffert cca84b183c Fix building without ObjC++ support. 6 years ago
Frederik Seiffert ed8eec6c6a Add unwind COPY_EXCEPTION macro. 6 years ago
David Chisnall b39a42252e Hide ARC warnings behind an off-by-default flag. 6 years ago
David Chisnall 3b8879720c More EH fixes.
libsupc++ is more aggressive about internal consistency checks than
libcxxrt, so we need to be more careful in the interop.  The tests from
PR #138 now pass for me on Debian with libsupc++.
6 years ago
David Chisnall be6483de6d Improve constant string support in tests.
This makes no difference to existing tests, but is needed for the ones
in #138
6 years ago
David Chisnall ec5c0bcae2 More C++ exception fixes.
* Make sure the unwind state is synchronised between the Objective-C
   and C++ exception objects.
 * Reintroduce the is-pointer callback so that `__cxa_begin_catch`
   adjusts the pointer correctly.  Objective-C++ code uses
   `__cxa_begin_catch` without the `objc_begin_catch` wrapper and the
   runtime does not call the `__do_catch` method on the type info if the
   type info is an exact match, so the caught object ended up being a
   pointer to the object.  This also meant that we needed to remove the
   double dereference in the `__do_catch` methods.
 * Introduce a subclass of `std::type_info` for all Objective-C types
   and move the `virtual` functions there.  This should simplify
   supporting libc++abi.
6 years ago
Johannes Brakensiek d5973fb6ce Add INSTALL instruction to reflect that git submodules need to be checked out as well 6 years ago
David Chisnall 1594de76c3
Merge pull request #156 from gnustep/detect-ehabi
Initial run-time detection of C++ EH ABI variant.
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
David Chisnall ec8782e396
Merge pull request #149 from gnustep/checkARCAccessors-fix
Fix detection of ARC-incompatible memory management methods
6 years ago
David Chisnall 5a35fff19d Add test for checking whether a class supports fast ARC. 6 years ago
David Chisnall 2d87ac45a1 Fix logging macro 6 years ago
rfm 8dbee52d24 Fix fast-ARC checks.
Check for release and autorelease as well as for retain.
6 years ago