diff --git a/user/dotnet8-stage0/APKBUILD b/user/dotnet8-stage0/APKBUILD index 1e8f080..00ee6f3 100644 --- a/user/dotnet8-stage0/APKBUILD +++ b/user/dotnet8-stage0/APKBUILD @@ -3,7 +3,7 @@ pkgname=dotnet8-stage0 pkgver=8.0.100_pre1 -pkgrel=0 +pkgrel=1 [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" @@ -14,6 +14,7 @@ _gittag=v8.0.100-preview.1 _artifactsver=0.1.0-8.0.100-5.centos.8-x64 _prebuiltsver=0.1.0-8.0.100-4.centos.8-x64 _bootstrapver="8.0.100-preview.1.23115.2" +_bootstraprel=0 _installerver=$_bootstrapver # Version of packages that aren't defined in git-info or badly defined @@ -28,6 +29,9 @@ _patches=" installer_runtimepacks.patch roslyn_allow-extra-params.patch runtime_76500-properly-set-toolchain-for-alpine.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_make-lld-use-depend-on-existing-on-target.patch runtime_mono-thread-coop-undefine-fortify-source.patch runtime_no-additional-runtime-id.patch @@ -39,6 +43,8 @@ _extra_nupkgs=" https://globalcdn.nuget.org/packages/microsoft.netcore.app.host.linux-musl-x64.7.0.2.nupkg https://globalcdn.nuget.org/packages/microsoft.netcore.app.host.linux-musl-arm64.7.0.2.nupkg https://globalcdn.nuget.org/packages/microsoft.netcore.app.host.linux-musl-arm.7.0.2.nupkg + https://lab.ilot.io/ayakael/repo-apk/-/raw/edge/archives/Microsoft.NETCore.App.Host.linux-musl-ppc64le.7.0.2.nupkg + https://lab.ilot.io/ayakael/repo-apk/-/raw/edge/archives/Microsoft.NETCore.App.Host.linux-musl-s390x.7.0.2.nupkg " _pkgver_macro=${pkgver%.*} @@ -48,8 +54,7 @@ pkgdesc="The .NET Core stage0 bits for dotnet build" # 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" options="!check" # Testsuite in main -build aport @@ -59,9 +64,11 @@ subpackages=" " source=" https://lab.ilot.io/dotnet/dotnet/-/releases/$_gittag/downloads/tarball/dotnet-$_gittag.tar.xz - dotnet-sdk-$_bootstrapver-linux.musl.x64.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-x64.tar.gz - dotnet-sdk-$_bootstrapver-linux.musl.arm64.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm64.tar.gz - dotnet-sdk-$_bootstrapver-linux.musl.arm.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm.tar.gz + dotnet-sdk-$_bootstrapver-linux-musl-x64.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-x64.tar.gz + dotnet-sdk-$_bootstrapver-linux-musl-arm64.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm64.tar.gz + dotnet-sdk-$_bootstrapver-linux-musl-arm.noextract::https://dotnetbuilds.azureedge.net/public/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm.tar.gz + dotnet-sdk-$_bootstrapver-r$_bootstraprel-linux-musl-ppc64le.noextract::https://lab.ilot.io/ayakael/dotnet-stage0/-/releases/$_bootstrapver-r$_bootstraprel/downloads/sdk/dotnet-sdk-$_bootstrapver-r$_bootstraprel-linux-musl-ppc64le.tar.xz + dotnet-sdk-$_bootstrapver-r$_bootstraprel-linux-musl-s390x.noextract::https://lab.ilot.io/ayakael/dotnet-stage0/-/releases/$_bootstrapver-r$_bootstraprel/downloads/sdk/dotnet-sdk-$_bootstrapver-r$_bootstraprel-linux-musl-s390x.tar.xz Private.SourceBuilt.Artifacts.$_artifactsver.noextract::https://dotnetcli.azureedge.net/source-built-artifacts/assets/Private.SourceBuilt.Artifacts.$_artifactsver.tar.gz Private.SourceBuilt.Prebuilts.$_prebuiltsver.noextract::https://dotnetcli.azureedge.net/source-built-artifacts/assets/Private.SourceBuilt.Prebuilts.$_prebuiltsver.tar.gz $_extra_nupkgs @@ -182,16 +189,6 @@ snapshot() { prepare() { default_prepare - # 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 - # adjusts sdk version and packagedir to expected for i in runtime sdk installer aspnetcore roslyn; do sed "s|@@PACKAGESDIR@@|$_packagesdir|" -i "$builddir"/src/$i/NuGet.config @@ -214,7 +211,7 @@ prepare() { ln -s "$_logdir"/${i##*\/} "$builddir"/src/${i##*\/}/artifacts/log done - tar --use-compress-program="pigz" -xf "$srcdir"/dotnet-sdk-$_pkgver_macro*$_dotnet_arch.noextract -C "$_cli_root" --no-same-owner + tar --use-compress-program="pigz" -xf "$srcdir"/dotnet-sdk-$_pkgver_macro*$_dotnet_arch*noextract -C "$_cli_root" --no-same-owner for i in $_extra_nupkgs; do $_nuget push "$srcdir"/${i##*/} --source="$_packagesdir" @@ -506,19 +503,26 @@ artifacts() { sha512sums=" f48d4168f526aade888bbd17f2da87f721dabc8ae004707ef9195b6359b79b871115a686678c87542ba74e1d86e5485df13d77ef4d3f4001c0804426aebaf92c dotnet-v8.0.100-preview.1.tar.xz -120048fce7c455cb2f98cbdda6b7f789f210d9e7e0b48304f8fdc8b4838c705c6af18b2b4c375b57aa48e0e5084e60ecefad0edc09c19aca166855b3dd3fb539 dotnet-sdk-8.0.100-preview.1.23115.2-linux.musl.x64.noextract -bf985c3b9c1f6f09f46f88527c54445c502e7c75dcbc004dccfb5339d0b5766290ff183abe3808919137ebc5a50c91cbd58a56ec31ad50a5e39a26671e990c61 dotnet-sdk-8.0.100-preview.1.23115.2-linux.musl.arm64.noextract -461094d1f53067c2b496ec25b1bf7686aee3a75f0de5a139bb29a3ac989cdb824367165c8385b78185414430f0579bbba8c94be6d511d793a16746dc018f232f dotnet-sdk-8.0.100-preview.1.23115.2-linux.musl.arm.noextract +120048fce7c455cb2f98cbdda6b7f789f210d9e7e0b48304f8fdc8b4838c705c6af18b2b4c375b57aa48e0e5084e60ecefad0edc09c19aca166855b3dd3fb539 dotnet-sdk-8.0.100-preview.1.23115.2-linux-musl-x64.noextract +bf985c3b9c1f6f09f46f88527c54445c502e7c75dcbc004dccfb5339d0b5766290ff183abe3808919137ebc5a50c91cbd58a56ec31ad50a5e39a26671e990c61 dotnet-sdk-8.0.100-preview.1.23115.2-linux-musl-arm64.noextract +461094d1f53067c2b496ec25b1bf7686aee3a75f0de5a139bb29a3ac989cdb824367165c8385b78185414430f0579bbba8c94be6d511d793a16746dc018f232f dotnet-sdk-8.0.100-preview.1.23115.2-linux-musl-arm.noextract +727be7a0c753a72635d22044fef7fea4389294fce01a63638f7a6fdb1b18481737969b1ff2a666ac1b84c1d48434f3505b80ffdf8e56d4224c92c1db34f8a154 dotnet-sdk-8.0.100-preview.1.23115.2-r0-linux-musl-ppc64le.noextract +6f2ff2b7e7c1eaac7af2a80684c361357313ccbc2c2572ee0ee495b63507192ab27b0aab61de8557a7afd18d8073b44a823f4d6fbbdc75c3058eeb0517ad52e6 dotnet-sdk-8.0.100-preview.1.23115.2-r0-linux-musl-s390x.noextract bb40f2fcd6f51e908e68fce740400345f2b3ee9c66c1cc69116b4188a19bb0f510e96c8ddcf99e03ee35d16f95ac0b918f940317cb7a5dd858682c4483d3c93b Private.SourceBuilt.Artifacts.0.1.0-8.0.100-5.centos.8-x64.noextract f20d22a4d069c3647433def852dba50e803a494f4a9f455c24baff8e259896ec709ebcd2a80a1716a9b582ad0d36cd4be98ee4918b0349cca46cea0643a1a9d8 Private.SourceBuilt.Prebuilts.0.1.0-8.0.100-4.centos.8-x64.noextract 5c1fd9e250e7f08d996b7b335134973624a8d1afc331f7fda3a81eee7d2170e39905be20b8786e99078892b21d1582092aeee45d49c5feae3b2bd5374c306fec microsoft.netcore.app.host.linux-musl-x64.7.0.2.nupkg c5bb986179b4789a24cc4552fa33bee2015acba1c9775ff8fe2295797dd7114f244df2c133e8cee8a3de392c5c47530ba9ef87939cc55660f8c937146b98e1fb microsoft.netcore.app.host.linux-musl-arm64.7.0.2.nupkg 2f35742d74255dd6e7a39e48f29e01cead2b410dabd9e4192d724186a8bd2e04f970b5015229045c732e6c7bcd89a8e9787d19fc50f09fcaab8cd94516f5a0ce microsoft.netcore.app.host.linux-musl-arm.7.0.2.nupkg +f3296b92c91ff76d3238af8414e5e1b4729f641b7c9d25539e5399a472c828b23851fb3241b7c3ba9fc691be0ac2dacd3f7efefc66207920574eda066d76cb9d Microsoft.NETCore.App.Host.linux-musl-ppc64le.7.0.2.nupkg +8e8dfc7184516f3e4ef4e43540fb403ec6066237e0596953cff5c49accaa811ad72f0286c52b2f03871adb9b24194cf4922bbcce05c2bb5caa8bcbd790013dde Microsoft.NETCore.App.Host.linux-musl-s390x.7.0.2.nupkg 9c2f5410c2983ae1d073a5efb78afa56b212165a18252400a42696e10d8cb6016fde5941d1f453eb5332a77f5e209bcb5d40b8ee142609232be95b0cdca1e060 aspnetcore_use-linux-musl-crossgen-on-non-x64.patch ead38430e54530819ecdb7ab5b087707eee97c4e77b5011a42758352e8265417c65f07b4eec2488708d932de240877695b474e07b8984d34086ef539d5022830 build_set-local-repo.patch 9fe4494b291128469874147e5f28f8fbd023b014114f0aa151fa5cf57821318fa88b834a131eeb77478c8c87adca8c1c0ff3e8c59264c7394fd0621a520eb014 installer_runtimepacks.patch d1811c1364d9ce4d180d61adf8a9074cf71cf854776959a6db98740f17ed75beec8536602cfb335f534a703d3917e43c3cd91f0f6aed68b5d40c1c80396f5908 roslyn_allow-extra-params.patch ba9c66b5bb8b8d2de87922717b8a7a6f880eed2a38b5208a554ebd64841c6053658692463471a26442c85cb9adb94043a9d91190786d46c0f45ff4e7cc9c707e runtime_76500-properly-set-toolchain-for-alpine.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 946f7ddc979bced4e2991f0fe768476b537c97d864362d105fcaec9e6f9f312a798e5e19312966f29fdd80593aa88870be5747b74172d9a70bb1b173c3c75a43 runtime_make-lld-use-depend-on-existing-on-target.patch d732df247c721c9f677baabdd7f36dbf4b564814ff64164361065bb1c196b767494a1d39f634eadf01a23032c7b3e64102614b7213065c81096bbf3f8022e6a0 runtime_mono-thread-coop-undefine-fortify-source.patch 1de4459522525e1d570e219c9ef067fbbf8745ad369602a006ea62cbafa0f64d2b01b63e00147cf8fed0ea9764373fb4c66aae2323b43a34447990a24f9f29c3 runtime_no-additional-runtime-id.patch diff --git a/user/dotnet8-stage0/README.md b/user/dotnet8-stage0/README.md index 9bce6c4..5c5d237 100644 --- a/user/dotnet8-stage0/README.md +++ b/user/dotnet8-stage0/README.md @@ -1,17 +1,17 @@ -# dotnet7-stage0 +# dotnet8-stage0 -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` (empty package to go around `buildrepo` build ordering bug) -* `dotnet7-stage0-bootstrap` (packages binary bootstrap artifacts) -* `dotnet7-stage0-artifacts` (packages non-binary bootstrap artifacts) +* `dotnet8` (empty package to go around `buildrepo` build ordering bug) +* `dotnet8-stage0-bootstrap` (packages binary bootstrap artifacts) +* `dotnet8-stage0-artifacts` (packages non-binary bootstrap artifacts) -## 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) @@ -22,17 +22,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: @@ -44,7 +44,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 ``` @@ -53,7 +53,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 @@ -69,7 +69,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. @@ -81,10 +81,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. @@ -99,7 +99,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 @@ -120,10 +120,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-stage0/runtime_79856-save-errno-when-using-posix-semaphores.patch b/user/dotnet8-stage0/runtime_79856-save-errno-when-using-posix-semaphores.patch new file mode 100644 index 0000000..4d451b7 --- /dev/null +++ b/user/dotnet8-stage0/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-stage0/runtime_82173-add-cmake-check-for-ioclt-prototype.patch b/user/dotnet8-stage0/runtime_82173-add-cmake-check-for-ioclt-prototype.patch new file mode 100644 index 0000000..d429eeb --- /dev/null +++ b/user/dotnet8-stage0/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-stage0/runtime_82676-make-pal-console-c-use-int.patch b/user/dotnet8-stage0/runtime_82676-make-pal-console-c-use-int.patch new file mode 100644 index 0000000..2252b6a --- /dev/null +++ b/user/dotnet8-stage0/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