diff --git a/user/dotnet8-build/APKBUILD b/user/dotnet8-build/APKBUILD index 992081e..c908ca1 100644 --- a/user/dotnet8-build/APKBUILD +++ b/user/dotnet8-build/APKBUILD @@ -3,7 +3,7 @@ pkgname=dotnet8-build pkgver=8.0.100_pre1 -pkgrel=0 +pkgrel=1 _gittag=v8.0.100-preview.1 _giturl="https://github.com/dotnet/dotnet" _testtag=16c3c04f3ae6620a474fa0474e8b298190e506c1 @@ -12,6 +12,9 @@ _patches=" build_enable-timestamps.patch check_rid-alpine-generation.diff roslyn-analyzer_disable-apphost.patch + runtime_79856-save-errno-when-using-posix-semaphores.patch + runtime_82173-add-cmake-check-for-ioclt-prototype.patch + runtime_82676-make-pal-console-c-use-int.patch runtime_enable-system-libunwind.diff runtime_mono-thread-coop-undefine-fortify-source.patch sdk_14239-add-zsh-compdef-completion-script.patch @@ -25,8 +28,7 @@ pkgdesc="The .NET $_pkgver_macro bootstrap" # x86: blocked by https://github.com/dotnet/runtime/issues/77667 # armhf: blocked by https://github.com/dotnet/runtime/issues/77663 # riscv64: port WIP https://github.com/dotnet/runtime/issues/36748 -# s390x / ppc64le: no bootstrap crossbuilt yet -arch="all !x86 !armhf !riscv64 !s390x !ppc64le" +arch="all !x86 !armhf !riscv64" url=https://dotnet.microsoft.com license="MIT" # hack for dotnetx-build to be able to pull itself for bootstrapping @@ -193,16 +195,6 @@ prepare() { msg "check_rid-alpine-generation.diff" patch -p1 -d "$_testdir" -i "$srcdir"/check_rid-alpine-generation.diff - # Parallel restore is broken on mono-based builds since dotnet7 - # see https://github.com/dotnet/runtime/issues/77364 - # A workaround via runtime_enable-runtime-marshalling.diff - case $CARCH in - s390x|ppc64le) - msg "runtime_enable-runtime-marshalling.diff" - patch -p1 -i "$srcdir"/runtime_enable-runtime-marshalling.diff - ;; - esac - # Using system libunwind is broken on aarch64|armv7, and unused on mono-based builds # see https://github.com/dotnet/source-build/issues/2408, case $CARCH in @@ -515,6 +507,9 @@ f48d4168f526aade888bbd17f2da87f721dabc8ae004707ef9195b6359b79b871115a686678c8754 eed7a7481a967f6938de956a6df485efa6dd61bf36ae4a768493cb1f7da0296dc91e0f2f89f7c302083ba9cf0c778e28228ec1b52e902077a00072d7d9957ef3 build_enable-timestamps.patch 941b430b55e323f723bbc5160447f060f40d18ce32e5803ab7dda16bfc60a0f5ec1dccd246e68475d7115ee265a9433824d8a5d997c302531311194a90deeca9 check_rid-alpine-generation.diff 4ac92d2d9190a55ee20d3e145a28a6953c98d3eb838c8acfb808b8839316443cb64da4a2c5787df0171fce7ef96ff6381043085ed90c23ec09ce9ac81571e675 roslyn-analyzer_disable-apphost.patch +77fa6d9987a7c43725582c9c493e9d4d5965a611a1d795dad4e3d46cd730caced095f994d93f91a131df7fa4b6a7277bcd3d915bae2dcd869559f22076fbc575 runtime_79856-save-errno-when-using-posix-semaphores.patch +86e805b5d0d85294b3ac4866dee00b906a35d064e988e5b48591aeabf29e34ddd8fccb4770cf2bd66437ce4f704fdda43a7522baa9f23ad9353ce010f884d1c5 runtime_82173-add-cmake-check-for-ioclt-prototype.patch +18f2be488e4d6c667b90f6b6faed12a84f8c5748c6da91a291542e0a9e8b43effc3bba92a6b38da1b2a904466e3e9bd66b01ad0d3f521bd27a067eb362e2add6 runtime_82676-make-pal-console-c-use-int.patch 293742ab307bef459a21deadcc4ad7c7996cc4b490910a36c2763b8ad25cc8a91c4e03b6290567cd1030f69638d0156c5b6970887858fb091f8482b67356065d runtime_enable-system-libunwind.diff d732df247c721c9f677baabdd7f36dbf4b564814ff64164361065bb1c196b767494a1d39f634eadf01a23032c7b3e64102614b7213065c81096bbf3f8022e6a0 runtime_mono-thread-coop-undefine-fortify-source.patch d1b4ebcbb1a6815fc0ce4c471485c232618e60968a879309fb8336821a9351d2e0028d9f7726c0c041c750b497a0baa47400c78c9ceff550b91b4a6c2816fc41 sdk_14239-add-zsh-compdef-completion-script.patch diff --git a/user/dotnet8-build/README.md b/user/dotnet8-build/README.md index 4c2c6df..5a708ba 100644 --- a/user/dotnet8-build/README.md +++ b/user/dotnet8-build/README.md @@ -1,22 +1,22 @@ -# dotnet7-build +# dotnet8-build -This is the .NET 7.0 package for Alpine Linux. +This is the .NET 8.0 package for Alpine Linux. Please report any issues [using Gitlab](https://gitlab.alpinelinux.org/alpine/aports/-/issues/new) and tag @ayakael # Building info ## Generated packages -* `dotnet7-build` (aimed for internal use as bootstrap) -* `dotnet7-build-artifacts` (aimed for internal use as bootstrap) -* `dotnet7-sdk` -* `dotnet7-templates` (required by sdk) +* `dotnet8-build` (aimed for internal use as bootstrap) +* `dotnet8-build-artifacts` (aimed for internal use as bootstrap) +* `dotnet8-sdk` +* `dotnet8-templates` (required by sdk) * `dotnet-zsh-completion` * `dotnet-bash-completion` * `dotnet-doc` * `netstandard21-targeting-pack` -## How to build dotnet7 on Alpine +## How to build dotnet8 on Alpine As dotnet is a self-hosting compiler (thus it compiles using itself), it requires a bootstrap for the initial build. To solve this problem, this package follows the `stage0` proposal outlined [here](https://lists.alpinelinux.org/~alpine/devel/%3C33KG0XO61I4IL.2Z7RTAZ5J3SY6%408pit.net%3E) @@ -27,17 +27,17 @@ builds bootstraps for Alpine on `x86_64`, `aarch64`, and `armv7`. Thus, `stage0` has also been designed to be crossbuild aware, allowing bootstrapping to other platforms. -In summary, dotnet7 is built using three different aports. +In summary, dotnet8 is built using three different aports. -* `community/dotnet7-stage0` -Builds minimum components for full build of dotnet7, and packages these in an initial -`dotnet7-stage0-bootstrap` package that `dotnet7-build` pulls. -* `community/dotnet7-build` -Builds full and packages dotnet7 fully using either stage0 or previoulsy built -dotnet7 build. -* `community/dotnet7-runtime` +* `community/dotnet8-stage0` +Builds minimum components for full build of dotnet8, and packages these in an initial +`dotnet8-stage0-bootstrap` package that `dotnet8-build` pulls. +* `community/dotnet8-build` +Builds full and packages dotnet8 fully using either stage0 or previoulsy built +dotnet8 build. +* `community/dotnet8-runtime` As abuild does not allow different versions for subpackages, a different aport -is required to package runtime bits from dotnet7-build. +is required to package runtime bits from dotnet8-build. ## Crossbuilding with `stage0` Crossbuilding `stage0` is a three step process: @@ -49,7 +49,7 @@ Crossbuilding `stage0` is a three step process: `$HOME/sysroot-$CTARGET_ARCH/etc/apk/repositories`, making sure to add required keys. This makes it so that whatever package is not built in step 1 will be pulled from package repos -3. Crossbuild `dotnet7-stage0` via: +3. Crossbuild `dotnet8-stage0` via: ``` CHOST=$CTARGET_ARCH abuild -r ``` @@ -58,7 +58,7 @@ CHOST=$CTARGET_ARCH abuild -r This package follows [package naming and contents suggested by upstream](https://docs.microsoft.com/en-us/dotnet/core/build/distribution-packaging), with two exceptions. It installs dotnet to `/usr/lib/dotnet` (aka `$_libdir`). -In addition, the package is named `dotnet7` as opposed to `dotnet-7.0` +In addition, the package is named `dotnet8` as opposed to `dotnet-8.0` to match Alpine Linux naming conventions for packages with many installable versions # Contributing @@ -74,7 +74,7 @@ follow. 2. Checkout the forked repository. - `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports` - - `cd community/dotnet7-build` + - `cd community/dotnet8-build` 3. Make your changes. Don't forget to add a changelog. @@ -86,10 +86,10 @@ follow. 6. Commit the changes to the git repo in a git branch - - `git checkout -b dotnet7/` + - `git checkout -b dotnet8/` - `git add` any new patches - `git remove` any now-unnecessary patches - - `git commit -m 'community/dotnet7-build: descriptive description'` + - `git commit -m 'community/dotnet8-build: descriptive description'` - `git push` 7. Create a merge request with your changes, tagging @ayakael for review. @@ -104,7 +104,7 @@ follow. 2. Checkout the forked repository. - `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports` - - `cd community/dotnet7-build` + - `cd community/dotnet8-build` 3. Build the new upstream source tarball. Update the versions in the @@ -125,10 +125,10 @@ follow. 7. Commit the changes to the git repo in a git branch. - - `git checkout -b dotnet7/` + - `git checkout -b dotnet8/` - `git add` any new patches - `git remove` any now-unnecessary patches - - `git commit -m 'community/dotnet7-build: upgrade to ` + - `git commit -m 'community/dotnet8-build: upgrade to ` - `git push` 8. Create a merge request with your changes, tagging @ayakael for review. diff --git a/user/dotnet8-build/runtime_76500-mono-musl-support.patch b/user/dotnet8-build/runtime_76500-mono-musl-support.patch deleted file mode 100644 index 6f4a121..0000000 --- a/user/dotnet8-build/runtime_76500-mono-musl-support.patch +++ /dev/null @@ -1,326 +0,0 @@ -From 98054ea87ce70247bb09ceafd2ad1a0b36d2fef4 Mon Sep 17 00:00:00 2001 -Patch-Source: https://github.com/dotnet/runtime/pull/76500 -From: Antoine Martin -Date: Sat, 1 Oct 2022 09:21:58 -0400 -Subject: [PATCH] Mono musl support - ---- - Directory.Build.props | 1 + - eng/common/cross/toolchain.cmake | 38 +++++++++++++++++++----- - eng/native/configurecompiler.cmake | 7 +++++ - eng/native/tryrun.cmake | 6 +++- - src/coreclr/pal/src/CMakeLists.txt | 5 ++++ - src/coreclr/pal/src/misc/perfjitdump.cpp | 2 +- - src/coreclr/vm/i386/cgenx86.cpp | 4 +++ - src/mono/CMakeLists.txt | 33 ++++++++++++++++++++ - src/mono/mono.proj | 32 +++++++++++++------- - src/mono/mono/mini/mini-runtime.c | 29 ++++++++++++++++++ - src/mono/mono/utils/mono-context.h | 8 +++++ - 11 files changed, 146 insertions(+), 19 deletions(-) - -diff --git a/src/runtime/Directory.Build.props b/src/runtime/Directory.Build.props -index 6f9b97c0a9c..4298a6df1d3 100644 ---- a/src/runtime/Directory.Build.props -+++ b/src/runtime/Directory.Build.props -@@ -22,7 +22,6 @@ - $(_hostOS) - true - true -- true - - - -@@ -154,7 +154,7 @@ - <_runtimeOS Condition="'$(TargetsMobile)' == 'true'">$(TargetOS.ToLowerInvariant()) - - <_portableOS>linux -- <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl'">linux-musl -+ <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl' or $(_runtimeOS.StartsWith('alpine'))">linux-musl - <_portableOS Condition="'$(_runtimeOS)' == 'linux-bionic'">linux-bionic - <_portableOS Condition="'$(_hostOS)' == 'OSX'">osx - <_portableOS Condition="'$(_runtimeOS)' == 'win' or '$(TargetOS)' == 'windows'">win - -@@ -200,6 +199,9 @@ - - $(PackageRID) - $(_portableOS)-$(TargetArchitecture) -+ -+ true -+ true - - - -diff --git a/src/runtime/eng/native/tryrun.cmake b/src/runtime/eng/native/tryrun.cmake -index 6355b0988f7..056c6606b17 100644 ---- a/src/runtime/eng/native/tryrun.cmake -+++ b/src/runtime/eng/native/tryrun.cmake -@@ -8,7 +8,11 @@ endmacro() - - if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR - EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR -- EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) -+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl OR -+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl OR -+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/ppc64le-alpine-linux-musl OR -+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl OR -+ EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl) - - set(ALPINE_LINUX 1) - elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) -diff --git a/src/runtime/src/coreclr/pal/src/CMakeLists.txt b/src/runtime/src/coreclr/pal/src/CMakeLists.txt -index d9726460ccf..c28563f8619 100644 ---- a/src/runtime/src/coreclr/pal/src/CMakeLists.txt -+++ b/src/runtime/src/coreclr/pal/src/CMakeLists.txt -@@ -315,6 +315,11 @@ if(CLR_CMAKE_TARGET_LINUX) - target_link_libraries(coreclrpal ${UNWIND_LIBS}) - endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - -+ # bundled libunwind requires using libucontext on alpine and x86 and ppc64le -+ if(CLR_CMAKE_TARGET_ALPINE_LINUX AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_POWERPC64)) -+ target_link_libraries(coreclrpal ucontext) -+ endif(CLR_CMAKE_TARGET_ALPINE_LINUX AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_POWERPC64)) -+ - endif(CLR_CMAKE_TARGET_LINUX) - - if(CLR_CMAKE_TARGET_NETBSD) -diff --git a/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp b/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp -index 8d7f79ed3f0..043939ad2da 100644 ---- a/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp -+++ b/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - - #include "../inc/llvm/ELF.h" - -diff --git a/src/runtime/src/coreclr/vm/i386/cgenx86.cpp b/src/runtime/src/coreclr/vm/i386/cgenx86.cpp -index 811c84a140d..4e958a44b30 100644 ---- a/src/runtime/src/coreclr/vm/i386/cgenx86.cpp -+++ b/src/runtime/src/coreclr/vm/i386/cgenx86.cpp -@@ -1133,6 +1133,7 @@ extern "C" DWORD __stdcall avx512StateSupport() - - #else // !TARGET_UNIX - -+#if !__has_builtin(__cpuid) - void __cpuid(int cpuInfo[4], int function_id) - { - // Based on the Clang implementation provided in cpuid.h: -@@ -1143,7 +1144,9 @@ void __cpuid(int cpuInfo[4], int function_id) - : "0"(function_id) - ); - } -+#endif - -+#if !__has_builtin(__cpuidex) - void __cpuidex(int cpuInfo[4], int function_id, int subFunction_id) - { - // Based on the Clang implementation provided in cpuid.h: -@@ -1154,6 +1157,7 @@ void __cpuidex(int cpuInfo[4], int function_id, int subFunction_id) - : "0"(function_id), "2"(subFunction_id) - ); - } -+#endif - - extern "C" DWORD __stdcall xmmYmmStateSupport() - { -diff --git a/src/runtime/src/mono/CMakeLists.txt b/src/runtime/src/mono/CMakeLists.txt -index cdff32677c0..08a82cd7e83 100644 ---- a/src/runtime/src/mono/CMakeLists.txt -+++ b/src/runtime/src/mono/CMakeLists.txt -@@ -216,6 +216,35 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # Enable the "full RELRO" options (RELRO & BIND_NOW) at link time - add_link_options(-Wl,-z,relro) - add_link_options(-Wl,-z,now) -+ # Detect Linux ID -+ # TODO: Eventually merge with eng/native/configureplatform.cmake -+ set(LINUX_ID_FILE "/etc/os-release") -+ if(CMAKE_CROSSCOMPILING) -+ set(LINUX_ID_FILE "${CMAKE_SYSROOT}${LINUX_ID_FILE}") -+ endif() -+ -+ if(EXISTS ${LINUX_ID_FILE}) -+ execute_process( -+ COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID" -+ OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID -+ OUTPUT_STRIP_TRAILING_WHITESPACE) -+ -+ execute_process( -+ COMMAND bash -c "if strings \"${CMAKE_SYSROOT}/usr/bin/ldd\" 2>&1 | grep -q musl; then echo musl; fi" -+ OUTPUT_VARIABLE CLR_CMAKE_LINUX_MUSL -+ OUTPUT_STRIP_TRAILING_WHITESPACE) -+ endif() -+ -+ if(DEFINED CLR_CMAKE_LINUX_ID) -+ if(CLR_CMAKE_LINUX_ID STREQUAL alpine) -+ set(CLR_CMAKE_HOST_ALPINE_LINUX 1) -+ set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID}) -+ endif() -+ -+ if(CLR_CMAKE_LINUX_MUSL STREQUAL musl) -+ set(CLR_CMAKE_HOST_LINUX_MUSL 1) -+ endif() -+ endif(DEFINED CLR_CMAKE_LINUX_ID) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") - set(HOST_LINUX 1) - add_definitions(-D_GNU_SOURCE -D_REENTRANT) -@@ -893,6 +922,12 @@ if(HOST_IOS OR HOST_ANDROID OR HOST_MACCAT) - else() - set(DISABLE_DLLMAP 1) - endif() -+ -+if(CLR_CMAKE_HOST_ALPINE_LINUX) -+ # On Alpine Linux, we need to ensure that the reported stack range for the primary thread is -+ # larger than the initial committed stack size. -+ add_definitions(-DENSURE_PRIMARY_STACK_SIZE) -+endif() - ### End of OS specific checks - - include_directories("${CLR_SRC_NATIVE_DIR}") -diff --git a/src/runtime/src/mono/mono.proj b/src/runtime/src/mono/mono.proj -index 59fea4a2f72..5bac7fdf1c6 100644 ---- a/src/runtime/src/mono/mono.proj -+++ b/src/runtime/src/mono/mono.proj -@@ -554,19 +560,21 @@ - darwin-x86_64 - windows-x86_64 - <_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName) -- <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">gnu -- <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">android -+ <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' != 'true'">linux-gnu -+ <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' == 'true'">alpine-linux-musl -+ <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">linux-android - <_LinuxFloatAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">hf - <_Objcopy>objcopy -- <_Objcopy Condition="'$(Platform)' == 'arm'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'armv6'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-linux-$(_LinuxAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'riscv64'">riscv64-linux-$(_LinuxAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-linux-$(_LinuxAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'ppc64le'">powerpc64le-linux-$(_LinuxAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-linux-$(_LinuxAbi)-$(_Objcopy) -- <_Objcopy Condition="'$(Platform)' == 'x86'">i686-linux-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'arm'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'armv6'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'riscv64'">riscv64-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'ppc64le'">powerpc64le-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-$(_LinuxAbi)-$(_Objcopy) -+ <_Objcopy Condition="'$(Platform)' == 'x86'">i686-$(_LinuxAbi)-$(_Objcopy) - <_Objcopy Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy -+ <_Objcopy Condition="'$(TargetsLinuxMusl)' == 'true' and '$(CrossBuild)' != 'true'">objcopy - - <_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64'">llvm-objcopy- - -diff --git a/src/runtime/src/mono/mono/mini/CMakeLists.txt b/src/runtime/src/mono/mono/mini/CMakeLists.txt -index 30df4bac1f7..8698fd81206 100644 ---- a/src/runtime/src/mono/mono/mini/CMakeLists.txt -+++ b/src/runtime/src/mono/mono/mini/CMakeLists.txt -@@ -368,6 +368,11 @@ if(NOT DISABLE_SHARED_LIBS) - target_sources(monosgen-shared PRIVATE $) - set_target_properties(monosgen-shared PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME}) - target_link_libraries (monosgen-shared PRIVATE monoapi) -+ # Alpine Linux implements ucontext in a different library -+ if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) -+ target_link_libraries(monosgen-shared PRIVATE ucontext) -+ endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) -+ - target_include_directories (monosgen-shared PRIVATE monoapi) - if(TARGET_WIN32) - # on Windows the import library for the shared mono library will have the same name as the static library, -@@ -527,6 +532,10 @@ if(NOT DISABLE_EXECUTABLES) - set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross) - endif() - target_link_libraries(mono-sgen PRIVATE monoapi monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) -+ # Alpine Linux implements ucontext in a different library -+ if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) -+ target_link_libraries(mono-sgen PRIVATE ucontext) -+ endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) - if(NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS AND NOT DISABLE_LINK_STATIC_COMPONENTS) - # if components are built statically, link them into runtime. - target_sources(mono-sgen PRIVATE "${mono-components-objects}") -diff --git a/src/runtime/src/mono/mono/mini/mini-runtime.c b/src/runtime/src/mono/mono/mini/mini-runtime.c -index c481f69adc8..4db6c9a0ae7 100644 ---- a/src/runtime/src/mono/mono/mini/mini-runtime.c -+++ b/src/runtime/src/mono/mono/mini/mini-runtime.c -@@ -4383,6 +4383,30 @@ mini_llvm_init (void) - #endif - } - -+#ifdef ENSURE_PRIMARY_STACK_SIZE -+/*++ -+ Function: -+ EnsureStackSize -+ -+ Abstract: -+ This fixes a problem on MUSL where the initial stack size reported by the -+ pthread_attr_getstack is about 128kB, but this limit is not fixed and -+ the stack can grow dynamically. The problem is that it makes the -+ functions ReflectionInvocation::[Try]EnsureSufficientExecutionStack -+ to fail for real life scenarios like e.g. compilation of corefx. -+ Since there is no real fixed limit for the stack, the code below -+ ensures moving the stack limit to a value that makes reasonable -+ real life scenarios work. -+ -+ --*/ -+static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE void -+ensure_stack_size (size_t size) -+{ -+ volatile uint8_t *s = (uint8_t *)g_alloca(size); -+ *s = 0; -+} -+#endif // ENSURE_PRIMARY_STACK_SIZE -+ - void - mini_add_profiler_argument (const char *desc) - { -@@ -4544,6 +4568,11 @@ mini_init (const char *filename) - mono_w32handle_init (); - #endif - -+#ifdef ENSURE_PRIMARY_STACK_SIZE -+ // TODO: https://github.com/dotnet/runtime/issues/72920 -+ ensure_stack_size (5 * 1024 * 1024); -+#endif // ENSURE_PRIMARY_STACK_SIZE -+ - mono_thread_info_runtime_init (&ticallbacks); - - if (g_hasenv ("MONO_DEBUG")) { -diff --git a/src/runtime/src/mono/mono/utils/mono-context.h b/src/runtime/src/mono/mono/utils/mono-context.h -index a1f0fe6f68e..a9db2d336ca 100644 ---- a/src/runtime/src/mono/mono/utils/mono-context.h -+++ b/src/runtime/src/mono/mono/utils/mono-context.h -@@ -11,6 +11,14 @@ - #ifndef __MONO_MONO_CONTEXT_H__ - #define __MONO_MONO_CONTEXT_H__ - -+/* -+ * Handle non-gnu libc versions with nothing in features.h -+ * We have no idea what they're compatible with, so always fail. -+ */ -+#ifndef __GLIBC_PREREQ -+# define __GLIBC_PREREQ(x,y) 0 -+#endif -+ - #include "mono-compiler.h" - #include "mono-sigcontext.h" - #include "mono-machine.h" -diff --git a/src/runtime/src/native/libs/System.Native/pal_io.c b/src/runtime/src/native/libs/System.Native/pal_io.c -index 0929a0b49ec..86311e19507 100644 ---- a/src/runtime/src/native/libs/System.Native/pal_io.c -+++ b/src/runtime/src/native/libs/System.Native/pal_io.c -@@ -1267,7 +1267,7 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t - // Try copying data using a copy-on-write clone. This shares storage between the files. - if (sourceLength != 0) - { -- while ((ret = ioctl(outFd, FICLONE, inFd)) < 0 && errno == EINTR); -+ while ((ret = ioctl(outFd, (int)FICLONE, inFd)) < 0 && errno == EINTR); - copied = ret == 0; - } - #endif --- -2.36.3 - diff --git a/user/dotnet8-build/runtime_79856-save-errno-when-using-posix-semaphores.patch b/user/dotnet8-build/runtime_79856-save-errno-when-using-posix-semaphores.patch new file mode 100644 index 0000000..4d451b7 --- /dev/null +++ b/user/dotnet8-build/runtime_79856-save-errno-when-using-posix-semaphores.patch @@ -0,0 +1,174 @@ +From 50de22c7fa57c687a996bfdf6702871216881c0f Mon Sep 17 00:00:00 2001 +Patch-Source: https://github.com/dotnet/runtime/pull/79856 +From: Antoine Martin +Date: Sat, 25 Feb 2023 15:19:00 -0500 +Subject: [PATCH 1/1] [threads] Save errno when using posix semaphores for + thread transitions + +We already save/restore GetLastError on win32. Do it on posix +platforms, too. + +If one thread is in a pinvoke wrapper, while another thread triggers a +STW, the pinvoke wrapper will self-suspend the thread and wait for a +notification to resume. Depending on the platform we can use win32 +primitives, Mach semaphores or POSIX semaphores. win32 and posix can +both change the value of last error (errno, respectively) while the +thread is suspended. + +That means that code like this (generated by the +LibraryImportAttribute source generator) cannot reliably retrieve the +error from the last pinvoke: + +```csharp +__retVal = __PInvoke(__path_native, mode); // there is a pinvoke wrapper here, that transitions from GC Safe to GC Unsafe mode +__lastError = System.Runtime.InteropServices.Marshal.GetLastSystemError(); +``` + +The solution is to explicitly preserve the value of GetLastError/errno +when exiting from GC Safe. + +Fixes https://github.com/dotnet/runtime/issues/77364 +--- + .../src/mono/mono/utils/mono-threads-coop.c | 12 +++--- + .../src/mono/mono/utils/mono-threads.c | 4 +- + .../src/mono/mono/utils/mono-threads.h | 43 ++++++++++++++++--- + 3 files changed, 45 insertions(+), 14 deletions(-) + +diff --git a/src/runtime/src/mono/mono/utils/mono-threads-coop.c b/src/runtime/src/mono/mono/utils/mono-threads-coop.c +index 4ed659d66..c562ada67 100644 +--- a/src/runtime/src/mono/mono/utils/mono-threads-coop.c ++++ b/src/runtime/src/mono/mono/utils/mono-threads-coop.c +@@ -337,10 +337,10 @@ mono_threads_exit_gc_safe_region_internal (gpointer cookie, MonoStackData *stack + return; + + #ifdef ENABLE_CHECKED_BUILD_GC +- W32_DEFINE_LAST_ERROR_RESTORE_POINT; ++ MONO_DEFINE_LAST_ERROR_RESTORE_POINT; + if (mono_check_mode_enabled (MONO_CHECK_MODE_GC)) + coop_tls_pop (cookie); +- W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; ++ MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; + #endif + + mono_threads_exit_gc_safe_region_unbalanced_internal (cookie, stackdata); +@@ -365,7 +365,7 @@ mono_threads_exit_gc_safe_region_unbalanced_internal (gpointer cookie, MonoStack + /* Common to use enter/exit gc safe around OS API's affecting last error. */ + /* This method can call OS API's that will reset last error on some platforms. */ + /* To reduce errors, we need to restore last error before exit gc safe. */ +- W32_DEFINE_LAST_ERROR_RESTORE_POINT; ++ MONO_DEFINE_LAST_ERROR_RESTORE_POINT; + + info = (MonoThreadInfo *)cookie; + +@@ -398,7 +398,7 @@ mono_threads_exit_gc_safe_region_unbalanced_internal (gpointer cookie, MonoStack + info->user_data = NULL; + } + +- W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; ++ MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; + } + + void +@@ -652,14 +652,14 @@ mono_threads_suspend_policy_init (void) + // otherwise if one of the old environment variables is set, use that. + // otherwise use full preemptive suspend. + +- W32_DEFINE_LAST_ERROR_RESTORE_POINT; ++ MONO_DEFINE_LAST_ERROR_RESTORE_POINT; + + (policy = threads_suspend_policy_getenv ()) + || (policy = threads_suspend_policy_default ()) + || (policy = threads_suspend_policy_getenv_compat ()) + || (policy = MONO_THREADS_SUSPEND_FULL_PREEMPTIVE); + +- W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; ++ MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; + + g_assert (policy); + mono_threads_suspend_policy_hidden_dont_modify = (char)policy; +diff --git a/src/runtime/src/mono/mono/utils/mono-threads.c b/src/runtime/src/mono/mono/utils/mono-threads.c +index 2ef2fe45b..41dbf3032 100644 +--- a/src/runtime/src/mono/mono/utils/mono-threads.c ++++ b/src/runtime/src/mono/mono/utils/mono-threads.c +@@ -1894,7 +1894,7 @@ mono_thread_info_uninstall_interrupt (gboolean *interrupted) + /* Common to uninstall interrupt handler around OS API's affecting last error. */ + /* This method could call OS API's on some platforms that will reset last error so make sure to restore */ + /* last error before exit. */ +- W32_DEFINE_LAST_ERROR_RESTORE_POINT; ++ MONO_DEFINE_LAST_ERROR_RESTORE_POINT; + + g_assert (interrupted); + *interrupted = FALSE; +@@ -1917,7 +1917,7 @@ mono_thread_info_uninstall_interrupt (gboolean *interrupted) + THREADS_INTERRUPT_DEBUG ("interrupt uninstall tid %p previous_token %p interrupted %s\n", + mono_thread_info_get_tid (info), previous_token, *interrupted ? "TRUE" : "FALSE"); + +- W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; ++ MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT; + } + + static MonoThreadInfoInterruptToken* +diff --git a/src/runtime/src/mono/mono/utils/mono-threads.h b/src/runtime/src/mono/mono/utils/mono-threads.h +index 6a548b183..45353db4e 100644 +--- a/src/runtime/src/mono/mono/utils/mono-threads.h ++++ b/src/runtime/src/mono/mono/utils/mono-threads.h +@@ -866,19 +866,50 @@ mono_win32_interrupt_wait (PVOID thread_info, HANDLE native_thread_handle, DWORD + void + mono_win32_abort_blocking_io_call (THREAD_INFO_TYPE *info); + +-#define W32_DEFINE_LAST_ERROR_RESTORE_POINT \ ++#else ++ ++ ++#endif ++ ++#ifdef USE_WINDOWS_BACKEND ++ ++/* APC calls can change GetLastError while a thread is suspended. Save/restore it when doing thread ++ state transitions (for example in m2n wrappers) in order to protect the result of the last ++ pinvoke */ ++ ++#define MONO_DEFINE_LAST_ERROR_RESTORE_POINT \ + const DWORD _last_error_restore_point = GetLastError (); + +-#define W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT \ ++#define MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT \ + /* Only restore if changed to prevent unnecessary writes. */ \ + if (GetLastError () != _last_error_restore_point) \ + mono_SetLastError (_last_error_restore_point); + ++#elif defined(USE_WASM_BACKEND) || defined (USE_POSIX_BACKEND) ++ ++#define MONO_DEFINE_LAST_ERROR_RESTORE_POINT \ ++ int _last_errno_restore_point = errno; ++ ++#define MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT \ ++ if (errno != _last_errno_restore_point) \ ++ errno = _last_errno_restore_point; ++ ++/* Posix semaphores set errno on failure and sporadic wakeup. GC state transitions are done in n2m ++ * and m2n wrappers and may change the value of errno from the last pinvoke. Use these macros to ++ * save/restore errno when doing thread state transitions. */ ++ ++#elif defined(USE_MACH_BACKEND) ++ ++/* Mach semaphores don't set errno on failure. Change this to be the same as POSIX if some other primitives used ++ in thread state transitions pollute errno. */ ++ ++#define MONO_DEFINE_LAST_ERROR_RESTORE_POINT /* nothing */ ++#define MONO_RESTORE_LAST_ERROR_FROM_RESTORE_POINT /* nothing */ ++ + #else +- +-#define W32_DEFINE_LAST_ERROR_RESTORE_POINT /* nothing */ +-#define W32_RESTORE_LAST_ERROR_FROM_RESTORE_POINT /* nothing */ +- ++#error "unknown threads backend, not sure how to save/restore last error" + #endif + ++ ++ + #endif /* __MONO_THREADS_H__ */ +-- +2.38.4 + diff --git a/user/dotnet8-build/runtime_82173-add-cmake-check-for-ioclt-prototype.patch b/user/dotnet8-build/runtime_82173-add-cmake-check-for-ioclt-prototype.patch new file mode 100644 index 0000000..d429eeb --- /dev/null +++ b/user/dotnet8-build/runtime_82173-add-cmake-check-for-ioclt-prototype.patch @@ -0,0 +1,81 @@ +From 8d085a4867cb28a24a6f87379df7b4eac6f4712d Mon Sep 17 00:00:00 2001 +Patch-Source: https://github.com/dotnet/runtime/pull/82173 +From: Adeel <3840695+am11@users.noreply.github.com> +Date: Wed, 15 Feb 2023 17:53:20 +0200 +Subject: [PATCH 1/2] Add cmake check for ioclt prototype + +--- + src/native/libs/Common/pal_config.h.in | 1 + + src/native/libs/System.Native/pal_io.c | 4 ++++ + src/native/libs/configure.cmake | 7 +++++++ + 3 files changed, 12 insertions(+) + +diff --git a/src/runtime/src/native/libs/Common/pal_config.h.in b/src/runtime/src/native/libs/Common/pal_config.h.in +index 7b592d10326f6..a5ce0ce2a46d4 100644 +--- a/src/runtime/src/native/libs/Common/pal_config.h.in ++++ b/src/runtime/src/native/libs/Common/pal_config.h.in +@@ -43,6 +43,7 @@ + #cmakedefine01 PRIORITY_REQUIRES_INT_WHO + #cmakedefine01 KEVENT_REQUIRES_INT_PARAMS + #cmakedefine01 HAVE_IOCTL ++#cmakedefine01 HAVE_IOCTL_WITH_INT_REQUEST + #cmakedefine01 HAVE_TIOCGWINSZ + #cmakedefine01 HAVE_TIOCSWINSZ + #cmakedefine01 HAVE_SCHED_GETAFFINITY +diff --git a/src/runtime/src/native/libs/System.Native/pal_io.c b/src/runtime/src/native/libs/System.Native/pal_io.c +index 22fcf3a4f7691..b89bbbbeeaf4b 100644 +--- a/src/runtime/src/native/libs/System.Native/pal_io.c ++++ b/src/runtime/src/native/libs/System.Native/pal_io.c +@@ -1325,7 +1325,11 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t + // Try copying data using a copy-on-write clone. This shares storage between the files. + if (sourceLength != 0) + { ++#if HAVE_IOCTL_WITH_INT_REQUEST + while ((ret = ioctl(outFd, (int)FICLONE, inFd)) < 0 && errno == EINTR); ++#elif ++ while ((ret = ioctl(outFd, FICLONE, inFd)) < 0 && errno == EINTR); ++#endif + copied = ret == 0; + } + #endif +diff --git a/src/runtime/src/native/libs/configure.cmake b/src/runtime/src/native/libs/configure.cmake +index 0b86bd6df64ed..cbaac692f2630 100644 +--- a/src/runtime/src/native/libs/configure.cmake ++++ b/src/runtime/src/native/libs/configure.cmake +@@ -790,6 +790,13 @@ check_prototype_definition( + ${STATFS_INCLUDES} + HAVE_NON_LEGACY_STATFS) + ++check_prototype_definition( ++ ioctl ++ "int ioctl(int fd, int request, ...)" ++ 0 ++ "sys/ioctl.h" ++ HAVE_IOCTL_WITH_INT_REQUEST) ++ + check_c_source_compiles( + " + #include + +From 349e0494a215a372538f6671d6f671c18f594f53 Mon Sep 17 00:00:00 2001 +From: Adeel Mujahid <3840695+am11@users.noreply.github.com> +Date: Wed, 15 Feb 2023 18:07:42 +0200 +Subject: [PATCH 2/2] . + +--- + src/native/libs/System.Native/pal_io.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/runtime/src/native/libs/System.Native/pal_io.c b/src/runtime/src/native/libs/System.Native/pal_io.c +index b89bbbbeeaf4b..7551b426d0b84 100644 +--- a/src/runtime/src/native/libs/System.Native/pal_io.c ++++ b/src/runtime/src/native/libs/System.Native/pal_io.c +@@ -1327,7 +1327,7 @@ int32_t SystemNative_CopyFile(intptr_t sourceFd, intptr_t destinationFd, int64_t + { + #if HAVE_IOCTL_WITH_INT_REQUEST + while ((ret = ioctl(outFd, (int)FICLONE, inFd)) < 0 && errno == EINTR); +-#elif ++#else + while ((ret = ioctl(outFd, FICLONE, inFd)) < 0 && errno == EINTR); + #endif + copied = ret == 0; diff --git a/user/dotnet8-build/runtime_82676-make-pal-console-c-use-int.patch b/user/dotnet8-build/runtime_82676-make-pal-console-c-use-int.patch new file mode 100644 index 0000000..2252b6a --- /dev/null +++ b/user/dotnet8-build/runtime_82676-make-pal-console-c-use-int.patch @@ -0,0 +1,26 @@ +From 86033acaa1dbc61833142ffa60cee0f1a0fb4a14 Mon Sep 17 00:00:00 2001 +Patch-Source: https://github.com/dotnet/runtime/pull/82676 +From: Antoine Martin +Date: Sat, 25 Feb 2023 14:39:43 -0500 +Subject: [PATCH] pal_console.c: cast TIOCSWINSZ to int when + HAVE_IOCTL_WITH_INT_REQUEST + +--- + src/native/libs/System.Native/pal_console.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/runtime/src/native/libs/System.Native/pal_console.c b/src/runtime/src/native/libs/System.Native/pal_console.c +index d217075e5..52241f47d 100644 +--- a/src/runtime/src/native/libs/System.Native/pal_console.c ++++ b/src/runtime/src/native/libs/System.Native/pal_console.c +@@ -43,7 +43,9 @@ int32_t SystemNative_SetWindowSize(WinSize* windowSize) + { + assert(windowSize != NULL); + +-#if HAVE_IOCTL && HAVE_TIOCSWINSZ ++#if HAVE_IOCTL_WITH_INT_REQUEST && HAVE_TIOCSWINSZ ++ return ioctl(STDOUT_FILENO, (int)TIOCSWINSZ, windowSize); ++#elif HAVE_IOCTL && HAVE_TIOCSWINSZ + return ioctl(STDOUT_FILENO, TIOCSWINSZ, windowSize); + #else + // Not supported on e.g. Android. Also, prevent a compiler error because windowSize is unused