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

Update ANNOUNCE for 2.2.1 #282

Merged
merged 10 commits into from
Mar 21, 2024
25 changes: 20 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ jobs:
system-processor: riscv64
triple: riscv64-linux-gnu
rtld: ld-linux-riscv64-lp64d.so.1
- name: ppc64el
system-processor: powerpc64le
triple: powerpc64le-linux-gnu
rtld: ld64.so.2
# lld versions prior to 15 do not support R_RISCV_ALIGN relocations
exclude:
- llvm-version: 13
Expand All @@ -108,7 +112,7 @@ jobs:
sudo apt install libstdc++-9-dev-${{ matrix.arch.name }}-cross qemu-user ninja-build
- name: Configure CMake
run: |
export LDFLAGS="-L/usr/lib/llvm-${{ matrix.llvm-version }}/lib/ -fuse-ld=lld -Wl,--dynamic-linker=/usr/${{ matrix.arch.triple }}/lib/${{ matrix.arch.rtld }},-rpath,/usr/${{ matrix.arch.triple }}/lib"
export LDFLAGS="-L/usr/lib/llvm-${{ matrix.llvm-version }}/lib/ -fuse-ld=lld-${{ matrix.llvm-version}} -Wl,--dynamic-linker=/usr/${{ matrix.arch.triple }}/lib/${{ matrix.arch.rtld }},-rpath,/usr/${{ matrix.arch.triple }}/lib"
cmake -B ${{github.workspace}}/build \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch.system-processor }} \
Expand Down Expand Up @@ -193,7 +197,7 @@ jobs:
matrix:
# Build each combination of OS and release/debug variants
os: [ windows-2019 ]
msystem: [ ucrt64, mingw64 ]
msystem: [ ucrt64, mingw64, clang64 ]
build-type: [ Release, Debug ]
include:
- msystem: ucrt64
Expand All @@ -202,6 +206,10 @@ jobs:
- msystem: mingw64
package-prefix: x86_64
cmake-flags: LDFLAGS="-fuse-ld=lld -lstdc++ -lgcc_s"
- msystem: clang64
package-prefix: clang-x86_64
cmake-flags: LDFLAGS="-lc++"
ctest-flags: -E UnexpectedException*
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
Expand All @@ -220,16 +228,23 @@ jobs:
run: |
mkdir build
cd build
${{ matrix.cmake-flags }} cmake .. -DTESTS=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
${{ matrix.cmake-flags }} cmake .. -DTESTS=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
working-directory: build
run: |
cmake --build .
- name: Test
working-directory: build
run: |
ctest -j 4 --output-on-failure -T test

ctest -j 4 --output-on-failure -T test ${{ matrix.ctest-flags }}
- name: Install
working-directory: build
run: |
cmake --install . --prefix=../dist
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.msystem }}-${{ matrix.build-type }}
path: dist/

# Fake check that can be used as a branch-protection rule.
all-checks:
Expand Down
51 changes: 13 additions & 38 deletions ANNOUNCE
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
GNUstep Objective-C Runtime 2.2
===============================
GNUstep Objective-C Runtime 2.2.1
=================================

This is the second update to the second major release of the GNUstep Objective-C
runtime (a.k.a. libobjc2). This runtime was designed to support the features
of modern dialects of Objective-C for use with GNUstep and other Objective-C
programs.
This a bugfix release for the second update to the second major release of
the GNUstep Objective-C runtime (a.k.a. libobjc2). This runtime was designed
to support the features of modern dialects of Objective-C for use with GNUstep and
other Objective-C programs.

Highlights of this release include:

- Initial support for RISC-V 64-bit (rv64) including an architecture-specific
objc_msgSend, and block trampoline implementation. Please note that
double-precision floating-point support (rv64d) is required for the
objc_msgSend implementation.
- Initial support for Windows on ARM64 with fast-path objc_msgSend.
- Numerous improvements to the Objective-C++ exception interoperation code.
The runtime now dynamically detects whether the libcxxrt, libsupc++, or
libc++abi variant of the Itanium C++ Exception ABI is being used. This is
the first version to support exception interoperability with libc++abi.
- Because we no longer need to identify the specific C++ runtime, we can link
to it indirectly via the C++ standard library, which enables more C++ to be
used in the Objective-C runtime.
- The minimum CMake version has been bumped to 3.16, which supports
Objective-C. This support is now used, simplifying the build.
- Support for GC mode is gone. Apple dropped support for this a long time ago.
- `objc_setUncaughtExceptionHandler` is added, which avoids consuming code
needing to access a library-owned global.
- The selector-table code has been rewritten in C++, improving performance of
adding selectors. This is unlikely to have a measurable impact on
performance outside of contrived test cases, but the new code is more
maintainable.
- Several bug fixes in the ARC code, especially in corner cases surrounding
weak references.
- Support for fast-path allocation / initialisation functions. Root classes
that opt into this should implement `+_TrivialAllocInit` (this can be an
empty method, it is not called). Clang 18 or later will emit calls to the
fast-path functions for `+alloc`, `+allocWithZone:` and `+alloc` + `-init`
calls. This should improve code density as well as performance.

You may obtain the code for this release from git and use the 2.2 branch:
- Various improvements for building and using libobjc2 on MinGW.
- Improved support for the PowerPC architecture.
- A fix for the detection of the tls-robin-map dependency.

You may obtain the code for this release from git and use the 2.2.1 branch:

https://github.com/gnustep/libobjc2.git

Alternatively, a tarball is available from:

https://github.com/gnustep/libobjc2/archive/v2.2.zip
https://github.com/gnustep/libobjc2/archive/v2.2.tar.gz
https://github.com/gnustep/libobjc2/archive/v2.2.1.zip
https://github.com/gnustep/libobjc2/archive/v2.2.1.tar.gz

The runtime library is responsible for implementing the core features of the
object model, as well as exposing introspection features to the user. The
Expand Down
55 changes: 55 additions & 0 deletions ANNOUNCE.2.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
GNUstep Objective-C Runtime 2.2
===============================

This is the second update to the second major release of the GNUstep Objective-C
runtime (a.k.a. libobjc2). This runtime was designed to support the features
of modern dialects of Objective-C for use with GNUstep and other Objective-C
programs.

Highlights of this release include:

- Initial support for RISC-V 64-bit (rv64) including an architecture-specific
objc_msgSend, and block trampoline implementation. Please note that
double-precision floating-point support (rv64d) is required for the
objc_msgSend implementation.
- Initial support for Windows on ARM64 with fast-path objc_msgSend.
- Numerous improvements to the Objective-C++ exception interoperation code.
The runtime now dynamically detects whether the libcxxrt, libsupc++, or
libc++abi variant of the Itanium C++ Exception ABI is being used. This is
the first version to support exception interoperability with libc++abi.
- Because we no longer need to identify the specific C++ runtime, we can link
to it indirectly via the C++ standard library, which enables more C++ to be
used in the Objective-C runtime.
- The minimum CMake version has been bumped to 3.16, which supports
Objective-C. This support is now used, simplifying the build.
- Support for GC mode is gone. Apple dropped support for this a long time ago.
- `objc_setUncaughtExceptionHandler` is added, which avoids consuming code
needing to access a library-owned global.
- The selector-table code has been rewritten in C++, improving performance of
adding selectors. This is unlikely to have a measurable impact on
performance outside of contrived test cases, but the new code is more
maintainable.
- Several bug fixes in the ARC code, especially in corner cases surrounding
weak references.
- Support for fast-path allocation / initialisation functions. Root classes
that opt into this should implement `+_TrivialAllocInit` (this can be an
empty method, it is not called). Clang 18 or later will emit calls to the
fast-path functions for `+alloc`, `+allocWithZone:` and `+alloc` + `-init`
calls. This should improve code density as well as performance.

You may obtain the code for this release from git and use the 2.2 branch:

https://github.com/gnustep/libobjc2.git

Alternatively, a tarball is available from:

https://github.com/gnustep/libobjc2/archive/v2.2.zip
https://github.com/gnustep/libobjc2/archive/v2.2.tar.gz

The runtime library is responsible for implementing the core features of the
object model, as well as exposing introspection features to the user. The
GNUstep runtime implements a superset of Apple's Objective-C Runtime APIs.

If you come across any problems, please file them in the issue tracker:

https://github.com/gnustep/libobjc2/issues
4 changes: 4 additions & 0 deletions CMake/detect_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#error i386
#elif defined(__x86_64__)
#error x86_64
#elif defined(__powerpc64__)
#error powerpc64
#elif defined(__powerpc__)
#error powerpc
#else
#error unknown
#endif
34 changes: 27 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ endif()

enable_language(OBJC OBJCXX)

if (MINGW)
# Make sure ObjC++ source code uses the C++ implicit include directories. This is needed, for example, to make sure we use the right
# C++ headers when using clang but linking with libstdc++.
set(CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif ()

INCLUDE (CheckCXXSourceCompiles)
INCLUDE (FetchContent)

Expand All @@ -44,7 +50,7 @@ try_compile(
)

if(NOT COMPILE_SUCCESS)
string(REGEX MATCH "(aarch64|arm|i386|x86_64|unknown)" ARCHITECTURE ${COMPILE_OUTPUT})
string(REGEX MATCH "(aarch64|arm|i386|x86_64|powerpc64|powerpc|unknown)" ARCHITECTURE ${COMPILE_OUTPUT})
endif()

set(ARCHITECTURE ${ARCHITECTURE} CACHE STRING "Architecture Type")
Expand Down Expand Up @@ -118,15 +124,13 @@ set(libobjc_CXX_SRCS
# Windows does not use DWARF EH, except when using the GNU ABI (MinGW)
if (WIN32 AND NOT MINGW)
list(APPEND libobjc_CXX_SRCS eh_win32_msvc.cc)
elseif (MINGW)
list(APPEND libobjc_CXX_SRCS eh_win32_mingw.m)
else ()
elseif (NOT MINGW)
list(APPEND libobjc_C_SRCS eh_personality.c)
endif ()

find_package(tsl-robin-map)

if (NOT tls-robin-map_FOUND)
if (NOT tsl-robin-map_FOUND)
FetchContent_Declare(
robinmap
GIT_REPOSITORY https://github.com/Tessil/robin-map/
Expand Down Expand Up @@ -180,6 +184,14 @@ set(INCLUDE_DIRECTORY "objc" CACHE STRING

add_compile_options($<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},i686>:-march=i586>)

# PowerPC 32-bit does not support native 64-bit atomic operations,
# which is used in safe caching.
# You must also update the guard in objc/runtime.h, when updating
# this macro.
if (ARCHITECTURE STREQUAL "powerpc")
add_definitions(-DNO_SAFE_CACHING)
endif()

set(INSTALL_TARGETS objc)

if(WIN32)
Expand Down Expand Up @@ -216,7 +228,7 @@ if (WIN32 AND NOT MINGW)
message(STATUS "Using MSVC-compatible exception model")
elseif (MINGW)
message(STATUS "Using MinGW-compatible exception model")
list(APPEND libobjc_CXX_SRCS objcxx_eh.cc)
list(APPEND libobjc_CXX_SRCS objcxx_eh.cc objcxx_eh_mingw.cc)
else ()
separate_arguments(EH_PERSONALITY_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS})
if (CMAKE_CXX_COMPILER_TARGET)
Expand Down Expand Up @@ -301,18 +313,26 @@ if (NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif ()

if (NOT CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR bin)
endif ()

set(GNUSTEP_INSTALL_TYPE ${DEFAULT_INSTALL_TYPE} CACHE STRING
"GNUstep installation type. Options are NONE, SYSTEM, NETWORK or LOCAL.")
if (${GNUSTEP_INSTALL_TYPE} STREQUAL "NONE")
SET(LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}" CACHE STRING
"Subdirectory of the root prefix where libraries are installed.")
SET(BIN_INSTALL_PATH "${CMAKE_INSTALL_BINDIR}" CACHE STRING
"Subdirectory of the root prefix where libraries are installed.")
SET(HEADER_INSTALL_PATH "include")
SET(PC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
else ()
EXEC_PROGRAM(gnustep-config
ARGS "--variable=GNUSTEP_${GNUSTEP_INSTALL_TYPE}_LIBRARIES"
OUTPUT_VARIABLE LIB_INSTALL_PATH)
EXEC_PROGRAM(gnustep-config
ARGS "--variable=GNUSTEP_${GNUSTEP_INSTALL_TYPE}_LIBRARIES"
OUTPUT_VARIABLE BIN_INSTALL_PATH)
EXEC_PROGRAM(gnustep-config
ARGS "--variable=GNUSTEP_${GNUSTEP_INSTALL_TYPE}_HEADERS"
OUTPUT_VARIABLE HEADER_INSTALL_PATH)
Expand All @@ -321,7 +341,7 @@ endif ()
message(STATUS "GNUstep install type set to ${GNUSTEP_INSTALL_TYPE}")

install(TARGETS ${INSTALL_TARGETS}
RUNTIME DESTINATION ${LIB_INSTALL_PATH}
RUNTIME DESTINATION ${BIN_INSTALL_PATH}
LIBRARY DESTINATION ${LIB_INSTALL_PATH}
ARCHIVE DESTINATION ${LIB_INSTALL_PATH})
install(FILES ${libobjc_HDRS}
Expand Down
2 changes: 1 addition & 1 deletion Test/UnexpectedException.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LONG WINAPI _UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo)

int main(void)
{
#if !(defined(__arm__) || defined(__ARM_ARCH_ISA_A64))
#if !(defined(__arm__) || defined(__ARM_ARCH_ISA_A64)) && !defined(__powerpc__)
#if defined(_WIN32) && !defined(__MINGW32__)
// also verify that an existing handler still gets called after we set ours
SetUnhandledExceptionFilter(&_UnhandledExceptionFilter);
Expand Down
8 changes: 8 additions & 0 deletions asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@
#define SLOT_OFFSET 0
#endif
#define SMALLOBJ_MASK ((1<<SMALLOBJ_BITS) - 1)

// Page size configuration
#if defined(__powerpc64__)
# define PAGE_SHIFT 16
#else
# define PAGE_SHIFT 12
#endif
#define PAGE_SIZE (1<<PAGE_SHIFT)
15 changes: 10 additions & 5 deletions block_to_imp.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "blocks_runtime.h"
#include "lock.h"
#include "visibility.h"
#include "asmconstants.h" // For PAGE_SIZE

#ifndef __has_builtin
#define __has_builtin(x) 0
Expand Down Expand Up @@ -95,22 +96,26 @@ static int mprotect(void *buffer, size_t len, int prot)
# endif
#endif

#define PAGE_SIZE 4096

struct block_header
{
void *block;
void(*fnptr)(void);
/**
* On 64-bit platforms, we have 16 bytes for instructions, which ought to
* be enough without padding. On MIPS, we need
* be enough without padding.
* Note: If we add too much padding, then we waste space but have no other
* ill effects. If we get this too small, then the assert in
* `init_trampolines` will fire on library load.
*
* PowerPC: We need INSTR_CNT * INSTR_LEN = 7*4 = 28 bytes
* for instruction. sizeof(block_header) must be a divisor of
* PAGE_SIZE, so we need to pad block_header to 32 bytes.
* On PowerPC 64-bit where sizeof(void *) = 8 bytes, we
* add 16 bytes of padding.
*/
#if defined(__i386__) || (defined(__mips__) && !defined(__mips_n64))
#if defined(__i386__) || (defined(__mips__) && !defined(__mips_n64)) || (defined(__powerpc__) && !defined(__powerpc64__))
uint64_t padding[3];
#elif defined(__mips__)
#elif defined(__mips__) || defined(__powerpc64__)
uint64_t padding[2];
#elif defined(__arm__)
uint64_t padding;
Expand Down