Merge branch 'dotnet7/initial-317' into 'v3.17'

[3.17] user/dotnet7: new aport

See merge request ayakael/user-aports!17
This commit is contained in:
Antoine Martin 2023-02-22 23:04:29 +00:00
commit da96e55577
15 changed files with 3306 additions and 0 deletions

529
user/dotnet7-build/APKBUILD Normal file
View file

@ -0,0 +1,529 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# secfixes:
# 7.0.103-r0:
# - CVE-2023-21808
pkgname=dotnet7-build
pkgver=7.0.103
pkgrel=0
_gittag=v$pkgver
_giturl="https://github.com/dotnet/installer"
_testtag=16c3c04f3ae6620a474fa0474e8b298190e506c1
_bunnytag=v12
_patches="
build_disable-source-link.patch
build_enable-timestamps.patch
build_shutdown-build-servers-at-each-build-step.patch
check_rid-alpine-generation.diff
roslyn-analyzer_disable-apphost.patch
runtime_76500-mono-musl-support.patch
runtime_enable-runtime-marshalling.diff
runtime_enable-system-libunwind.diff
runtime_mono-thread-coop-undefine-fortify-source.patch
sdk_14239-add-zsh-compdef-completion-script.patch
"
_pkgver_macro=${pkgver%.*}
_pkgver_prior=${pkgver%.*.*}
_pkgver_name=${_pkgver_macro//[.0]}
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
arch="all !x86 !armhf !riscv64"
url=https://dotnet.microsoft.com
license="MIT"
# hack for dotnetx-build to be able to pull itself for bootstrapping
provides="dotnet$_pkgver_name-bootstrap"
provider_priority=$_pkgver_prior
checkdepends="
babeltrace
binutils
coreutils
file
gawk
jq
lttng-tools
npm
procps
sed
strace
util-linux-misc
which
"
makedepends="
bash
clang
cmake
dotnet$_pkgver_name-bootstrap
dotnet$_pkgver_name-bootstrap-artifacts
dotnet$_pkgver_name-stage0
findutils
git
grep
icu-data-full
icu-dev
inetutils-syslogd
krb5-dev
libgit2-dev
libintl
libucontext-dev
libunwind-dev
libxml2-dev
libxml2-utils
linux-headers
lldb-dev
llvm-dev
lttng-ust-dev
nodejs
numactl-dev
openssl-dev
pigz
rsync
samurai
tar
xz
zlib-dev
"
case $CARCH in
s390x|x86) ;;
*) makedepends="$makedepends lld-dev";;
esac
subpackages="
dotnet$_pkgver_name-artifacts:artifacts:noarch
dotnet$_pkgver_name-sdk
dotnet$_pkgver_name-templates:templates:noarch
dotnet-zsh-completion:zshcomp:noarch
dotnet-bash-completion:bashcomp:noarch
dotnet-doc
netstandard21-targeting-pack:netstandard_targeting_pack:noarch
"
source="
https://lab.ilot.io/dotnet/installer/-/releases/$_gittag/downloads/tarball/dotnet-$_gittag.tar.xz
dotnet-testsuite-$_testtag.tar.gz::https://github.com/redhat-developer/dotnet-regular-tests/archive/$_testtag.tar.gz
dotnet-bunny-$_bunnytag.tar.gz::https://github.com/redhat-developer/dotnet-bunny/archive/$_bunnytag.tar.gz
$_patches
"
builddir="$srcdir"/dotnet-$_gittag
_checkdir="$srcdir"/dotnet-bunny-${_bunnytag/v}
_testdir="$srcdir"/dotnet-regular-tests-$_testtag
_cli_root="$srcdir"/bootstrap
_libdir="/usr/lib"
# if true, then within pipeline environment, in which case send logs there
# to be scooped
if [ -d "$APORTSDIR/logs" ]; then
_logdir="$APORTSDIR"/logs/$pkgname
else
_logdir="$srcdir"/logs
fi
case $CARCH in
x86_64) _dotnet_arch="x64";;
aarch64) _dotnet_arch="arm64";;
armv7) _dotnet_arch="arm";;
armhf) _dotnet_arch="armv6";;
*) _dotnet_arch="$CARCH";;
esac
# Build doesn't set all the right executable bits for the right file types
_fix_executable() {
# add executable bit
find "$1" -type f \( \
-name 'apphost' -o \
-name 'singlefilehost' -o \
-name 'lib*so' \
\) \
-exec chmod +x '{}' \;
# remove executable bit
find "$1" -type f \( \
-name '*.a' -o \
-name '*.dll' -o \
-name '*.h' -o \
-name '*.json' -o \
-name '*.pdb' -o \
-name '*.props' -o \
-name '*.pubxml' -o \
-name '*.targets' -o \
-name '*.txt' -o \
-name '*.xml' \
\) \
-exec chmod -x '{}' \;
}
# generates tarball containing all components built by dotnet
snapshot() {
local _pkg="$srcdir"/${builddir##*/}.tar
ulimit -n 4096
if [ -d "$srcdir" ]; then
cd "$srcdir"
else
mkdir -p "$srcdir" && cd "$srcdir"
fi
if [ -d "installer" ]; then
cd "$srcdir"/installer
else
git clone $_giturl --branch $_gittag && cd "$srcdir"/installer
fi
sed 's|<Exec Command="tar.*|<Exec Command="tar -cf $(TarballFilePath) -C $(TarballDir)/.. $([MSBuild]::MakeRelative($([System.IO.Path]::GetDirectoryName($(TarballDir))), $(TarballDir)))" />|' -i src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
if [ -d "$_libdir/dotnet/bootstrap" ]; then
local _cli_root="$(find $_libdir/dotnet/bootstrap/${_pkgver_macro}* -maxdepth 0 -type d | sort -r | head -n 1)"
else
local _cli_root=""
fi
_InitializeDotNetCli="$_cli_root" DOTNET_INSTALL_DIR="$_cli_root" DotNetBuildFromSource=true ./build.sh \
/p:ArcadeBuildTarball=true \
/p:TarballDir=$builddir \
/p:TarballFilePath=$_pkg
msg "Compressing ${builddir##*/}.tar to $SRCDEST"
xz -T0 -9 -vv -e -c > "$SRCDEST"/${builddir##*/}.tar.xz < "$_pkg"
cd "$startdir"
abuild checksum
}
prepare() {
default_prepare
# check patches
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
aarch64|armv7) msg "Using bundled libunwind";;
armhf|s390x|ppc64le) msg "No libunwind used";;
*)
msg "Using system libunwind"
patch -p1 -i "$srcdir"/runtime_enable-system-libunwind.diff
;;
esac
# ensure that dotnet does not download artifacts provided by dotnet-artifacts
rm -rf "$builddir"/packages/archive
# links logfiles to pipeline logs for easy pickup in pipelines
mkdir -p "$_logdir" "$builddir"/artifacts
ln -s "$_logdir" "$builddir"/artifacts/logs
ln -s "$_logdir" "$builddir"/artifacts/log
for i in "$builddir"/src/*; do
if [ -f "$i" ]; then
continue
fi
mkdir -p "$_logdir"/${i##*\/} "$builddir"/src/${i##*\/}/artifacts
ln -s "$_logdir"/${i##*\/} "$builddir"/src/${i##*\/}/artifacts/log
done
# dotnet requires its bootstrap to be in a writable dir
msg "Setting up bootstrap"
local _bootstrapdir=$(find $_libdir/dotnet/bootstrap/$_pkgver_macro* -maxdepth 0 | sort -r | head -n 1)
if [ ! -d "$_cli_root" ]; then
cp -r "$_bootstrapdir" "$_cli_root"
fi
}
build() {
msg "Building $pkgname-$pkgver"
ulimit -n 4096
# Disable use of LTTng as tracing on lttng <=2,13,0 is broken
# See https://github.com/dotnet/runtime/issues/57784.
if [ -f "/usr/lib/liblttng-ust.so.1 " ]; then
export DOTNET_LTTng=0
fi
# looks for most recent recent version of _artifactsdir
local _artifactsdir=$(find $_libdir/dotnet/artifacts/$_pkgver_macro* -maxdepth 0 | sort -r | head -n 1)
# ci args, else the output is forwarded to log files which isn't ideal in a
# pipeline environment, and build by defaults uses lots of space
local args="
/v:minimal
/p:LogVerbosity=minimal
/p:MinimalConsoleLogOutput=true
/p:CleanWhileBuilding=true
"
# part of https://github.com/dotnet/installer/pull/14792 that sets this flag
# was not integrated in 7.0.1xx yet
case $CARCH in
s390x|ppc64le) local args="$args /p:SourceBuildUseMonoRuntime=true";;
esac
# Sets TargetRid manually as dotnet cannot be trusted to reliably compute
# the machine's runtime ID between releases.
# shellcheck disable=SC2034
. /etc/os-release
local VERSION_ID_DOT="${VERSION_ID//[^.]}"
while [ ${#VERSION_ID_DOT} -gt 1 ]; do
local VERSION_ID="${VERSION_ID%.*}"
local VERSION_ID_DOT="${VERSION_ID//[^.]}"
done
local VERSION_ID_DASH="${VERSION_ID//[^_]}"
while [ ${#VERSION_ID_DASH} -ge 1 ]; do
local VERSION_ID="${VERSION_ID%_*}"
local VERSION_ID_DASH="${VERSION_ID//[^_]}"
done
local args="$args /p:TargetRid=$ID.$VERSION_ID-$_dotnet_arch"
./build.sh \
--with-sdk "$_cli_root" \
--with-packages "$_artifactsdir" \
-- $args
}
check() {
ulimit -n 4096
# Tests timeout (in seconds)
local _tests_timeout=1000
# Test suite disable flags
# following tests can only work after packaging step
local _disabled_tests="man-pages distribution-package bash-completion install-location release-version-sane"
# test broken: permission issue on lxc / pipelines
local _disabled_tests="$_disabled_tests createdump-aspnet workload"
# liblttng-ust_sys-sdt.h: no 'NT_STAPSDT' on Alpine's lttng-ust package
# lttng: known issue, see https://github.com/dotnet/runtime/issues/57784
local _disabled_tests="$_disabled_tests liblttng-ust_sys-sdt.h lttng"
# {bundled,system}-libunwind: use system version on all but aarch64/armv7, as broken
# see https://github.com/redhat-developer/dotnet-regular-tests/issues/113
# disable on mono-flavored runtime as mono does not use libunwind
case $CARCH in
armv7|aarch64) local _disabled_tests="$_disabled_tests system-libunwind";;
s390x|ppc64le|armhf) local _disabled_tests="$_disabled_tests bundled-libunwind system-libunwind";;
*) local _disabled_tests="$_disabled_tests bundled-libunwind";;
esac
# test unit broken currently
_disabled_tests="$_disabled_tests system-libunwind"
# nativeaot is not supported on armv7
case $CARCH in
armv7) local _disabled_tests="$_disabled_tests nativeaot"
esac
msg "Unpacking produced dotnet"
export DOTNET_ROOT="$_checkdir/release"
if [ ! -d "$DOTNET_ROOT" ]; then
mkdir -p "$DOTNET_ROOT"
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$DOTNET_ROOT" \
--no-same-owner
fi
export PATH="$DOTNET_ROOT:$PATH"
# some files either should or should not have executable bits
# (done again during packaging - this is for tests)
_fix_executable "$DOTNET_ROOT"
msg "Building turkey test suite"
if [ ! -d "$_checkdir"/turkey ]; then
cd "$_checkdir"/Turkey
dotnet publish -f netcoreapp3.1 -c Release -p:VersionPrefix=1 -p:VersionSuffix="$(git rev-parse --short HEAD)" -o "$_checkdir"/turkey
fi
msg "Running test suite"
cd "$_testdir"
for i in $_disabled_tests; do
if [ -d "$i" ]; then
sed -i 's|"enabled": true|"enabled": false|' $i/test.json
fi
done
dotnet "$_checkdir"/turkey/Turkey.dll -t $_tests_timeout || local ERROR=true
if [ $ERROR ]; then
msg "Check error reported, dumping logs"
for i in *.log; do
msg "Dumping $i"
cat "$i"
done
fi
}
package() {
# directory creation
install -dm 755 \
"$pkgdir"/$_libdir/dotnet/bootstrap/$pkgver \
"$pkgdir"/usr/share/man/man1 \
"$pkgdir"/$_libdir/dotnet/artifacts/$pkgver
# unpack sdk to bootstrap
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$pkgdir"/$_libdir/dotnet/bootstrap/$pkgver/ \
--no-same-owner
# extract arch-specific artifacts to artifacts dir for use by future dotnet builds
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/Private.SourceBuilt.Artifacts.*.tar.gz \
-C "$pkgdir"/$_libdir/dotnet/artifacts/$pkgver/ \
--no-same-owner \
--wildcards \
'*alpine*'
# assemble docs
find "$builddir" -iname 'dotnet*.1' -type f -exec cp '{}' "$pkgdir"/usr/share/man/man1/. \;
# some files either should or should not have executable bits
_fix_executable "$pkgdir"
# Disable use of LTTng as tracing on lttng <=2,13,0 is broken
# See https://github.com/dotnet/runtime/issues/57784.
if [ -f "/usr/lib/liblttng-ust.so.1 " ]; then
rm "$pkgdir"/$_libdir/dotnet/bootstrap/*/shared/Microsoft.NETCore.App/*/libcoreclrtraceptprovider.so
fi
}
sdk() {
pkgdesc="The .NET $_pkgver_macro SDK"
# libucontext isn't automatically detected on all platforms
depends="
aspnetcore$_pkgver_name-runtime
aspnetcore$_pkgver_name-targeting-pack
dotnet$_pkgver_name-apphost-pack
dotnet$_pkgver_name-targeting-pack
dotnet$_pkgver_name-templates
netstandard21-targeting-pack
libucontext
"
provides="
dotnet-sdk-$_pkgver_macro=$pkgver-r$pkgrel
dotnet$_pkgver_name-dev=$pkgver-r$pkgrel
"
install -dm 755 "$subpkgdir"/$_libdir/dotnet
# sdk
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$subpkgdir"/$_libdir/dotnet/ \
--no-same-owner \
./sdk ./sdk-manifests
# some files either should or should not have executable bits
_fix_executable "$subpkgdir"
# See https://github.com/dotnet/source-build/issues/2579
find "$subpkgdir" -type f -name 'testhost.x86' -delete
find "$subpkgdir" -type f -name 'vstest.console' -delete
}
netstandard_targeting_pack() {
pkgdesc="The .NET 2.1 Standard targeting pack"
depends="dotnet-host"
provides="netstandard-targeting-pack-2.1=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet/packs
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$subpkgdir"/$_libdir/dotnet/ \
--no-same-owner \
./packs/NETStandard.Library.Ref
# some files either should or should not have executable bits
_fix_executable "$subpkgdir"
}
templates() {
pkgdesc="The .NET $_pkgver_macro templates"
depends="dotnet-host"
provides="dotnet-templates-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$subpkgdir"/$_libdir/dotnet/ \
--no-same-owner \
./templates
# some files either should or should not have executable bits
_fix_executable "$subpkgdir"
}
artifacts() {
pkgdesc="Internal package for building .NET $_pkgver_macro Software Development Kit"
# hack to allow artifacts to pull itself
provides="dotnet$_pkgver_name-bootstrap-artifacts"
provider_priority=$_pkgver_prior
# directory creation
install -dm 755 \
"$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver \
"$subpkgdir"/usr/share/licenses
# extract arch-agnostic artifacts to artifacts dir for use by future dotnet builds
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/Private.SourceBuilt.Artifacts.*.tar.gz \
-C "$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver/ \
--no-same-owner \
--exclude '*Intermediate*' \
--exclude '*alpine*'
}
zshcomp() {
depends=""
pkgdesc="zsh completion for .NET"
# netstandard21-targeting-pack will always be pulled by any dotnetx-sdk
# thus pulling this with it for sdk
install_if="netstandard21-targeting-pack zsh"
depends="dotnet-host"
install -dm 755 "$subpkgdir"/usr/share/zsh/site-functions
install -m 755 "$builddir"/src/sdk/scripts/register-completions.zsh "$subpkgdir"/usr/share/zsh/site-functions/_dotnet
}
bashcomp() {
depends=""
pkgdesc="bash completion for .NET"
# netstandard21-targeting-pack will always be pulled by any dotnetx-sdk
# thus pulling this with it for sdk
install_if="netstandard21-targeting-pack bash-completion"
depends="dotnet-host"
install -dm 755 "$subpkgdir"/usr/share/bash-completion/completions
install -m 755 "$builddir"/src/sdk/scripts/register-completions.bash "$subpkgdir"/usr/share/bash-completion/completions/_dotnet
}
doc() {
default_doc
pkgdesc="Docs for .NET"
# licenses
install -dm 755 "$subpkgdir"/usr/share/licenses/dotnet
tar --use-compress-program="pigz" \
-xf "$builddir"/artifacts/$_dotnet_arch/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$subpkgdir"/usr/share/licenses/dotnet/ \
--no-same-owner \
./LICENSE.txt ./ThirdPartyNotices.txt
}
sha512sums="
1e38ce8024eb4d741b20b00fb315cacd99cf7c2a3dca73ec5cc18a0e407c6c6da075484ca7ddcad899228d1de776f6c3b9b082c02a9fc553e83e1312cf725565 dotnet-v7.0.103.tar.xz
81428356e4b9691c54cacd242368a42d3939732918a608c2a5ae3f23fff45af2d9e981ead70a977f34f4e498c422f708e523bfbbf590cfdafb5c16ef1f0fed8a dotnet-testsuite-16c3c04f3ae6620a474fa0474e8b298190e506c1.tar.gz
0028d5d97b814b122d73137b4e0d64ca5d788aa0ae5fde500de722e23522827f2538f06e75acb17cc39b8917961ee78d1f0bbc84b2b624ae0e9bf88adca2ba6f dotnet-bunny-v12.tar.gz
ebab0364deab5d99131e2724b7fbac668bc27ddf74958623af1913e49850df98b2d077d27324b2bbabbbcdf77ea48bf7a7ca83d0ced6f48bdb66cc1e8bbce4a4 build_disable-source-link.patch
86fbaa058f78bba100f534f4c4bd6d7254181909f70d264c0390d3dd89c878a14ba9b5d2de05271b2c07b73ead70e029488c926221f676d59e27e387e3e579e9 build_enable-timestamps.patch
0049b27fad32f35ee99ef620aeee518600c24bde28c7a146261c7ae4313d747f3bdbe3e8b74a3154e025a80d5c62d545aa226c20c9376599e11091a31390abe6 build_shutdown-build-servers-at-each-build-step.patch
941b430b55e323f723bbc5160447f060f40d18ce32e5803ab7dda16bfc60a0f5ec1dccd246e68475d7115ee265a9433824d8a5d997c302531311194a90deeca9 check_rid-alpine-generation.diff
4ac92d2d9190a55ee20d3e145a28a6953c98d3eb838c8acfb808b8839316443cb64da4a2c5787df0171fce7ef96ff6381043085ed90c23ec09ce9ac81571e675 roslyn-analyzer_disable-apphost.patch
7a3291a05c94986d631a37870f573aca8603e9464cb632b3e5b93eca8a358fc7dcc98a8a8017f566885ceafe462bec734b7d31c7a974270e83c6d2ae54f51902 runtime_76500-mono-musl-support.patch
1f7be536c4826638853f110ee88bbd554be015cc88c6491c1066830789be18ad324f8ed2b1b75ed7aad74457dcafc812730059cb25d36d6344bfae8a517c00c4 runtime_enable-runtime-marshalling.diff
293742ab307bef459a21deadcc4ad7c7996cc4b490910a36c2763b8ad25cc8a91c4e03b6290567cd1030f69638d0156c5b6970887858fb091f8482b67356065d runtime_enable-system-libunwind.diff
d732df247c721c9f677baabdd7f36dbf4b564814ff64164361065bb1c196b767494a1d39f634eadf01a23032c7b3e64102614b7213065c81096bbf3f8022e6a0 runtime_mono-thread-coop-undefine-fortify-source.patch
d1b4ebcbb1a6815fc0ce4c471485c232618e60968a879309fb8336821a9351d2e0028d9f7726c0c041c750b497a0baa47400c78c9ceff550b91b4a6c2816fc41 sdk_14239-add-zsh-compdef-completion-script.patch
"

View file

@ -0,0 +1,145 @@
# dotnet7-build
This is the .NET 7.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)
* `dotnet-zsh-completion`
* `dotnet-bash-completion`
* `dotnet-doc`
* `netstandard21-targeting-pack`
## How to build dotnet7 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)
The goal of `stage0` is to bootstrap dotnet with as little intervention as
possible, thus allowing seamless Alpine upgrades. Unfortunately, upstream only
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.
* `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`
As abuild does not allow different versions for subpackages, a different aport
is required to package runtime bits from dotnet7-build.
## Crossbuilding with `stage0`
Crossbuilding `stage0` is a three step process:
1. Build sysroot for target platform by using `scripts/bootstrap.sh` in aports repo:
```
./bootstrap.sh $CTARGET_ARCH
```
2. Although not necessary, it is recommended to add Alpine repositories to
`$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:
```
CHOST=$CTARGET_ARCH abuild -r
```
# Specification
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`
to match Alpine Linux naming conventions for packages with many installable versions
# Contributing
The steps below are for the final package. Please only contribute to a
pre-release version if you know what you are doing. Original instructions
follow.
## General Changes
1. Fork the main aports repo.
2. Checkout the forked repository.
- `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports`
- `cd community/dotnet7-build`
3. Make your changes. Don't forget to add a changelog.
4. Do local builds.
- `abuild -r`
5. Fix any errors that come up and rebuild until it works locally.
6. Commit the changes to the git repo in a git branch
- `git checkout -b dotnet7/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet7-build: descriptive description'`
- `git push`
7. Create a merge request with your changes, tagging @ayakael for review.
8. Once the tests in the merge-request pass, and reviewers are happy, your changes
will be merged.
## Updating to an new upstream release
1. Fork the main aports repo.
2. Checkout the forked repository.
- `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports`
- `cd community/dotnet7-build`
3. Build the new upstream source tarball. Update the versions in the
APKBUILD file, and then create a snapshot. After build, update checksum.
- `abuild snapshot`
- `abuild checksum`
4. Do local builds.
- `abuild -r`
5. Fix any errors that come up and rebuild until it works locally. Any
patches that are needed at this point should be added to the APKBUILD file
in `_patches` variable.
6. Upload the source archive to a remote location, and update `source` variable.
7. Commit the changes to the git repo in a git branch.
- `git checkout -b dotnet7/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet7-build: upgrade to <new-version>`
- `git push`
8. Create a merge request with your changes, tagging @ayakael for review.
9. Once the tests in the merge-request pass, and reviewers are happy, your changes
will be merged.
# Testing
This package uses CI tests as defined in `check()` function. Creating a
merge-request or running a build will fire off tests and flag any issues.
The tests themselves are contained in this external repository:
https://github.com/redhat-developer/dotnet-regular-tests/

View file

@ -0,0 +1,20 @@
From 98054ea87ce70247bb09ceafd2ad1a0b36d2fef4 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Sat, 1 Oct 2022 09:21:58 -0400
Subject: [PATCH] Disable source link
Addresses undiagnosed "Source control information is not available" error
---
diff --git a/repos/installer.proj b/repos/installer.proj
index 3a9756a27b7..4968184b14e 100644
--- a/repos/installer.proj
+++ b/repos/installer.proj
@@ -26,6 +26,7 @@
-->
<BuildCommandArgs>$(BuildCommandArgs) /p:NETCoreAppMaximumVersion=99.9</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:OSName=$(OSNameOverride)</BuildCommandArgs>
+ <BuildCommandArgs>$(BuildCommandArgs) /p:EnableSourceLink=false</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:PortableOSName=$(PortableOS)</BuildCommandArgs>
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux'">$(BuildCommandArgs) /p:Rid=$(TargetRid)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:DOTNET_INSTALL_DIR=$(DotNetCliToolDir)</BuildCommandArgs>

View file

@ -0,0 +1,40 @@
diff --git a/repos/Directory.Build.props b/repos/Directory.Build.props
index b70a3161fef..d57f9393299 100644
--- a/repos/Directory.Build.props
+++ b/repos/Directory.Build.props
@@ -134,6 +134,7 @@
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) $(FlagParameterPrefix)pack</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) $(FlagParameterPrefix)publish</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) -bl</StandardSourceBuildArgs>
+ <StandardSourceBuildArgs>$(StandardSourceBuildArgs) /consoleLoggerParameters:ShowTimestamp</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:ArcadeBuildFromSource=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:CopyWipIntoInnerSourceBuildRepo=true</StandardSourceBuildArgs>
<StandardSourceBuildArgs>$(StandardSourceBuildArgs) /p:DotNetBuildOffline=true</StandardSourceBuildArgs>
diff --git a/src/fsharp/eng/build.sh b/src/fsharp/eng/build.sh
index fff8414b3ef..d470fc6ed56 100755
--- a/src/fsharp/eng/build.sh
+++ b/src/fsharp/eng/build.sh
@@ -144,7 +144,7 @@ while [[ $# > 0 ]]; do
--sourcebuild)
source_build=true
;;
- /p:*)
+ /*)
properties="$properties $1"
;;
*)
diff --git a/src/roslyn/eng/build.sh b/src/roslyn/eng/build.sh
index a08cbea099d..d3ec235732f 100755
--- a/src/roslyn/eng/build.sh
+++ b/src/roslyn/eng/build.sh
@@ -167,7 +167,7 @@ while [[ $# > 0 ]]; do
args="$args $1"
shift
;;
- /p:*)
+ /*)
properties="$properties $1"
;;
*)

View file

@ -0,0 +1,13 @@
diff --git a/repos/Directory.Build.targets.orig b/repos/Directory.Build.targets
index 9a61647b4d5..115cd213641 100644
--- a/repos/Directory.Build.targets.orig
+++ b/repos/Directory.Build.targets
@@ -376,6 +376,7 @@
DependsOnTargets="BuildRepoReferences"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(RepoCompletedSemaphorePath)Build.complete">
+ <Exec Command="$(DotnetToolCommand) build-server shutdown" />
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Building $(ProjectBuildReason)" />
<Message Importance="High" Text="Running command:" />
<Message Importance="High" Text=" $(BuildCommand) $(RepoApiArgs)" Condition="'$(BuildCommand)' != ''" />

View file

@ -0,0 +1,42 @@
From 5bbd0366f3caa6281fbafb49882a226453371b6a Mon Sep 17 00:00:00 2001
From: Antoine Martin (ayakael) <dev@ayakael.net>
Date: Wed, 10 Aug 2022 00:57:30 +0000
Subject: [PATCH 1/1] fix-runtme-id
General fix for RID normalisation in testing suite
---
runtime-id | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/runtime-id b/runtime-id
index 5673bba..7369776 100755
--- a/runtime-id
+++ b/runtime-id
@@ -44,12 +44,15 @@ if [[ ${portable_rid} == 1 ]]; then
echo "linux-${arch}"
fi
else
- case "${ID}" in
- # Remove the minor version
- alpine|ol|rhel|rocky) rid_version=${VERSION_ID%.*} ;;
-
- *) rid_version=${VERSION_ID} ;;
- esac
-
- echo "${ID}.${rid_version}-${arch}"
+ VERSION_ID_DOT="${VERSION_ID//[^.]}"
+ while [[ ${#VERSION_ID_DOT} -gt 1 ]]; do
+ VERSION_ID="${VERSION_ID%.*}"
+ VERSION_ID_DOT="${VERSION_ID//[^.]}"
+ done
+ VERSION_ID_DASH="${VERSION_ID//[^_]}"
+ while [[ ${#VERSION_ID_DASH} -ge 1 ]]; do
+ VERSION_ID="${VERSION_ID%_*}"
+ VERSION_ID_DASH="${VERSION_ID//[^_]}"
+ done
+ echo "${ID}.${VERSION_ID}-${arch}"
fi
--
2.37.1

View file

@ -0,0 +1,28 @@
From 79f02a53316f90543d60269d7c06727c376f423b Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Wed, 24 Aug 2022 18:41:08 +0000
Subject: [PATCH 1/1] disable apphost usage
Roslyn-analyzer can't seem to find apphost produced by runtime build on ppc64le
This disables its use as it isn't necessary
---
diff --git a/src/roslyn-analyzers/src/PerformanceTests/Tests/PerformanceTests.csproj b/src/roslyn-analyzers/src/PerformanceTests/Tests/PerformanceTests.csproj
index 044a2aba46..3d37e147b3 100644
--- a/src/roslyn-analyzers/src/PerformanceTests/Tests/PerformanceTests.csproj
+++ b/src/roslyn-analyzers/src/PerformanceTests/Tests/PerformanceTests.csproj
@@ -15,6 +15,7 @@
<Configuration>Release</Configuration>
<IsPackable>false</IsPackable>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
+ <UseAppHost>false</UseAppHost>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetVersion)" />
@@ -27,4 +28,4 @@
<ProjectReference Include="..\Utilities\CSharp\CSharpPerfUtilities.csproj" />
<ProjectReference Include="..\Utilities\VisualBasic\VisualBasicPerfUtilities.csproj" />
</ItemGroup>
-</Project>
\ No newline at end of file
+</Project>

View file

@ -0,0 +1,326 @@
From 98054ea87ce70247bb09ceafd2ad1a0b36d2fef4 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/runtime/pull/76500
From: Antoine Martin <dev@ayakael.net>
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 @@
<TargetOS Condition="'$(TargetOS)' == ''">$(_hostOS)</TargetOS>
<TargetsMobile Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'Browser'">true</TargetsMobile>
<TargetsAppleMobile Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator'">true</TargetsAppleMobile>
- <TargetsLinuxBionic Condition="$(OutputRid.StartsWith('linux-bionic'))">true</TargetsLinuxBionic>
</PropertyGroup>
<!-- Platform property is required by RepoLayout.props in Arcade SDK. -->
@@ -154,7 +154,7 @@
<_runtimeOS Condition="'$(TargetsMobile)' == 'true'">$(TargetOS.ToLowerInvariant())</_runtimeOS>
<_portableOS>linux</_portableOS>
- <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl'">linux-musl</_portableOS>
+ <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl' or $(_runtimeOS.StartsWith('alpine'))">linux-musl</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'linux-bionic'">linux-bionic</_portableOS>
<_portableOS Condition="'$(_hostOS)' == 'OSX'">osx</_portableOS>
<_portableOS Condition="'$(_runtimeOS)' == 'win' or '$(TargetOS)' == 'windows'">win</_portableOS>
@@ -200,6 +199,9 @@
<OutputRid Condition="'$(OutputRid)' == ''">$(PackageRID)</OutputRid>
<OutputRid Condition="'$(PortableBuild)' == 'true'">$(_portableOS)-$(TargetArchitecture)</OutputRid>
+
+ <TargetsLinuxBionic Condition="$(OutputRid.StartsWith('linux-bionic'))">true</TargetsLinuxBionic>
+ <TargetsLinuxMusl Condition="'$(_portableOS)' == 'linux-musl'">true</TargetsLinuxMusl>
</PropertyGroup>
<PropertyGroup Label="CalculateTargetOSName" Condition="'$(SkipInferTargetOSName)' != '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 <sys/uio.h>
#include <time.h>
#include <unistd.h>
-#include <linux/limits.h>
+#include <limits.h>
#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 @@
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">darwin-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="'$(HostOS)' == 'windows'">windows-x86_64</MonoToolchainPrebuiltOS>
<_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
- <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">gnu</_LinuxAbi>
- <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">android</_LinuxAbi>
+ <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' != 'true'">linux-gnu</_LinuxAbi>
+ <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(TargetsLinuxMusl)' == 'true'">alpine-linux-musl</_LinuxAbi>
+ <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">linux-android</_LinuxAbi>
<_LinuxFloatAbi Condition="'$(TargetsAndroid)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">hf</_LinuxFloatAbi>
<_Objcopy>objcopy</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'arm'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'armv6'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'riscv64'">riscv64-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'ppc64le'">powerpc64le-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'x86'">i686-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'arm'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'armv6'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'riscv64'">riscv64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'ppc64le'">powerpc64le-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'x64'">x86_64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'x86'">i686-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy</_Objcopy>
+ <_Objcopy Condition="'$(TargetsLinuxMusl)' == 'true' and '$(CrossBuild)' != 'true'">objcopy</_Objcopy>
<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64'">llvm-objcopy-</_ObjcopyPrefix>
</PropertyGroup>
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 $<TARGET_OBJECTS:eglib_objects>)
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

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
diff --git a/src/runtime/eng/SourceBuild.props b/src/runtime/eng/SourceBuild.props
index 32e6d9c0ba..8e2a7f9931 100644
--- a/src/runtime/eng/SourceBuild.props
+++ b/src/runtime/eng/SourceBuild.props
@@ -51,6 +51,7 @@
<InnerBuildArgs>$(InnerBuildArgs) /p:DisableSourceLink=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono</InnerBuildArgs>
+ <InnerBuildArgs>$(InnerBuildArgs) --cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE</InnerBuildArgs>
</PropertyGroup>
</Target>

View file

@ -0,0 +1,25 @@
From 98054ea87ce70247bb09ceafd2ad1a0b36d2fef4 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/runtime/issues/82269
From: Antoine Martin <dev@ayakael.net>
Date: Sat, 1 Oct 2022 09:21:58 -0400
Subject: [PATCH] Undefine fortify-source on mono-thread-coop
When _FORTIFY_SOURCE=2, there is a bug relating to memcpy that expresses itself.
See: https://gitlab.alpinelinux.org/alpine/aports/-/issues/14105. Alpine Linux
now sets this by default since https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/43463,
which makes mono-flavored runtime dump its core. This patch offers a workaround
by undefining _FORTIFY_SOURCE in the problematic file.
---
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 4ed659d6605..34bb5785fba 100644
--- a/src/runtime/src/mono/mono/utils/mono-threads-coop.c
+++ b/src/runtime/src/mono/mono/utils/mono-threads-coop.c
@@ -15,6 +15,7 @@
#ifdef TARGET_MACH
#define _DARWIN_C_SOURCE
#endif
+#undef _FORTIFY_SOURCE
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-threads.h>

View file

@ -0,0 +1,35 @@
From 4c74721e1f5da9642adab03075dda2f55719ac7b Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/sdk/pull/14239
From: Esgariot <esgariot@icloud.com>
Date: Mon, 19 Oct 2020 23:42:37 +0200
Subject: [PATCH 1/1] Add zsh compdef completion script.
Continuing off of PR 13384 in upstream.
This commit is ready to be rebased to include appropriate co-authors
before merging PR.
---
scripts/register-completions.zsh | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/src/sdk/scripts/register-completions.zsh b/src/sdk/scripts/register-completions.zsh
index 8eebe9a867..faa32fef71 100644
--- a/src/sdk/scripts/register-completions.zsh
+++ b/src/sdk/scripts/register-completions.zsh
@@ -1,10 +1,3 @@
-# zsh parameter completion for the dotnet CLI
-
-_dotnet_zsh_complete()
-{
- local completions=("$(dotnet complete "$words")")
-
- reply=( "${(ps:\n:)completions}" )
-}
-
-compctl -K _dotnet_zsh_complete dotnet
+#compdef dotnet
+local completions=("$(dotnet complete "$words")")
+[[ -n "$completions" ]] && compadd -- "${(ps:\n:)completions}"
--
2.34.1

View file

@ -0,0 +1,128 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# secfixes:
# 7.0.3-r0:
# - CVE-2023-21808
pkgname=dotnet7-runtime
pkgver=7.0.3
_bldver=7.0.103-r0
pkgrel=0
# Following for dotnet build version 6.0 and up
_pkgver_macro=${pkgver%.*}
_pkgver_name=${_pkgver_macro//[.0]}
_bldver_ver=${_bldver%%-*}
pkgdesc="The .NET $_pkgver_macro Core runtime"
# 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
arch="all !x86 !armhf !riscv64"
url=https://dotnet.microsoft.com
license="MIT"
depends="
dotnet$_pkgver_name-hostfxr
icu-data-full
icu-libs
"
makedepends="dotnet$_pkgver_name-build=$_bldver"
subpackages="
aspnetcore$_pkgver_name-runtime:aspnetcore_runtime:noarch
aspnetcore$_pkgver_name-targeting-pack:aspnetcore_targeting_pack:noarch
dotnet$_pkgver_name-apphost-pack:apphost_pack
dotnet$_pkgver_name-hostfxr
dotnet$_pkgver_name-targeting-pack:targeting_pack:noarch
dotnet-host:host
"
provides="dotnet$_pkgver_name=$pkgver-r$pkgrel"
options="!check" # No test suite
source="dotnet.sh.in"
builddir="$srcdir"
_libdir="/usr/lib"
case $CARCH in
x86_64) _dotnet_arch="x64";;
aarch64) _dotnet_arch="arm64";;
armv7) _dotnet_arch="arm";;
armhf) _dotnet_arch="armv6";;
*) _dotnet_arch="$CARCH";;
esac
build() {
sed "s|%LIBDIR%|$_libdir/dotnet|" "$srcdir"/dotnet.sh.in > "$srcdir"/dotnet.sh
}
package() {
install -dm 755 "$pkgdir"/$_libdir/dotnet/shared
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/shared/Microsoft.NETCore.App "$pkgdir"/$_libdir/dotnet/shared/.
}
host() {
pkgdesc="A generic driver for the .NET Core Command Line Interface"
depends=""
install -dm 755 \
"$subpkgdir"/etc/profile.d \
"$subpkgdir"/etc/dotnet \
"$subpkgdir"/usr/bin \
"$subpkgdir"/$_libdir/dotnet
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/dotnet "$subpkgdir"/$_libdir/dotnet/.
ln -s $_libdir/dotnet/dotnet "$subpkgdir"/usr/bin/dotnet
echo "$_libdir/dotnet" > "$subpkgdir"/etc/dotnet/install_location
echo "$_libdir/dotnet" > "$subpkgdir"/etc/dotnet/install_location_$_dotnet_arch
install -Dm 644 "$srcdir"/dotnet.sh -t "$subpkgdir"/etc/profile.d/
}
hostfxr() {
pkgdesc="The .NET host resolver contains the logic to resolve and select the right version of the .NET SDK or runtime to use."
depends="dotnet-host"
provides="dotnet-hostfxr-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/host "$subpkgdir"/$_libdir/dotnet/.
}
aspnetcore_runtime() {
pkgdesc="The ASP.NET $_pkgver_macro Core runtime"
depends="dotnet$_pkgver_name-runtime"
provides="aspnetcore-runtime-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet/shared
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/shared/Microsoft.AspNetCore.App "$subpkgdir"/$_libdir/dotnet/shared/.
}
apphost_pack() {
pkgdesc="The .NET $_pkgver_macro Core apphost pack"
provides="dotnet-apphost-pack-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet/packs
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/packs/Microsoft.NETCore.App.Host.* "$subpkgdir"/$_libdir/dotnet/packs/.
}
targeting_pack() {
pkgdesc="The .NET $_pkgver_macro Core targeting pack"
provides="dotnet-targeting-pack-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet/packs
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/packs/Microsoft.NETCore.App.Ref "$subpkgdir"/$_libdir/dotnet/packs/.
}
aspnetcore_targeting_pack() {
pkgdesc="The ASP.NET $_pkgver_macro Core targeting pack"
provides="aspnetcore-targeting-pack-$_pkgver_macro=$pkgver-r$pkgrel"
install -dm 755 "$subpkgdir"/$_libdir/dotnet/packs
cp -r $_libdir/dotnet/bootstrap/$_bldver_ver/packs/Microsoft.AspNetCore.App.Ref "$subpkgdir"/$_libdir/dotnet/packs/.
}
sha512sums="
c3f31956976b77198e72a3fef3427338b6b2961f8c121416040c1105de0ce8073e46f4c2e9ef22a001aee69cbe39621c2ddac988522693110071dfae42f2e2b7 dotnet.sh.in
"

View file

@ -0,0 +1,144 @@
# dotnet7-runtime
This is the .NET 7.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
* `aspnetcore7-runtime`
* `aspnetcore7-targeting-pack`
* `dotnet7-apphost-pack` (used by dotnet7-runtime)
* `dotnet7-hostfxr` (used by dotnet-host)
* `dotnet7-runtime`
* `dotnet7-targeting-pack`
* `dotnet-host`
## How to build dotnet7 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)
The goal of `stage0` is to bootstrap dotnet with as little intervention as
possible, thus allowing seamless Alpine upgrades. Unfortunately, upstream only
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.
* `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`
As abuild does not allow different versions for subpackages, a different aport
is required to package runtime bits from dotnet7-build.
## Crossbuilding with `stage0`
Crossbuilding `stage0` is a three step process:
1. Build sysroot for target platform by using `scripts/bootstrap.sh` in aports repo:
```
./bootstrap.sh $CTARGET_ARCH
```
2. Although not necessary, it is recommended to add Alpine repositories to
`$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:
```
CHOST=$CTARGET_ARCH abuild -r
```
# Specification
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`
to match Alpine Linux naming conventions for packages with many installable versions
# Contributing
The steps below are for the final package. Please only contribute to a
pre-release version if you know what you are doing. Original instructions
follow.
## General Changes
1. Fork the main aports repo.
2. Checkout the forked repository.
- `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports`
- `cd community/dotnet7-build`
3. Make your changes. Don't forget to add a changelog.
4. Do local builds.
- `abuild -r`
5. Fix any errors that come up and rebuild until it works locally.
6. Commit the changes to the git repo in a git branch
- `git checkout -b dotnet7/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet7-build: descriptive description'`
- `git push`
7. Create a merge request with your changes, tagging @ayakael for review.
8. Once the tests in the pull-request pass, and reviewers are happy, your changes
will be merged.
## Updating to an new upstream release
1. Fork the main aports repo.
2. Checkout the forked repository.
- `git clone ssh://git@gitlab.alpinelinux.org/$USER/aports`
- `cd community/dotnet7-build`
3. Build the new upstream source tarball. Update the versions in the
APKBUILD file, and then create a snapshot. After build, update checksum.
- `abuild snapshot`
- `abuild checksum`
4. Do local builds.
- `abuild -r`
5. Fix any errors that come up and rebuild until it works locally. Any
patches that are needed at this point should be added to the APKBUILD file
in `_patches` variable.
6. Upload the source archive to a remote location, and update `source` variable.
7. Commit the changes to the git repo in a git branch.
- `git checkout -b dotnet7/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet7-build: upgrade to <new-version>`
- `git push`
8. Create a merge request with your changes, tagging @ayakael for review.
9. Once the tests in the pull-request pass, and reviewers are happy, your changes
will be merged.
# Testing
This package uses CI tests as defined in `check()` function. Creating a
merge-request or running a build will fire off tests and flag any issues.
The tests themselves are contained in this external repository:
https://github.com/redhat-developer/dotnet-regular-tests/

View file

@ -0,0 +1,12 @@
# Set location for AppHost lookup
[ -z "$DOTNET_ROOT" ] && export DOTNET_ROOT=%LIBDIR%
# Add dotnet tools directory to PATH
DOTNET_TOOLS_PATH="$HOME/.dotnet/tools"
case "$PATH" in
*"$DOTNET_TOOLS_PATH"* ) true ;;
* ) PATH="$PATH:$DOTNET_TOOLS_PATH" ;;
esac
# Extract self-contained executables under HOME to avoid multi-user issues from using the default '/var/tmp'
[ -z "$DOTNET_BUNDLE_EXTRACT_BASE_DIR" ] && export DOTNET_BUNDLE_EXTRACT_BASE_DIR="${XDG_CACHE_HOME:-"$HOME"/.cache}/dotnet_bundle_extract"