From 0aeae8f645f087d455daf6bdc999eb2389bfc646 Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Wed, 23 Oct 2024 14:07:07 +0000 Subject: ada: Set correct minimum stack size for aarch64-linux The minimum stack size defined by PTHREAD_STACK_MIN defined on AArch64 Linux is 131072 bytes. Add a separate version for this target to reflect that value. Previously the x86-64 value of 16384 bytes was used. gcc/ada/ChangeLog: * Makefile.rtl: Use libgnat/s-parame__aarch64-linux.adb for s-parame.adb on aarch64-linux. * libgnat/s-parame__aarch64-linux.adb: Add file. --- gcc/ada/Makefile.rtl | 1 + gcc/ada/libgnat/s-parame__aarch64-linux.adb | 82 +++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 gcc/ada/libgnat/s-parame__aarch64-linux.adb (limited to 'gcc') diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 4d32bc4..d686a30 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -2496,6 +2496,7 @@ ifeq ($(strip $(filter-out aarch64% linux%,$(target_cpu) $(target_os))),) s-osinte.adb. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This is the version for AArch64 Linux + +package body System.Parameters is + + ------------------------- + -- Adjust_Storage_Size -- + ------------------------- + + function Adjust_Storage_Size (Size : Size_Type) return Size_Type is + begin + if Size = Unspecified_Size then + return Default_Stack_Size; + elsif Size < Minimum_Stack_Size then + return Minimum_Stack_Size; + else + return Size; + end if; + end Adjust_Storage_Size; + + ------------------------ + -- Default_Stack_Size -- + ------------------------ + + function Default_Stack_Size return Size_Type is + Default_Stack_Size : constant Integer; + pragma Import (C, Default_Stack_Size, "__gl_default_stack_size"); + begin + if Default_Stack_Size = -1 then + return 2 * 1024 * 1024; + elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then + return Minimum_Stack_Size; + else + return Size_Type (Default_Stack_Size); + end if; + end Default_Stack_Size; + + ------------------------ + -- Minimum_Stack_Size -- + ------------------------ + + function Minimum_Stack_Size return Size_Type is + begin + -- 12K is required for stack-checking to work reliably on most platforms + -- when using the GCC scheme to propagate an exception in the ZCX case. + -- 131K is the value of PTHREAD_STACK_MIN under AArch64 Linux, so is a + -- reasonable default. + + return 128 * 1024; + end Minimum_Stack_Size; + +end System.Parameters; -- cgit v1.1