user/dotnet6-stage0: new aport

This commit is contained in:
Antoine Martin 2023-02-21 23:48:05 -05:00
parent 356958aea7
commit 8bf299545a
Signed by: forge
GPG key ID: D62A472A4AA7D541
15 changed files with 1786 additions and 0 deletions

View file

@ -0,0 +1,507 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=dotnet6-stage0
pkgver=6.0.112
pkgrel=0
[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross=""
# Tag of tarball generator.
_gittag=v6.0.112
# Versions of prebuilt artifacts and bootstrap tar
_artifactsver=6.0.112
_bootstrapver="6.0.112"
_installerver=$_bootstrapver
# Version of packages that aren't defined in git-info
_iltoolsver=6.0.12-servicing.22579.1
# Patches to be used. String before '_' refers to repo to patch
# Look for patch notes within each patch for what they fix / where they come from
# build_* patches applies directly to $builddir
_patches="
aspnetcore_use-linux-musl-crossgen-on-non-x64.patch
build_set-local-repo.patch
installer_2780-reprodicible-tarball.patch
installer_runtimepacks.patch
roslyn_57003-mono-namedmutex.patch
roslyn_allow-extra-params.patch
roslyn_revert-lift-version-codeanalysis.patch
runtime_76500-mono-musl-support.patch
runtime_build-with-no-strict-prototypes.patch
runtime_lld-fix.patch
runtime_no-additional-runtime-id.patch
runtime_s390x-build.patch
sdk_dummyshim-fix.patch
"
_extra_nupkgs="
https://globalcdn.nuget.org/packages/system.reactive.core.4.1.1.nupkg
"
_pkgver_macro=${pkgver%.*}
_pkgver_prior=1
_pkgver_name="${_pkgver_macro//[.0]}"
pkgdesc="The .NET Core stage0 bits for dotnet build"
arch="x86_64 aarch64 armv7 s390x"
url=https://www.microsoft.com/net/core
license="MIT"
options="!check" # Testsuite in main -build aport
subpackages="
dotnet$_pkgver_name-stage0-artifacts:artifacts:noarch
dotnet$_pkgver_name-stage0-bootstrap
"
source="
https://repo.gpg.nz/apk/archives/dotnet-${_gittag/release\/}.tar.xz
dotnet-sdk-$_bootstrapver-linux-musl-x64.noextract::https://dotnetcli.azureedge.net/dotnet/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-x64.tar.gz
dotnet-sdk-$_bootstrapver-linux-musl-arm64.noextract::https://dotnetcli.azureedge.net/dotnet/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm64.tar.gz
dotnet-sdk-$_bootstrapver-linux-musl-arm.noextract::https://dotnetcli.azureedge.net/dotnet/Sdk/$_bootstrapver/dotnet-sdk-$_bootstrapver-linux-musl-arm.tar.gz
dotnet-sdk-$_bootstrapver-linux-musl-s390x.noextract::https://repo.gpg.nz/apk/archives/dotnet-sdk-$_bootstrapver-linux-musl-s390x.tar.gz
Private.SourceBuilt.Artifacts.$_artifactsver.noextract::https://dotnetcli.azureedge.net/source-built-artifacts/assets/Private.SourceBuilt.Artifacts.$_artifactsver.tar.gz
https://globalcdn.nuget.org/packages/runtime.linux-musl-x64.microsoft.netcore.ilasm.6.0.0.nupkg
https://globalcdn.nuget.org/packages/runtime.linux-musl-arm64.microsoft.netcore.ilasm.6.0.0.nupkg
https://globalcdn.nuget.org/packages/runtime.linux-musl-arm.microsoft.netcore.ilasm.6.0.0.nupkg
https://repo.gpg.nz/apk/archives/runtime.linux-musl-s390x.microsoft.netcore.ilasm.6.0.0.nupkg
$_extra_nupkgs
$_patches
"
makedepends_host="
bash
binutils
clang
cmake
findutils
g++
gcc
grep
icu-dev
krb5-dev
libintl
libstdc++
libucontext-dev
libunwind-dev
libxml2-dev
libxml2-utils
linux-headers
lttng-ust-dev
musl-dev
musl-utils
openssl-dev
pigz
unzip
zip
zlib-dev
"
case $CARCH in
s390x|x86) makedepends_host="$makedepends_host libucontext-dev";;
*) makedepends_host="$makedepends_host lld-dev";;
esac
makedepends_build="
$makedepends_host
binutils$_cross
git
gcc$_cross
llvm
llvm-dev
python3
xz
"
case $CBUILD_ARCH in
x86_64) _dotnet_arch="x64";;
aarch64) _dotnet_arch="arm64";;
armv7|armhf) _dotnet_arch="arm";;
i586) _dotnet_arch="x86";;
*) _dotnet_arch=$CBUILD_ARCH;;
esac
case $CTARGET_ARCH in
x86_64) _dotnet_target="x64";;
aarch64) _dotnet_target="arm64";;
armv7|armhf) _dotnet_target="arm";;
i586) _dotnet_target="x86";;
*) _dotnet_target=$CTARGET_ARCH;;
esac
builddir="$srcdir"/dotnet-${_gittag/release\/}
_packagesdir="$srcdir"/local-packages
_libdir="/usr/lib"
_nugetdir="$srcdir"/nuget
_downloaddir="$srcdir"/local-downloads
_cli_root="$srcdir"/bootstrap
_nuget="$_cli_root/dotnet nuget"
_outputdir="$srcdir"/artifacts
# 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
# 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 https://github.com/dotnet/installer && cd "$srcdir"/installer
fi
git checkout $_gittag
sed 's|/src/installer||' "$startdir"/installer_2780-reprodicible-tarball.patch | patch -Np1 || true
if [ ! -d "$_cli_root" ]; then
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
# adjusts sdk version to expected
sed "s|6.0.100|$_bootstrapver|" -i "$builddir"/src/roslyn/global.json
sed "s|6.0.100|$_bootstrapver|" -i "$builddir"/src/sdk/global.json
for i in sdk installer aspnetcore roslyn; do
sed "s|@@PACKAGESDIR@@|$_packagesdir|" -i "$builddir"/src/$i/NuGet.config
done
mkdir -p "$_cli_root"
mkdir -p $_packagesdir $_downloaddir $_outputdir $_nugetdir
# 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
unzip -po "$srcdir"/runtime.linux-musl-$_dotnet_arch.microsoft.netcore.ilasm.*.nupkg runtimes/linux-musl-$_dotnet_arch/native/ilasm > $_cli_root/ilasm
chmod +x "$_cli_root"/ilasm
tar --use-compress-program="pigz" -xf "$srcdir"/dotnet-sdk-$_pkgver_macro*$_dotnet_arch.noextract -C "$_cli_root" --no-same-owner
}
_runtime() {
"$_cli_root"/dotnet build-server shutdown
if [ -z "${_runtimever+x}" ]; then
local _runtimever=$(grep OutputPackageVersion "$builddir"/git-info/runtime.props | sed -E 's|</?OutputPackageVersion>||g' | tr -d ' ')
fi
local _runtimever_ns=$(awk '{if($2 ~ "Name=\"VS.Redist.Common.NetCore.SharedFramework.x64.*\""){print $3}}' "$builddir"/src/installer/eng/Version.Details.xml | awk -F '"' '{print $2}')
msg "[$(date)] Building runtime version $_runtimever"
cd "$builddir"/src/runtime
local args="
-c Release
-clang
-arch $_dotnet_target
-bl
/consoleLoggerParameters:ShowTimestamp
/p:NoPgoOptimize=true
/p:EnableNgenOptimization=false
/p:GitCommitHash=$(cat ./.git/HEAD)
/p:ILAsmToolPath=$_cli_root
"
if [ "$CBUILD" != "$CHOST" ]; then
local args="$args -cross"
fi
if [ "$_runtimever" != "${_runtimever##*-}" ]; then
local args="$args /p:VersionSuffix=${_runtimever##*-}"
fi
ROOTFS_DIR="$CBUILDROOT" ./build.sh $args
for i in artifacts/packages/*/*/*.nupkg; do
$_nuget push $i --source="$_packagesdir"
done
mkdir -p "$_downloaddir"/Runtime/$_runtimever_ns
cp artifacts/packages/*/*/dotnet-runtime-*-*.tar.gz $_downloaddir/Runtime/$_runtimever_ns
}
_roslyn() {
"$_cli_root"/dotnet build-server shutdown
if [ -z "${_roslynver+x}" ]; then
local _roslynver=$(grep OutputPackageVersion "$builddir"/git-info/roslyn.props | sed -E 's|</?OutputPackageVersion>||g' | tr -d ' ')
fi
local _roslynver_ns=$(awk '{if($2 == "Name=\"Microsoft.Net.Compilers.Toolset\""){print $3}}' "$builddir"/src/installer/eng/Version.Details.xml | awk -F '"' '{print $2}')
msg "[$(date)] Building roslyn version $_roslynver"
cd "$builddir"/src/roslyn
local args="
-c Release
-bl
/consoleLoggerParameters:ShowTimestamp
/p:GitCommitHash=$(cat ./.git/HEAD)
"
if [ "$_roslynver" != "${_roslynver##*-}" ]; then
local args="$args /p:VersionSuffix=${_roslynver##*-}"
fi
DotNetBuildFromSource=false ./eng/build.sh --restore /p:UseAppHost=false
./eng/build.sh --restore --build --pack $args
for i in artifacts/packages/*/*/*.nupkg; do
$_nuget push $i --source="$_packagesdir"
done
}
_sdk() {
"$_cli_root"/dotnet build-server shutdown
if [ -z "${_sdkver+x}" ]; then
local _sdkver=$(grep OutputPackageVersion "$builddir"/git-info/sdk.props | sed -E 's|</?OutputPackageVersion>||g' | tr -d ' ')
fi
local _sdkver_ns=$(awk '{if($2 == "Name=\"Microsoft.NET.Sdk\""){print $3}}' "$builddir"/src/installer/eng/Version.Details.xml | awk -F '"' '{print $2}')
msg "[$(date)] Building sdk version $_sdkver"
cd "$builddir"/src/sdk
# ArgumentsReflector doesn't build correctly when built from source
cd ./src/Tests/ArgumentsReflector
DotNetBuildFromSource=false dotnet restore
DotNetBuildFromSource=false dotnet build --configuration Release
cd ../../..
local args="
-c Release
-bl
/consoleLoggerParameters:ShowTimestamp
/p:GitCommitHash=$(cat ./.git/HEAD)
/p:Architecture=$_dotnet_target
"
if [ "$_sdkver" != "${_sdkver##*-}" ]; then
local args="$args /p:VersionSuffix=${_sdkver##*-}"
fi
./build.sh --pack $args
for i in artifacts/packages/*/*/*.nupkg; do
$_nuget push $i --source="$_packagesdir"
done
mkdir -p "$_downloaddir"/Sdk/$_sdkver_ns
cp artifacts/packages/*/*/dotnet-toolset-internal-*.zip "$_downloaddir"/Sdk/$_sdkver_ns
}
_aspnetcore() {
"$_cli_root"/dotnet build-server shutdown
if [ -z "${_aspnetver+x}" ]; then
local _aspnetver=$(grep OutputPackageVersion "$builddir"/git-info/aspnetcore.props | sed -E 's|</?OutputPackageVersion>||g' | tr -d ' ')
fi
local _aspnetver_ns=$(awk '{if($2 == "Name=\"Microsoft.AspNetCore.App.Ref.Internal\""){print $3}}' "$builddir"/src/installer/eng/Version.Details.xml | awk -F '"' '{print $2}')
msg "[$(date)] Build aspnetcore version $_aspnetver"
cd "$builddir"/src/aspnetcore
local args="
--os-name linux-musl
-arch $_dotnet_target
-c Release
-no-build-nodejs
-bl
/consoleLoggerParameters:ShowTimestamp
/p:GitCommitHash=$(cat ./.git/HEAD)
/p:DotNetAssetRootUrl=file://$_downloaddir/
"
case $CARCH in
x86) local args="$args /p:CrossgenOutput=false";;
esac
if [ "$_aspnetver" != "${_aspnetver##*-}" ]; then
local args="$args /p:VersionSuffix=${_aspnetver##*-}"
fi
./eng/build.sh --pack $args
for i in artifacts/packages/*/*/*.nupkg; do
$_nuget push $i --source="$_packagesdir"
done
mkdir -p "$_downloaddir"/aspnetcore/Runtime/$_aspnetver_ns
cp artifacts/installers/*/aspnetcore-runtime-internal-*-linux-musl-$_dotnet_target.tar.gz "$_downloaddir"/aspnetcore/Runtime/$_aspnetver_ns
cp artifacts/installers/*/aspnetcore_base_runtime.version "$_downloaddir"/aspnetcore/Runtime/$_aspnetver_ns
}
_installer() {
"$_cli_root"/dotnet build-server shutdown
msg "[$(date)] Building installer version $_installerver"
cd "$builddir"/src/installer
local args="
-c Release
-bl
/consoleLoggerParameters:ShowTimestamp
/p:OSName=linux-musl
/p:HostOSName=linux-musl
/p:Architecture=$_dotnet_target
/p:CoreSetupBlobRootUrl=file://$_downloaddir/
/p:DotnetToolsetBlobRootUrl=file://$_downloaddir/
/p:GitCommitHash=$(cat ./.git/HEAD)
/p:GitCommitCount=$(grep GitCommitCount "$builddir"/git-info/installer.props | sed -E 's|</?GitCommitCount>||g' | tr -d ' ')
/p:PublicBaseURL=file://$_downloaddir/
"
if [ "$_installerver" != "${_installerver##*-}" ]; then
local args="$args /p:VersionSuffix=${_installerver##*-}"
fi
case $CARCH in
x86) local args="$args /p:DISABLE_CROSSGEN=True";;
esac
./build.sh $args
mkdir -p "$_downloaddir"/installer/$_installerver
cp artifacts/packages/*/*/dotnet-sdk-$_pkgver_macro*.tar.gz "$_downloaddir"/installer/$_installerver
}
build() {
export _InitializeDotNetCli=$_cli_root
export DOTNET_INSTALL_DIR=$_cli_root
export PATH="$_cli_root:$PATH"
export NUGET_PACKAGES=$_nugetdir
export DotNetBuildFromSource=true
export DOTNET_CLI_TELEMETRY_OPTOUT=true
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
export SHELL=/bin/bash
export EXTRA_CPPFLAGS="${CPPFLAGS/--sysroot=$CBUILDROOT}"
export EXTRA_CXXFLAGS="${CXXFLAGS/--sysroot=$CBUILDROOT}"
export EXTRA_CFLAGS="${CFLAGS/--sysroot=$CBUILDROOT}"
export EXTRA_LDFLAGS="$LDFLAGS"
unset CXXFLAGS CFLAGS LDFLAGS CPPFLAGS
ulimit -n 4096
_runtime
_roslyn
_sdk
_aspnetcore
_installer
}
package() {
# lua-aports / buildrepo doesn't know to always build stage0 first when dealing
# with virtual packages. Thus, we need to depend on an empty stage0 pkg that
# dotnetx-build will pull, thus forcing build of stage0 first
mkdir -p "$pkgdir"
}
bootstrap() {
# allows stage0 to be pulled by dotnetx-build if first build of dotnetx
provides="dotnet$_pkgver_name-bootstrap"
provider_priority=$_pkgver_prior
install -dm 755 \
"$subpkgdir"/$_libdir/dotnet/bootstrap/$pkgver/docs \
"$subpkgdir"/$_libdir/dotnet/bootstrap/$pkgver/comp \
"$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver
# unpack build artifacts to bootstrap subdir for use by future builds
tar --use-compress-program="pigz" \
-xf "$_downloaddir"/installer/$_installerver/dotnet-sdk-$_pkgver_macro*.tar.gz \
-C "$subpkgdir"/$_libdir/dotnet/bootstrap/$pkgver/ \
--no-same-owner
local _iltoolsArray="
runtime.*.Microsoft.NETCore.TestHost.*.nupkg
runtime.*.Microsoft.NETCore.ILAsm.*.nupkg
runtime.*.Microsoft.NETCore.ILDAsm.*.nupkg
"
local _nupkgsArray="
$_iltoolsArray
Microsoft.NETCore.App.Host.*.*.nupkg
Microsoft.NETCore.App.Runtime.*.*.nupkg
Microsoft.NETCore.App.Crossgen2.*.*.nupkg
runtime.*.Microsoft.NETCore.DotNetHost.*.nupkg
runtime.*.Microsoft.NETCore.DotNetHostPolicy.*.nupkg
runtime.*.Microsoft.NETCore.DotNetHostResolver.*.nupkg
runtime.*.Microsoft.NETCore.DotNetAppHost.*.nupkg
Microsoft.AspNetCore.App.Runtime.linux-musl-*.*.nupkg
"
# copies artifacts to artifacts dir for use by future dotnet builds
for i in $_nupkgsArray; do install -Dm644 "$_packagesdir"/$i "$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver/ || true; done
for i in $_extra_nupkgs; do install -Dm644 "$srcdir"/${i##*/} "$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver/; done
msg "Changing iltools version to $_iltoolsver"
# source-build expects a certain version of ilasm, ildasm and testhost
# following adjusts version
for i in $_iltoolsArray; do
local nupath="$subpkgdir"$_libdir/dotnet/artifacts/$pkgver/$i
local nupath=$(find $nupath || true)
if [ ! "$nupath" ]; then continue; fi
local nupkg="${nupath##*/}"
local nuname="${nupkg%-*}"
local nuname="${nuname%.*.*.*}"
local nuver="${nupkg/$nuname.}"
local nuver="${nuver/.nupkg}"
local nuspec="$nuname.nuspec"
# shellcheck disable=SC2094
unzip -p "$nupath" $nuspec | sed "s|$nuver|$_iltoolsver|" > "$srcdir"/$nuspec
cd "$srcdir"
zip -u "$nupath" $nuspec
mv "$nupath" "${nupath/$nuver/$_iltoolsver}"
done
}
# build relies on a plethora of nupkgs which are provided by this Artifacts file.
# stage0 sources these from Microsoft, which then allows bootstrap to build
# locally hosted versions. The following unpacks built tarball into directory
# for use by future builds.
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 artifacts to artifacts dir for use by future dotnet builds
tar --use-compress-program="pigz" \
-xf "$srcdir"/Private.SourceBuilt.Artifacts.*.noextract \
-C "$subpkgdir"/$_libdir/dotnet/artifacts/$pkgver/ \
--no-same-owner \
--exclude '*x64*'
}
sha512sums="
a308859d2b3e2946c38b400e9711cd34c52fbabf927fca7212ed3a87ba495b8fa125e043b4890d01c59a152930e92fdced40fd2eed9e7da3b13345cfe2a7dc6f dotnet-v6.0.112.tar.xz
6d23a7fe8dbddb0785811271326aa3f0bcd68db85c1a148c4e21eb6fd7347a1381dac9c077e4d01c17b08570cffea4b4cf43f78c3f83c2177e66a8c4531c237d dotnet-sdk-6.0.112-linux-musl-x64.noextract
6000baf38c8b92ea4c71ecc6b3f2dcffbe6e0b3d3e8846f7c296180d0ac1d94905542df3453dc8fae16c3ae351d6380f053017d86207c2e58affdc67c93fff1b dotnet-sdk-6.0.112-linux-musl-arm64.noextract
2d0bdbc564853ea9c6daf4a1fb7940c28bf3a766ef857a4fcccaa42f8b3ccda53f8b968b83187e1387a8119502175a8f92215a24eeacd843c018a01b44e140cc dotnet-sdk-6.0.112-linux-musl-arm.noextract
79389787b851ebdbe0ea2dcafa172aba313e72db795b02cc2ad0b42b9dd9017ed26c3e4cdc987711bedb2237211dcd2f7d05ba90d9e4f4f2a43dbdeb1990874a dotnet-sdk-6.0.112-linux-musl-s390x.noextract
64fffa28143c28ceefbae08e8086746e177a11242f6a5b778bc5597190748c9d3e869020d7d3f4b74efaad7fbb73258765e227c9bdd098501fdbbc7e7e6ec05b Private.SourceBuilt.Artifacts.6.0.112.noextract
0eb771d7e23607a256f209c958a8025af6a7c1e20948b244f2903941aad5e1c0f130a9285ee29086d6188090e8692f5f129329a88da54d3f0a7e7e5b7e4257ef runtime.linux-musl-x64.microsoft.netcore.ilasm.6.0.0.nupkg
5ad26a79b5ba3ebdc6932dde50218d2c0669377dcb628debbb448e0dfc5d001d7e07b121f18ecd50b667ab372e10ec0bfe166a6e2103faf2f824995fdad0c355 runtime.linux-musl-arm64.microsoft.netcore.ilasm.6.0.0.nupkg
2a24e56ddf0f3e3ef7cb64523b7c6ebf02b91a73287c342783eb66e43a9bbe0cd23eb4b26f435e6b194bf1a40017e6aae60333ff087b18657672b243e8c8ce76 runtime.linux-musl-arm.microsoft.netcore.ilasm.6.0.0.nupkg
efdc9097028d11ddc2e9e052c57d62af333705b5108093077238d8b98fb5e250d75ac62cec5842bd9989bf6d737736a70ed4f512c69b356314805c24f3f1d698 runtime.linux-musl-s390x.microsoft.netcore.ilasm.6.0.0.nupkg
a24efb7578e2020e17c877ffe00b49f8f476b0845fdc55c16404008a9566d8628a72c2208bd23df745c88592ebe9c922b0cf1bc1f95f834b539bbcc2cbf516c5 system.reactive.core.4.1.1.nupkg
7462305c0aed05c0d18ea5ebf8a9d04c7e15d826ff5682d14ce256393e8d05094d3be244fdc550cb1ab9fa45400c4d92783faac03960ef156fa25b4073728fdb aspnetcore_use-linux-musl-crossgen-on-non-x64.patch
8db70e1df88894ae9095f1ddd277ef52c6e02678bb9ec34c44378aeb76694d8b8f7db47c0a7dbcb395b14481ef3f643e3bd3ffe23f9d16a2290cd7ff2ea7b98c build_set-local-repo.patch
5a60254d58f4a2f3bafb75cfafc84ed6a0c5705714b7a6fb3bc84463d80abff98c9ac04adcdb0390d143dbb2b8cbd626cefb289a9f1dddfa963a240abc9b7725 installer_2780-reprodicible-tarball.patch
53194e107801ae36668599697fa42d7bf6ef24baff63987a3289e95b971f83a9c50ed1815efeb67ba86afbd1172ae6db964022d0f4a85ba4409a1d622c6c999f installer_runtimepacks.patch
42779a7bf1004fe0f7054cfa4f09f49d7f2a57c0543ec994ffbd54fb349abb508295476098ed35d60e9676be8bcc15aa8a9ec5c814cd1e058357530b5cdfb2b6 roslyn_57003-mono-namedmutex.patch
ead82bb2276acc273d661e42597c76661984143bb7736cd6a64241f51b2da3b9b8625b6232e24c7f9a6965436f65a5b7bf1ba7669a01e6b9774ebd3a62f7ebe0 roslyn_allow-extra-params.patch
cf40e37b4adfc61e24e3b48a397b4d813726d190f271869d946035279bf662a694a0fca448f5ae06ad2bb2300595223109ad64f60f65dac5cddf9308e12147a3 roslyn_revert-lift-version-codeanalysis.patch
e67e0114bd324dae65eb19f6fa8c74414bee77cd30e299931b0d82b4ca1b6b6f88358a0c47ffb180f46c5cb28f61f79bb4a59d43c1ae3011bfe491e757de293a runtime_76500-mono-musl-support.patch
f1960cb573ca33437d29a5a98fa05df848c95fde2f9e0dd3344be8583c1cc98d3034b6b4d8fea2643ae29046fe312529651207da33b66e892b76b62e637dfbc2 runtime_build-with-no-strict-prototypes.patch
5f465f6e3bfbff66551a5690eb41be46735f8e0b1e6e6503038521a8cc60cd66b7839426319ec304f785c9f074ef588b1f189ad6dbb6ced53257af28b09388f2 runtime_lld-fix.patch
564463cf898ee82a96f54303f7663527192ccd097a27b68c27fe6c9a5b7c9ac352dc23c7658f180ef3194433ededbf0d01fee3194604f6ca8b20dd17d3ebf9dd runtime_no-additional-runtime-id.patch
173105cf8e63f2e15c8b46d598f1338416a0da1ce77e0862cfb774c41e7883c70d0d733ed56fae5ab091ea96f8d6dd70e0e873b5dac6edb4e1266a08f68f2986 runtime_s390x-build.patch
b5f28aa8bdbd24c589276a60893859965eb78b0abfbdac7a6e86715ac87e3bbd8bc271852ff62a41ea83b53af02e1c1814abcccc8862c07b3ac74633d1be0a32 sdk_dummyshim-fix.patch
"

View file

@ -0,0 +1,140 @@
# dotnet6-stage0
This is the .NET 6.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
* `dotnet6` (empty package to go around `buildrepo` build ordering bug)
* `dotnet6-stage0-bootstrap` (packages binary bootstrap artifacts)
* `dotnet6-stage0-artifacts` (packages non-binary bootstrap artifacts)
## How to build dotnet6 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, dotnet6 is built using three different aports.
* `community/dotnet6-stage0`
Builds minimum components for full build of dotnet6, and packages these in an initial
`dotnet6-stage0-bootstrap` package that `dotnet7-build` pulls.
* `community/dotnet6-build`
Builds full and packages dotnet6 fully using either stage0 or previoulsy built
dotnet6 build.
* `community/dotnet6-runtime`
As abuild does not allow different versions for subpackages, a different aport
is required to package runtime bits from dotnet6-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 `dotnet6-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 `dotnet6` as opposed to `dotnet-6.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/dotnet6-stage0`
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 dotnet6/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet6-stage0: 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/dotnet6-stage0`
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 dotnet6/<name>`
- `git add` any new patches
- `git remove` any now-unnecessary patches
- `git commit -m 'community/dotnet6-stage0: 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,34 @@
From 451aa3e9544b0214d0e8e844c27af3847f5bf391 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/installer/pull/13410
From: Antoine Martin <dev@ayakael.net>
Date: Fri, 18 Feb 2022 05:14:39 +0000
Subject: [PATCH 1/1] musl build fix
Line causes build of aspnetcore on arm to look for linux version of
CrossGen2 rather than linux-musl. This removes the line so that
BuildOsName is pulled from TargetOsName as expected
This is now only necessary for portable
builds, as https://github.com/dotnet/installer/pull/14549 has fixed
issues relating to musl build on full source-build
---
.../App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/aspnetcore/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/aspnetcore/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
index aeb3c08f13..380fc5fbac 100644
--- a/src/aspnetcore/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
+++ b/src/aspnetcore/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
@@ -104,7 +104,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
Special case the crossgen2 package reference on Windows to avoid the x86 package when building in Visual Studio.
-->
<BuildOsName>$(TargetOsName)</BuildOsName>
- <BuildOsName Condition="'$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'">linux</BuildOsName>
<BuildOsName Condition=" '$(PortableBuild)' == 'false' ">$(TargetRuntimeIdentifier.Substring(0,$(TargetRuntimeIdentifier.IndexOf('-'))))</BuildOsName>
<Crossgen2BuildArchitecture Condition=" '$(BuildOsName)' == 'win' ">x64</Crossgen2BuildArchitecture>
<Crossgen2BuildArchitecture Condition=" '$(Crossgen2BuildArchitecture)' == '' ">$(BuildArchitecture)</Crossgen2BuildArchitecture>
--
2.34.1

View file

@ -0,0 +1,64 @@
From 46382e01243e30156660f6efe84a9afee0c5c1aa Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Sun, 28 Aug 2022 05:19:20 +0000
Subject: [PATCH 2/2] aspnetcore_set-local-repo
Patch necessary for stage0, as each component requires the artifacts
from previously built component. This patch (along with a prepare step
in aport) adds a "local" nupkg repository that artifacts are pushed to
at end of component build
---
src/aspnetcore/NuGet.config | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/aspnetcore/NuGet.config b/src/aspnetcore/NuGet.config
index a26b4ca86..1f40b8f06 100644
--- a/src/aspnetcore/NuGet.config
+++ b/src/aspnetcore/NuGet.config
@@ -2,6 +2,7 @@
<configuration>
<packageSources>
<clear />
+ <add key="local" value="@@PACKAGESDIR@@" />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-int-dotnet-runtime-163a635" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-163a6359/nuget/v3/index.json" />
diff --git a/src/roslyn/NuGet.config b/src/roslyn/NuGet.config
index a26b4ca86..1f40b8f06 100644
--- a/src/roslyn/NuGet.config
+++ b/src/roslyn/NuGet.config
@@ -3,6 +3,7 @@
<configuration>
<packageSources>
<clear />
+ <add key="local" value="@@PACKAGESDIR@@" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
diff --git a/src/sdk/NuGet.config b/src/sdk/NuGet.config
index 2773a4d0b..9aab732f7 100644
--- a/src/sdk/NuGet.config
+++ b/src/sdk/NuGet.config
@@ -2,6 +2,7 @@
<configuration>
<packageSources>
<clear />
+ <add key="local" value="@@PACKAGESDIR@@" />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-aspnetcore -->
<add key="darc-int-dotnet-aspnetcore-6a01dd1" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-aspnetcore-6a01dd1e/nuget/v3/index.json" />
diff --git a/src/installer/NuGet.config b/src/installer/NuGet.config
index 8cac51c22..c07e44968 100644
--- a/src/installer/NuGet.config
+++ b/src/installer/NuGet.config
@@ -5,6 +5,7 @@
</solution>
<packageSources>
<clear />
+ <add key="local" value="@@PACKAGESDIR@@" />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-aspnetcore -->
<add key="darc-int-dotnet-aspnetcore-6a01dd1" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-aspnetcore-6a01dd1e/nuget/v3/index.json" />
--
2.37.1

View file

@ -0,0 +1,127 @@
From 3669424e83ce393e2e0ee3f23b5a255c3a11a192 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/installer/issues/2780
From: Antoine Martin <dev@ayakael.net>
Date: Wed, 16 Feb 2022 15:59:42 +0000
Subject: [PATCH 1/1] reproducible tarball
By default, tarball is not reprodicible due to a select few of volatile
files. This volatility is associated with .git directories and
OfficialBuildId of a few packages that source it from tarball build
date. This patch allows stripping of git directories to bare minimum and
sources OfficialBuildId with generic date to be modified later for
build.
---
.../src/Tarball_WriteSourceRepoProperties.cs | 6 +--
.../tools/SourceBuildArcadeTarball.targets | 9 +++--
.../SourceBuildArcadeTarball_strip-git.sh | 38 +++++++++++++++++++
3 files changed, 46 insertions(+), 7 deletions(-)
create mode 100755 src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball_strip-git.sh
diff --git a/src/installer/src/SourceBuild/Arcade/src/Tarball_WriteSourceRepoProperties.cs b/src/installer/src/SourceBuild/Arcade/src/Tarball_WriteSourceRepoProperties.cs
index b6b2793f3..55d680971 100644
--- a/src/installer/src/SourceBuild/Arcade/src/Tarball_WriteSourceRepoProperties.cs
+++ b/src/installer/src/SourceBuild/Arcade/src/Tarball_WriteSourceRepoProperties.cs
@@ -105,12 +105,12 @@ private static DerivedVersion GetVersionInfo(string version, string commitCount)
if (releaseParts.Length == 2)
{
// NuGet does this - arbitrary build IDs
- return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("yyyyMMdd.1"), PreReleaseVersionLabel = releaseParts[0] };
+ return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("19900101.1"), PreReleaseVersionLabel = releaseParts[0] };
}
else if (releaseParts.Length == 3)
{
// VSTest uses full dates for the first part of their preview build numbers
- if (DateTime.TryParseExact(releaseParts[1], "yyyyMMdd", new CultureInfo("en-US"), DateTimeStyles.AssumeLocal, out DateTime fullDate))
+ if (DateTime.TryParseExact(releaseParts[1], "19900101", new CultureInfo("en-US"), DateTimeStyles.AssumeLocal, out DateTime fullDate))
{
return new DerivedVersion { OfficialBuildId = $"{releaseParts[1]}.{releaseParts[2]}", PreReleaseVersionLabel = releaseParts[0] };
}
@@ -139,7 +139,7 @@ private static DerivedVersion GetVersionInfo(string version, string commitCount)
{
// finalized version number (x.y.z) - probably not our code
// VSTest, Application Insights, Newtonsoft.Json do this
- return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("yyyyMMdd.1"), PreReleaseVersionLabel = string.Empty };
+ return new DerivedVersion { OfficialBuildId = DateTime.Now.ToString("19900101.1"), PreReleaseVersionLabel = string.Empty };
}
throw new FormatException($"Can't derive a build ID from version {version} (commit count {commitCount}, release {string.Join(";", nugetVersion.Release.Split('-', '.'))})");
diff --git a/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets b/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
index a516a86cf..eb5858ba3 100644
--- a/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
+++ b/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
@@ -15,6 +15,7 @@
<PropertyGroup>
<ArtifactsDir>$(RepoRoot)artifacts/</ArtifactsDir>
<TarballDir>$(ArtifactsDir)tarball/</TarballDir>
+ <TarballNameDir>$([MSBuild]::MakeRelative($([System.IO.Path]::GetDirectoryName($(TarballDir))), $(TarballDir)))</TarballNameDir>
<TarballRootDir>$([MSBuild]::EnsureTrailingSlash('$(TarballDir)'))</TarballRootDir>
<TarballSourceDir>$(TarballRootDir)src/</TarballSourceDir>
<TarballGitInfoDir>$(TarballRootDir)git-info/</TarballGitInfoDir>
@@ -42,7 +43,7 @@
<Error Text="TarballFilePath not specified." Condition=" '$(TarballFilePath)' == '' " />
<MakeDir Directories="$(TarballFileDir)" Condition=" '$(TarballFileDir)' != '' " />
- <Exec Command="tar --numeric-owner -zcf $(TarballFilePath) -C $(TarballDir) ." />
+ <Exec Command="tar --format=gnu --sort=name --owner=0 --group=0 --numeric-owner --mtime='1990-01-01Z' -cf $(TarballFilePath) -C $(TarballDir)/.. $(TarballNameDir)" />
<Message Text="Tarball '$(TarballFilePath)' was successfully created from '$(TarballDir)'" Importance="High" />
</Target>
@@ -189,10 +190,10 @@
Command="git config --file $(TarballRepoSourceDir)/.git/config --add remote.origin.url $(OriginalRepoUri)"
WorkingDirectory="$(RepoRoot)"/>
- <!-- Remove the git objects folder to free up tarball space -->
+ <!-- Strips git directories / submodules to bare minimum for reproducibility -->
<Exec
- Command="rm -rf objects"
- WorkingDirectory="$(TarballRepoSourceDir).git"
+ Command="$(RepoRoot)/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball_strip-git.sh $(SourceDir)"
+ WorkingDirectory="$(TarballSourceDir)"
Condition="$(PreserveTarballGitFolders) != 'true'" />
<Message Text="--> Done Cloning Repo $(SourceBuildRepoName)" Importance="High" />
diff --git a/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball_strip-git.sh b/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball_strip-git.sh
new file mode 100755
index 000000000..63858732f
--- /dev/null
+++ b/src/installer/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball_strip-git.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+repodir="$1"
+
+gitdir="$repodir"/.git
+stripdir="$repodir"/.strip
+mkdir "$stripdir"
+
+commit=$(git -C "$repodir" rev-parse HEAD)
+url="$(grep -m 1 url "$gitdir"/config)"
+url=${url#*= }
+
+echo $commit > "$stripdir"/HEAD
+{
+echo "[remote \"origin\"]"
+echo " url = \"$url\""
+} > "$stripdir"/config
+
+if [ -f "$repodir"/.gitmodules ]; then
+ cat "$repodir"/.gitmodules >> "$stripdir"/config
+
+ for subdir in $(find "$gitdir"/modules -type f -name 'config'); do
+ subdir=${subdir/\/config}
+ substripdir="${subdir/.git/.strip}"
+ commit=$(git -C "$subdir" rev-parse HEAD)
+ url="$(grep -m 1 url "$subdir"/config)"
+ url=${url#*= }
+
+ mkdir -p "$substripdir"
+ echo $commit > "$substripdir"/HEAD
+ {
+ echo "[remote \"origin\"]"
+ echo " url = \"$url\""
+ } > "$substripdir"/config
+ done
+fi
+
+rm -fR "$gitdir"
+mv "$stripdir" "$gitdir"

View file

@ -0,0 +1,46 @@
From fb558e038ac3cf78b2c26ed24b99586fc97d82f1 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Fri, 21 Oct 2022 13:44:04 -0400
Subject: [PATCH 1/1] runtimepacks
Necessary for stage0, as installer doesn't pull runtime packs.
---
src/redist/targets/GenerateLayout.targets | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/installer/src/redist/targets/GenerateLayout.targets b/src/installer/src/redist/targets/GenerateLayout.targets
index 88a053b61..47aa38571 100644
--- a/src/installer/src/redist/targets/GenerateLayout.targets
+++ b/src/installer/src/redist/targets/GenerateLayout.targets
@@ -135,6 +135,13 @@
<RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
</BundledLayoutPackage>
+ <BundledLayoutPackage Include="MicrosoftNetCoreAppRuntimePackNupkg">
+ <PackageName>Microsoft.NETCore.App.Runtime.$(SharedFrameworkRid)</PackageName>
+ <PackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</PackageVersion>
+ <TargetFramework>$(TargetFramework)</TargetFramework>
+ <RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
+ </BundledLayoutPackage>
+
<BundledLayoutPackage Include="MicrosoftNetStandardTargetingPackNupkg">
<PackageName>NETStandard.Library.Ref</PackageName>
<PackageVersion>$(NETStandardLibraryRefPackageVersion)</PackageVersion>
@@ -149,6 +156,13 @@
<RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
</BundledLayoutPackage>
+ <BundledLayoutPackage Include="MicrosoftAspNetCoreAppRuntimePackNupkg">
+ <PackageName>Microsoft.AspNetCore.App.Runtime.$(SharedFrameworkRid)</PackageName>
+ <PackageVersion>$(MicrosoftAspNetCoreAppRefPackageVersion)</PackageVersion>
+ <TargetFramework>$(TargetFramework)</TargetFramework>
+ <RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
+ </BundledLayoutPackage>
+
<BundledLayoutPackage Include="MicrosoftNetCoreAppHostPackNupkg">
<PackageName>Microsoft.NETCore.App.Host.$(SharedFrameworkRid)</PackageName>
<PackageVersion>$(MicrosoftNETCoreAppHostPackageVersion)</PackageVersion>
--
2.36.3

View file

@ -0,0 +1,470 @@
From 210c17ea60f525837a7525df73e7332598ad4089 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/roslyn/pull/57003
From: Antoine Martin <dev@ayakael.net>
Date: Sat, 27 Aug 2022 21:26:01 -0800
Subject: [PATCH 1/1] mono-named-mutex
---
.../InternalUtilities/PlatformInformation.cs | 19 ++
.../VBCSCompilerTests/BuildClientTests.cs | 2 +-
.../CompilerServerApiTest.cs | 4 +-
.../VBCSCompilerTests/CompilerServerTests.cs | 4 +-
.../VBCSCompilerServerTests.cs | 7 +-
src/Compilers/Shared/BuildServerConnection.cs | 251 +++++++++++-------
6 files changed, 182 insertions(+), 105 deletions(-)
diff --git a/src/roslyn/src/Compilers/Core/Portable/InternalUtilities/PlatformInformation.cs b/src/roslyn/src/Compilers/Core/Portable/InternalUtilities/PlatformInformation.cs
index 033e66cd2f2..d4fa56413fb 100644
--- a/src/roslyn/src/Compilers/Core/Portable/InternalUtilities/PlatformInformation.cs
+++ b/src/roslyn/src/Compilers/Core/Portable/InternalUtilities/PlatformInformation.cs
@@ -31,5 +31,24 @@ public static bool IsRunningOnMono
}
}
}
+ /// <summary>
+ /// Are we running on .NET 5 or later using the Mono runtime?
+ /// Will also return true when running on Mono itself; if necessary
+ /// we can use IsRunningOnMono to distinguish.
+ /// </summary>
+ public static bool IsUsingMonoRuntime
+ {
+ get
+ {
+ try
+ {
+ return !(Type.GetType("Mono.RuntimeStructs", throwOnError: false) is null);
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ }
}
}
diff --git a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
index 669d1bfb676..7f1d0468823 100644
--- a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
+++ b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
@@ -79,7 +79,7 @@ public void ConnectToServerFails()
// to connect. When it fails it should fall back to in-proc
// compilation.
bool holdsMutex;
- using (var serverMutex = new Mutex(initiallyOwned: true,
+ using (var serverMutex = BuildServerConnection.OpenOrCreateMutex(
name: BuildServerConnection.GetServerMutexName(_pipeName),
createdNew: out holdsMutex))
{
diff --git a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
index 0dbd1b2e143..c00b72e8434 100644
--- a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
+++ b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerApiTest.cs
@@ -103,7 +103,7 @@ public void MutexStopsServerStarting()
var mutexName = BuildServerConnection.GetServerMutexName(pipeName);
bool holdsMutex;
- using (var mutex = new Mutex(initiallyOwned: true,
+ using (var mutex = BuildServerConnection.OpenOrCreateMutex(
name: mutexName,
createdNew: out holdsMutex))
{
@@ -119,7 +119,7 @@ public void MutexStopsServerStarting()
}
finally
{
- mutex.ReleaseMutex();
+ mutex.Dispose();
}
}
}
diff --git a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
index 3b6f4f291ff..e97a6bf923f 100644
--- a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
+++ b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/CompilerServerTests.cs
@@ -304,7 +304,7 @@ public async Task ServerFailsWithLongTempPathUnix()
var newTempDir = _tempDirectory.CreateDirectory(new string('a', 100 - _tempDirectory.Path.Length));
await ApplyEnvironmentVariables(
new[] { new KeyValuePair<string, string>("TMPDIR", newTempDir.Path) },
- async () =>
+ async () => await Task.Run(async () =>
{
using var serverData = await ServerUtil.CreateServer(_logger);
var result = RunCommandLineCompiler(
@@ -317,7 +317,7 @@ public async Task ServerFailsWithLongTempPathUnix()
var listener = await serverData.Complete();
Assert.Equal(CompletionData.RequestCompleted, listener.CompletionDataList.Single());
- });
+ }));
}
[Fact]
diff --git a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/VBCSCompilerServerTests.cs b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/VBCSCompilerServerTests.cs
index d5f493fed8a..73941972e48 100644
--- a/src/roslyn/src/Compilers/Server/VBCSCompilerTests/VBCSCompilerServerTests.cs
+++ b/src/roslyn/src/Compilers/Server/VBCSCompilerTests/VBCSCompilerServerTests.cs
@@ -101,7 +101,7 @@ public async Task NoServerConnection()
var thread = new Thread(() =>
{
- using (var mutex = new Mutex(initiallyOwned: true, name: mutexName, createdNew: out created))
+ using (var mutex = BuildServerConnection.OpenOrCreateMutex(name: mutexName, createdNew: out created))
using (var stream = NamedPipeUtil.CreateServer(pipeName))
{
readyMre.Set();
@@ -112,7 +112,7 @@ public async Task NoServerConnection()
stream.Close();
doneMre.WaitOne();
- mutex.ReleaseMutex();
+ mutex.Dispose();
}
});
@@ -153,7 +153,7 @@ public async Task ServerShutdownsDuringProcessing()
{
using (var stream = NamedPipeUtil.CreateServer(pipeName))
{
- var mutex = new Mutex(initiallyOwned: true, name: mutexName, createdNew: out created);
+ var mutex = BuildServerConnection.OpenOrCreateMutex(name: mutexName, createdNew: out created);
readyMre.Set();
stream.WaitForConnection();
@@ -161,7 +161,6 @@ public async Task ServerShutdownsDuringProcessing()
// Client is waiting for a response. Close the mutex now. Then close the connection
// so the client gets an error.
- mutex.ReleaseMutex();
mutex.Dispose();
stream.Close();
diff --git a/src/roslyn/src/Compilers/Shared/BuildServerConnection.cs b/src/roslyn/src/Compilers/Shared/BuildServerConnection.cs
index f67c2d83957..1fe609061ee 100644
--- a/src/roslyn/src/Compilers/Shared/BuildServerConnection.cs
+++ b/src/roslyn/src/Compilers/Shared/BuildServerConnection.cs
@@ -543,19 +543,10 @@ internal static bool WasServerMutexOpen(string mutexName)
{
try
{
- if (PlatformInformation.IsRunningOnMono)
+ if (PlatformInformation.IsUsingMonoRuntime)
{
- IServerMutex? mutex = null;
- bool createdNew = false;
- try
- {
- mutex = new ServerFileMutexPair(mutexName, false, out createdNew);
- return !createdNew;
- }
- finally
- {
- mutex?.Dispose();
- }
+ using var mutex = new ServerFileMutex(mutexName);
+ return !mutex.CouldLock();
}
else
{
@@ -572,9 +563,11 @@ internal static bool WasServerMutexOpen(string mutexName)
internal static IServerMutex OpenOrCreateMutex(string name, out bool createdNew)
{
- if (PlatformInformation.IsRunningOnMono)
+ if (PlatformInformation.IsUsingMonoRuntime)
{
- return new ServerFileMutexPair(name, initiallyOwned: true, out createdNew);
+ var mutex = new ServerFileMutex(name);
+ createdNew = mutex.TryLock(0);
+ return mutex;
}
else
{
@@ -648,19 +641,22 @@ internal interface IServerMutex : IDisposable
}
/// <summary>
- /// An interprocess mutex abstraction based on OS advisory locking (FileStream.Lock/Unlock).
+ /// An interprocess mutex abstraction based on file sharing permission (FileShare.None).
/// If multiple processes running as the same user create FileMutex instances with the same name,
/// those instances will all point to the same file somewhere in a selected temporary directory.
- /// The TryLock method can be used to attempt to acquire the mutex, with Unlock or Dispose used to release.
+ /// The TryLock method can be used to attempt to acquire the mutex, with Dispose used to release.
+ /// The CouldLock method can be used to check whether an attempt to acquire the mutex would have
+ /// succeeded at the current time, without actually acquiring it.
/// Unlike Win32 named mutexes, there is no mechanism for detecting an abandoned mutex. The file
/// will simply revert to being unlocked but remain where it is.
/// </summary>
- internal sealed class FileMutex : IDisposable
+ internal sealed class ServerFileMutex : IServerMutex
{
- public readonly FileStream Stream;
+ public FileStream? Stream;
public readonly string FilePath;
+ public readonly string GuardPath;
- public bool IsLocked { get; private set; }
+ public bool IsDisposed { get; private set; }
internal static string GetMutexDirectory()
{
@@ -670,61 +666,176 @@ internal static string GetMutexDirectory()
return result;
}
- public FileMutex(string name)
+ public ServerFileMutex(string name)
{
- FilePath = Path.Combine(GetMutexDirectory(), name);
- Stream = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
+ var mutexDirectory = GetMutexDirectory();
+ FilePath = Path.Combine(mutexDirectory, name);
+ GuardPath = Path.Combine(mutexDirectory, ".guard");
}
- public bool TryLock(int timeoutMs)
+ /// <summary>
+ /// Acquire the guard by opening the guard file with FileShare.None. The guard must only ever
+ /// be held for very brief amounts of time, so we can simply spin until it is acquired. The
+ /// guard must be released by disposing the FileStream returned from this routine. Note the
+ /// guard file is never deleted; this is a leak, but only of a single file.
+ /// </summary>
+ internal FileStream LockGuard()
{
- if (IsLocked)
- throw new InvalidOperationException("Lock already held");
-
- var sw = Stopwatch.StartNew();
- do
+ // We should be able to acquire the guard quickly. Limit the number of retries anyway
+ // by some arbitrary bound to avoid getting hung up in a possibly infinite loop.
+ for (var i = 0; i < 100; i++)
{
try
{
- Stream.Lock(0, 0);
- IsLocked = true;
- return true;
+ return new FileStream(GuardPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
- // Lock currently held by someone else.
+ // Guard currently held by someone else.
// We want to sleep for a short period of time to ensure that other processes
// have an opportunity to finish their work and relinquish the lock.
// Spinning here (via Yield) would work but risks creating a priority
// inversion if the lock is held by a lower-priority process.
Thread.Sleep(1);
}
+ }
+ // Handle unexpected failure to acquire guard as error.
+ throw new InvalidOperationException("Unable to acquire guard");
+ }
+
+ /// <summary>
+ /// Attempt to acquire the lock by opening the lock file with FileShare.None. Sets "Stream"
+ /// and returns true if successful, returns false if the lock is already held by another
+ /// thread or process. Guard must be held when calling this routine.
+ /// </summary>
+ internal bool TryLockFile()
+ {
+ Debug.Assert(Stream is null);
+ FileStream? stream = null;
+ try
+ {
+ stream = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
+ // On some targets, the file locking used to implement FileShare.None may not be
+ // atomic with opening/creating the file. This creates a race window when another
+ // thread holds the lock and is just about to unlock: we may be able to open the
+ // file here, then the other thread unlocks and deletes the file, and then we
+ // acquire the lock on our file handle - but the actual file is already deleted.
+ // To close this race, we verify that the file does in fact still exist now that
+ // we have successfull acquired the locked FileStream. (Note that this check is
+ // safe because we cannot race with an other attempt to create the file since we
+ // hold the guard, and after the FileStream constructor returned we can no race
+ // with file deletion because we hold the lock.)
+ if (!File.Exists(FilePath))
+ {
+ // To simplify the logic, we treat this case as "unable to acquire the lock"
+ // because it we caught another process while it owned the lock and was just
+ // giving it up. If the caller retries, we'll likely acquire the lock then.
+ stream.Dispose();
+ return false;
+ }
+ }
+ catch (Exception)
+ {
+ stream?.Dispose();
+ return false;
+ }
+ Stream = stream;
+ return true;
+ }
+
+ /// <summary>
+ /// Release the lock by deleting the lock file and disposing "Stream".
+ /// </summary>
+ internal void UnlockFile()
+ {
+ Debug.Assert(Stream is not null);
+ try
+ {
+ // Delete the lock file while the stream is not yet disposed
+ // and we therefore still hold the FileShare.None exclusion.
+ // There may still be a race with another thread attempting a
+ // TryLockFile in parallel, but that is safely handled there.
+ File.Delete(FilePath);
+ }
+ finally
+ {
+ Stream.Dispose();
+ Stream = null;
+ }
+ }
+
+ public bool TryLock(int timeoutMs)
+ {
+ if (IsDisposed)
+ throw new ObjectDisposedException("Mutex");
+ if (Stream is not null)
+ throw new InvalidOperationException("Lock already held");
+
+ var sw = Stopwatch.StartNew();
+ do
+ {
+ try
+ {
+ // Attempt to acquire lock while holding guard.
+ using var guard = LockGuard();
+ if (TryLockFile())
+ return true;
+ }
catch (Exception)
{
- // Something else went wrong.
return false;
}
+
+ // See comment in LockGuard.
+ Thread.Sleep(1);
} while (sw.ElapsedMilliseconds < timeoutMs);
return false;
}
- public void Unlock()
+ public bool CouldLock()
{
- if (!IsLocked)
- return;
- Stream.Unlock(0, 0);
- IsLocked = false;
+ if (IsDisposed)
+ return false;
+ if (Stream is not null)
+ return false;
+
+ try
+ {
+ // Attempt to acquire lock while holding guard, and if successful
+ // immediately unlock again while still holding guard. This ensures
+ // no other thread will spuriously observe the lock as held due to
+ // the lock attempt here.
+ using var guard = LockGuard();
+ if (TryLockFile())
+ {
+ UnlockFile();
+ return true;
+ }
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ return false;
}
public void Dispose()
{
- var wasLocked = IsLocked;
- if (wasLocked)
- Unlock();
- Stream.Dispose();
- // We do not delete the lock file here because there is no reliable way to perform a
- // 'delete if no one has the file open' operation atomically on *nix. This is a leak.
+ if (IsDisposed)
+ return;
+ IsDisposed = true;
+ if (Stream is not null)
+ {
+ try
+ {
+ UnlockFile();
+ }
+ catch (Exception)
+ {
+ }
+ }
}
}
@@ -792,56 +903,4 @@ public void Dispose()
}
}
}
-
- /// <summary>
- /// Approximates a named mutex with 'locked', 'unlocked' and 'abandoned' states.
- /// There is no reliable way to detect whether a mutex has been abandoned on some target platforms,
- /// so we use the AliveMutex to manually track whether the creator of a mutex is still running,
- /// while the HeldMutex represents the actual lock state of the mutex.
- /// </summary>
- internal sealed class ServerFileMutexPair : IServerMutex
- {
- public readonly FileMutex AliveMutex;
- public readonly FileMutex HeldMutex;
-
- public bool IsDisposed { get; private set; }
-
- public ServerFileMutexPair(string mutexName, bool initiallyOwned, out bool createdNew)
- {
- AliveMutex = new FileMutex(mutexName + "-alive");
- HeldMutex = new FileMutex(mutexName + "-held");
- createdNew = AliveMutex.TryLock(0);
- if (initiallyOwned && createdNew)
- {
- if (!TryLock(0))
- throw new Exception("Failed to lock mutex after creating it");
- }
- }
-
- public bool TryLock(int timeoutMs)
- {
- if (IsDisposed)
- throw new ObjectDisposedException("Mutex");
- return HeldMutex.TryLock(timeoutMs);
- }
-
- public void Dispose()
- {
- if (IsDisposed)
- return;
- IsDisposed = true;
-
- try
- {
- HeldMutex.Unlock();
- AliveMutex.Unlock();
- }
- finally
- {
- AliveMutex.Dispose();
- HeldMutex.Dispose();
- }
- }
- }
-
}
--
2.36.2

View file

@ -0,0 +1,13 @@
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,32 @@
From 3e75c1b17777befc94689de319fff7a40a1f86bc Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Tue, 23 Aug 2022 14:17:51 -0800
Subject: [PATCH 1/1] Revert "lift version of Microsoft.CodeAnalysis.Common
dependencies to previously source built version"
This reverts commit 7b504d40a3876ce14323d77e282f0fb7ea1ec758, a patch
applied by installer during tarball generation that only is only needed
when building the whole source-build stack. Within stage0, this is
breaks the build
---
.../Source/CSharpSyntaxGenerator/CSharpSyntaxGenerator.csproj | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/roslyn/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/CSharpSyntaxGenerator.csproj b/src/roslyn/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/CSharpSyntaxGenerator.csproj
index a50822a6aeb..7eae8afa275 100644
--- a/src/roslyn/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/CSharpSyntaxGenerator.csproj
+++ b/src/roslyn/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/CSharpSyntaxGenerator.csproj
@@ -27,9 +27,5 @@
<Compile Include="..\..\..\..\..\Compilers\CSharp\Portable\Syntax\SyntaxKindFacts.cs" Link="Grammar\SyntaxKindFacts.cs" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(SourceGeneratorMicrosoftCodeAnalysisVersion)" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
- <PackageReference Include="System.Collections.Immutable" Version="$(SourceBuildLiftedSystemCollectionsImmutableVersion)" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
- <PackageReference Include="System.Reflection.Metadata" Version="$(SourceBuildLiftedSystemReflectionMetadataVersion)" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
- <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="$(SourceBuildLiftedSystemRuntimeCompilerServicesUnsafeVersion)" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
- <PackageReference Include="System.Text.Encoding.CodePages" Version="$(SourceBuildLiftedSystemTextEncodingCodePagesVersion)" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
</ItemGroup>
</Project>
\ No newline at end of file
--
2.36.2

View file

@ -0,0 +1,189 @@
From f54977e2fc84527fe58024ed5537cb63244168e2 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/runtime/pull/76500
From: Antoine Martin <dev@ayakael.net>
Date: Tue, 13 Sep 2022 14:17:35 +0200
Subject: [PATCH 1/1] Mono musl support
---
src/coreclr/pal/src/misc/perfjitdump.cpp | 2 +-
src/mono/CMakeLists.txt | 29 ++++++++++++++++++++++++
src/mono/mono.proj | 18 +++++++++------
src/mono/mono/metadata/domain.c | 10 ++++++++
src/mono/mono/mini/CMakeLists.txt | 10 ++++++++
src/mono/mono/utils/mono-context.h | 8 +++++++
6 files changed, 69 insertions(+), 8 deletions(-)
diff --git a/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp b/src/runtime/src/coreclr/pal/src/misc/perfjitdump.cpp
index d80bd58038c..3488397b0da 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/mono/CMakeLists.txt b/src/runtime/src/mono/CMakeLists.txt
index 49a73b1b709..7e596d69d35 100644
--- a/src/runtime/src/mono/CMakeLists.txt
+++ b/src/runtime/src/mono/CMakeLists.txt
@@ -208,6 +208,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)
diff --git a/src/runtime/src/mono/mono.proj b/src/runtime/src/mono/mono.proj
index d6a0c9a8ec2..933ed60cea7 100644
--- a/src/runtime/src/mono/mono.proj
+++ b/src/runtime/src/mono/mono.proj
@@ -417,11 +417,15 @@
<!-- Linux options -->
<ItemGroup Condition="'$(TargetsLinux)' == true">
<_MonoCFLAGS Include="-Wl,--build-id=sha1" />
+ <_MonoCFLAGS Include="-Wno-strict-prototypes" />
<_MonoCXXFLAGS Include="-Wl,--build-id=sha1" />
+ <_MonoCXXFLAGS Include="-Wno-strict-prototypes" />
</ItemGroup>
<ItemGroup Condition="'$(RealTargetOS)' == 'Linux'">
<_MonoAOTCFLAGS Include="-Wl,--build-id=sha1" />
+ <_MonoAOTCFLAGS Include="-Wno-strict-prototypes" />
<_MonoAOTCXXFLAGS Include="-Wl,--build-id=sha1" />
+ <_MonoAOTCXXFLAGS Include="-Wno-strict-prototypes" />
</ItemGroup>
<!-- Devloop features -->
@@ -500,15 +504,15 @@
<MonoToolchainPrebuiltOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">darwin-x86_64</MonoToolchainPrebuiltOS>
<MonoToolchainPrebuiltOS Condition="'$(OS)' == 'Windows_NT'">windows-x86_64</MonoToolchainPrebuiltOS>
<_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
- <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true'">gnu</_LinuxAbi>
- <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true'">android</_LinuxAbi>
+ <_LinuxAbi Condition="'$(TargetsAndroid)' != 'true'">alpine-linux-musl</_LinuxAbi>
+ <_LinuxAbi Condition="'$(TargetsAndroid)' == 'true'">linux-android</_LinuxAbi>
<_LinuxFloatAbi Condition="'$(TargetsAndroid)' != 'true'">hf</_LinuxFloatAbi>
<_Objcopy>objcopy</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'arm'">arm-linux-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 'arm64'">aarch64-linux-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
- <_Objcopy Condition="'$(Platform)' == 's390x'">s390x-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' and '$(CrossBuild)' == 'true'">arm-$(_LinuxAbi)eabi$(_LinuxFloatAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'arm64' and '$(CrossBuild)' == 'true'">aarch64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 's390x' and '$(CrossBuild)' == 'true'">s390x-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'x64' and '$(CrossBuild)' == 'true'">x86_64-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
+ <_Objcopy Condition="'$(Platform)' == 'x86' and '$(CrossBuild)' == 'true'">i686-$(_LinuxAbi)-$(_Objcopy)</_Objcopy>
<_Objcopy Condition="'$(TargetsAndroid)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/$(_Objcopy)</_Objcopy>
</PropertyGroup>
<!-- test viability of objcopy command -->
diff --git a/src/runtime/src/mono/mono/metadata/domain.c b/src/runtime/src/mono/mono/metadata/domain.c
index 4a8e06d28ae..e9868bd1b2c 100644
--- a/src/runtime/src/mono/mono/metadata/domain.c
+++ b/src/runtime/src/mono/mono/metadata/domain.c
@@ -138,6 +138,14 @@ create_root_domain (void)
return domain;
}
+static MONO_NO_OPTIMIZATION MONO_NEVER_INLINE void
+ensure_stack_size (void)
+{
+ const int default_size = 5 * 1024 * 1024;
+ volatile uint8_t *s = (uint8_t *)g_alloca(default_size);
+ *s = 0;
+}
+
/**
* mono_init_internal:
*
@@ -181,6 +189,8 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
mono_counters_register ("Max HashTable Chain Length", MONO_COUNTER_INT|MONO_COUNTER_METADATA, &mono_g_hash_table_max_chain_length);
+ ensure_stack_size ();
+
mono_gc_base_init ();
mono_thread_info_attach ();
diff --git a/src/runtime/src/mono/mono/mini/CMakeLists.txt b/src/runtime/src/mono/mono/mini/CMakeLists.txt
index 128ed08f45b..17cbe696c4b 100644
--- a/src/runtime/src/mono/mono/mini/CMakeLists.txt
+++ b/src/runtime/src/mono/mono/mini/CMakeLists.txt
@@ -364,6 +364,11 @@ if(NOT DISABLE_SHARED_LIBS)
set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib")
endif()
target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${ICONV_LIB} ${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(monosgen-shared PRIVATE ucontext)
+ endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
+
if(ICU_LDFLAGS)
set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}")
endif()
@@ -488,6 +493,11 @@ if(NOT DISABLE_EXECUTABLES)
set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross)
endif()
target_link_libraries(mono-sgen PRIVATE monosgen-static ${OS_LIBS} ${ICONV_LIB} ${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/utils/mono-context.h b/src/runtime/src/mono/mono/utils/mono-context.h
index bd1a3cd0104..db4ba452bcb 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"
--
2.36.3

View file

@ -0,0 +1,12 @@
diff --git a/src/runtime/src/libraries/Native/Unix/CMakeLists.txt.orig b/src/runtime/src/libraries/Native/Unix/CMakeLists.txt
index 6931f62d24c..25abeecd5b6 100644
--- a/src/runtime/src/libraries/Native/Unix/CMakeLists.txt.orig
+++ b/src/runtime/src/libraries/Native/Unix/CMakeLists.txt
@@ -38,6 +38,7 @@ add_compile_options(-Wno-c11-extensions)
add_compile_options(-Wno-unknown-pragmas)
add_compile_options(-Wno-unknown-warning-option)
add_compile_options(-Wno-unused-but-set-variable)
+add_compile_options(-Wno-strict-prototypes)
check_c_compiler_flag(-Wimplicit-fallthrough COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)
if (COMPILER_SUPPORTS_W_IMPLICIT_FALLTHROUGH)

View file

@ -0,0 +1,31 @@
From 91988b0241a77f1f6524c19e2ce55dda06de7242 Mon Sep 17 00:00:00 2001
Patch-Source: https://src.fedoraproject.org/rpms/dotnet6.0/blob/src/runtime/rawhide/f/runtime-arm64-lld-fix.patch
From: Omair Majid <omajid@redhat.com>
Date: Wed, 16 Feb 2022 18:08:22 +0000
Subject: [PATCH 1/1] arm64 lld fix
---
eng/native/init-compiler.sh | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/runtime/eng/native/init-compiler.sh b/src/runtime/eng/native/init-compiler.sh
index 567d18da474..05245c7b9f8 100755
--- a/src/runtime/eng/native/init-compiler.sh
+++ b/src/runtime/eng/native/init-compiler.sh
@@ -108,11 +108,8 @@ if [[ -z "$CC" ]]; then
fi
if [[ "$compiler" == "clang" ]]; then
- if command -v "lld$desired_version" > /dev/null; then
- # Only lld version >= 9 can be considered stable
- if [[ "$majorVersion" -ge 9 ]]; then
- LDFLAGS="-fuse-ld=lld"
- fi
+ if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then
+ LDFLAGS="-fuse-ld=lld"
fi
fi
--
2.34.1

View file

@ -0,0 +1,26 @@
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] No additional runtime id
For some reason, AdditionalRuntimeIdentifiers gets set as '$arch' rather than 'linux-musl-$arch'
Since we know our portable RID exists, just skip ensuring RID existence
---
diff --git a/src/runtime/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj b/src/runtime/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj
index 5ff979046a5..e0af5d1ca02 100644
--- a/src/runtime/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj
+++ b/src/runtime/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj
@@ -16,9 +16,6 @@
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<NoWarn>$(NoWarn);NU5128</NoWarn> <!-- No Dependencies-->
<PackageDescription>Provides runtime information required to resolve target framework, platform, and runtime specific implementations of .NETCore packages.</PackageDescription>
-
- <!-- When building from source, ensure the RID we're building for is part of the RID graph -->
- <AdditionalRuntimeIdentifiers Condition="'$(DotNetBuildFromSource)' == 'true'">$(AdditionalRuntimeIdentifiers);$(OutputRID)</AdditionalRuntimeIdentifiers>
<ServicingVersion>7</ServicingVersion>
</PropertyGroup>
--
2.37.1

View file

@ -0,0 +1,40 @@
From b99f2106370e1af3ecd116576341b94319cbd332 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Sun, 18 Sep 2022 00:45:20 +0000
Subject: [PATCH 1/1] s390x fixes
---
src/runtime/eng/common/cross/toolchain.cmake | 7 ++++++-
.../eng/common/native/init-compiler.sh | 2 +-
6 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/src/runtime/eng/common/cross/toolchain.cmake b/src/runtime/eng/common/cross/toolchain.cmake
index 561576be9..8a81d0387 100644
--- a/src/runtime/eng/common/cross/toolchain.cmake
+++ b/src/runtime/eng/common/cross/toolchain.cmake
@@ -38,7 +38,11 @@ elseif(TARGET_ARCH_NAME STREQUAL "arm64")
endif()
elseif(TARGET_ARCH_NAME STREQUAL "s390x")
set(CMAKE_SYSTEM_PROCESSOR s390x)
- set(TOOLCHAIN "s390x-linux-gnu")
+ if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl)
+ set(TOOLCHAIN "s390x-alpine-linux-musl")
+ else()
+ set(TOOLCHAIN "s390x-linux-gnu")
+ endif()
elseif(TARGET_ARCH_NAME STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR i686)
set(TOOLCHAIN "i686-linux-gnu")
diff --git a/src/runtime/eng/native/init-compiler.sh b/src/runtime/eng/native/init-compiler.sh
index 567d18da474..62f6db47959 100755
--- a/src/runtime/eng/native/init-compiler.sh
+++ b/src/runtime/eng/native/init-compiler.sh
@@ -109,7 +109,7 @@
if [[ "$compiler" == "clang" ]]; then
if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then
- LDFLAGS="-fuse-ld=lld"
+ [ -f "$ROOTFS_DIR/usr/bin/lld" ] && LDFLAGS="-fuse-ld=lld"
fi
fi

View file

@ -0,0 +1,55 @@
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] dummy-shim-fix
Hack for building sdk within stage0, which expects to be built using the
whole stack.
---
build/GenerateResxSource.targets | 1 -
scripts/register-completions.zsh | 13 +++----------
.../Microsoft.DotNet.PackageInstall.Tests.csproj | 1 -
.../SampleGlobalToolWithShim/includepublish.nuspec | 4 +---
4 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/src/sdk/build/GenerateResxSource.targets b/src/sdk/build/GenerateResxSource.targets
index 239665655d..b47510d901 100644
--- a/src/sdk/build/GenerateResxSource.targets
+++ b/src/sdk/build/GenerateResxSource.targets
@@ -1,7 +1,6 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_CustomizeXlfSourceNames"
- DependsOnTargets="_CustomizeResourceNames"
BeforeTargets="PrepareResourceNames;GatherXlf"
>
<ItemGroup>
index a147870bcb..f673e4e21b 100644
--- a/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj
+++ b/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/Microsoft.DotNet.PackageInstall.Tests.csproj
@@ -107,7 +107,6 @@
</PropertyGroup>
<Copy SourceFiles="SampleGlobalToolWithShim/DotnetToolSettings.xml" DestinationFolder="$(testAssetSourceRoot)" />
<Copy SourceFiles="SampleGlobalToolWithShim/dummyshim" DestinationFolder="$(testAssetSourceRoot)" />
- <Copy SourceFiles="SampleGlobalToolWithShim/dummyshim.exe" DestinationFolder="$(testAssetSourceRoot)" />
<MSBuild BuildInParallel="False" Projects="SampleGlobalToolWithShim/consoledemo.csproj" Targets="Restore" Properties="Configuration=Release;BaseOutputPath=$(testAssetSourceRoot)/bin/;BaseIntermediateOutputPath=$(testAssetSourceRoot)/obj/;ImportDirectoryBuildProps=false;ImportDirectoryBuildTargets=false;ForceRestoreToEvaluateSeparately=1"
RemoveProperties="TargetFramework">
</MSBuild>
diff --git a/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/SampleGlobalToolWithShim/includepublish.nuspec b/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/SampleGlobalToolWithShim/includepublish.nuspec
index b2ed9d349c..d760d5f772 100644
--- a/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/SampleGlobalToolWithShim/includepublish.nuspec
+++ b/src/sdk/src/Tests/Microsoft.DotNet.PackageInstall.Tests/SampleGlobalToolWithShim/includepublish.nuspec
@@ -12,9 +12,7 @@
<files>
<file src="bin\Release\netcoreapp2.1\publish\*.*" target="tools\netcoreapp2.1\any\" />
<file src="DotnetToolSettings.xml" target="tools\netcoreapp2.1\any\DotnetToolSettings.xml" />
- <file src="dummyshim.exe" target="tools\netcoreapp2.1\any\shims\win-x64\demo.exe" />
- <file src="dummyshim.exe" target="tools\netcoreapp2.1\any\shims\win-x86\demo.exe" />
<file src="dummyshim" target="tools\netcoreapp2.1\any\shims\osx-x64\demo" />
<file src="dummyshim" target="tools\netcoreapp2.1\any\shims\linux\demo" />
</files>
</package>
--
2.37.1