Skip to content

Commit 7f3a74c

Browse files
committed
Fix build against musl
1 parent 40c798a commit 7f3a74c

File tree

7 files changed

+73
-16
lines changed

7 files changed

+73
-16
lines changed

src/SourceBuild/tarball/content/Directory.Build.props

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,6 @@
170170
<ArmEnvironmentVariables Condition="'$(Platform)' == 'armel'">ROOTFS_DIR=$(BaseIntermediatePath)crossrootfs/armel</ArmEnvironmentVariables>
171171
</PropertyGroup>
172172

173-
<PropertyGroup>
174-
<TargetRid Condition="'$(TargetRid)' == ''">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</TargetRid>
175-
176-
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS'))">Windows_NT</TargetOS>
177-
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">OSX</TargetOS>
178-
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('LINUX'))">Linux</TargetOS>
179-
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD'))">FreeBSD</TargetOS>
180-
181-
<PortableRid Condition="'$(TargetOS)' == 'FreeBSD'">freebsd-$(Platform)</PortableRid>
182-
<PortableRid Condition="'$(TargetOS)' == 'OSX'">osx-$(Platform)</PortableRid>
183-
<PortableRid Condition="'$(TargetOS)' == 'Linux'">linux-$(Platform)</PortableRid>
184-
<PortableRid Condition="'$(TargetOS)' == 'Windows_NT'">win-$(Platform)</PortableRid>
185-
<TargetRid Condition="'$(PortableBuild)' == 'true' AND '$(PortableRid)' != ''">$(PortableRid)</TargetRid>
186-
</PropertyGroup>
187-
188173
<PropertyGroup>
189174
<!-- known-good (repos/known-good.proj) conditionally includes submodules based on the platform,
190175
so this will not always correspond to the same repos - see that file for details.

src/SourceBuild/tarball/content/Directory.Build.targets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
</ItemGroup>
1111
</Target>
1212

13+
<Target Name="GetOSPlatformIsMuslCheck"
14+
BeforeTargets="CollectPackageReferences">
15+
<Exec IgnoreExitCode="true" Command="ldd --version 2&gt;&amp;1 | grep -q musl">
16+
<Output TaskParameter="ExitCode" PropertyName="OSPlatformIsMuslCheck" />
17+
</Exec>
18+
</Target>
19+
1320
<Import Condition="'$(SkipArcadeSdkImport)' != 'true'" Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
1421

1522
</Project>

src/SourceBuild/tarball/content/repos/aspnetcore.proj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<!-- https://github.com/dotnet/sdk/pull/20136 has not flowed into our bootstrap SDK yet, which causes file-in-use issues in ASP.NET
1616
due to an interaction with the RemoveSharedFrameworkDependencies task. disable package validation until this is fixed. -->
1717
<BuildCommandArgs>$(BuildCommandArgs) /p:EnablePackageValidation=false</BuildCommandArgs>
18+
<!-- below is temporary fix till https://github.com/dotnet/aspnetcore/issues/39822 is addressed -->
19+
<BuildCommandArgs Condition="'$(OSPlatformIsMusl)' == 'true'">$(BuildCommandArgs) --os-name linux-musl</BuildCommandArgs>
1820
<BuildCommand>$(ProjectDirectory)\eng\build$(ShellExtension) $(BuildCommandArgs)</BuildCommand>
1921

2022
<LogVerbosityOptOut>true</LogVerbosityOptOut>

src/SourceBuild/tarball/content/repos/installer.proj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux'">$(BuildCommandArgs) /p:Rid=$(TargetRid)</BuildCommandArgs>
2626
<BuildCommandArgs>$(BuildCommandArgs) /p:DOTNET_INSTALL_DIR=$(DotNetCliToolDir)</BuildCommandArgs>
2727

28-
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux'">$(BuildCommandArgs) /p:AspNetCoreInstallerRid=linux-$(Platform)</BuildCommandArgs>
28+
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux' AND '$(OSPlatformIsMusl)' == 'false'">$(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-$(Platform)</BuildCommandArgs>
29+
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux' AND '$(OSPlatformIsMusl)' == 'true'">$(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-musl-$(Platform)</BuildCommandArgs>
30+
2931
<!-- core-sdk always wants to build portable on OSX and FreeBSD -->
3032
<BuildCommandArgs Condition="'$(TargetOS)' == 'FreeBSD'">$(BuildCommandArgs) /p:CoreSetupRid=freebsd-x64 /p:PortableBuild=true</BuildCommandArgs>
3133
<BuildCommandArgs Condition="'$(TargetOS)' == 'OSX'">$(BuildCommandArgs) /p:CoreSetupRid=osx-x64</BuildCommandArgs>

src/SourceBuild/tarball/content/tools-local/init-build.proj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<Target Name="Build">
2222
<CallTarget Targets="
23+
InitTargetRid;
2324
UnpackTarballs;
2425
BuildXPlatTasks;
2526
BuildLeakDetection;
@@ -29,6 +30,26 @@
2930
PoisonPrebuiltPackages" />
3031
</Target>
3132

33+
<Target Name="InitTargetRid"
34+
DependsOnTargets="GetOSPlatformIsMuslCheck" />
35+
<PropertyGroup>
36+
<OSPlatformIsMusl Condition="$(OSPlatformIsMuslCheck) == '0'">true</OSPlatformIsMusl>
37+
<OSPlatformIsMusl Condition="$(OSPlatformIsMusl) == ''">false</OSPlatformIsMusl>
38+
<TargetRid Condition="'$(TargetRid)' == ''">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</TargetRid>
39+
40+
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS'))">Windows_NT</TargetOS>
41+
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">OSX</TargetOS>
42+
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('LINUX'))">Linux</TargetOS>
43+
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD'))">FreeBSD</TargetOS>
44+
45+
<PortableRid Condition="'$(TargetOS)' == 'FreeBSD'">freebsd-$(Platform)</PortableRid>
46+
<PortableRid Condition="'$(TargetOS)' == 'OSX'">osx-$(Platform)</PortableRid>
47+
<PortableRid Condition="'$(TargetOS)' == 'Linux'">linux-$(Platform)</PortableRid>
48+
<PortableRid Condition="'$(TargetOS)' == 'Windows_NT'">win-$(Platform)</PortableRid>
49+
<TargetRid Condition="'$(PortableBuild)' == 'true' AND '$(PortableRid)' != ''">$(PortableRid)</TargetRid>
50+
</PropertyGroup>
51+
</Target>
52+
3253
<Target Name="PrepareOfflineLocalTools"
3354
DependsOnTargets="
3455
ExtractToolPackage;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 451aa3e9544b0214d0e8e844c27af3847f5bf391 Mon Sep 17 00:00:00 2001
2+
From: Antoine Martin <[email protected]>
3+
Date: Fri, 18 Feb 2022 05:14:39 +0000
4+
Subject: [PATCH 1/1] musl build fix
5+
6+
Line causes build of aspnetcore on arm to look for linux version of
7+
CrossGen2 rather than linux-musl. This removes the line so that
8+
BuildOsName is pulled from TargetOsName as expected
9+
10+
Will be fixed once https://github.com/dotnet/aspnetcore/issues/37400
11+
is addressed.
12+
13+
---
14+
.../App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj | 1 -
15+
1 file changed, 1 deletion(-)
16+
17+
diff --git a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
18+
index aeb3c08f13..380fc5fbac 100644
19+
--- a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
20+
+++ b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
21+
@@ -104,7 +104,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
22+
Special case the crossgen2 package reference on Windows to avoid the x86 package when building in Visual Studio.
23+
-->
24+
<BuildOsName>$(TargetOsName)</BuildOsName>
25+
- <BuildOsName Condition="'$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'">linux</BuildOsName>
26+
<Crossgen2BuildArchitecture Condition=" '$(BuildOsName)' == 'win' ">x64</Crossgen2BuildArchitecture>
27+
<Crossgen2BuildArchitecture Condition=" '$(Crossgen2BuildArchitecture)' == '' ">$(BuildArchitecture)</Crossgen2BuildArchitecture>
28+
<Crossgen2PackageRootVariableName>PkgMicrosoft_NETCore_App_Crossgen2_$(BuildOsName)-$(Crossgen2BuildArchitecture)</Crossgen2PackageRootVariableName>
29+
--
30+
2.34.1
31+

src/redist/targets/GetRuntimeInformation.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<Project>
22
<Target Name="GetCurrentRuntimeInformation">
3+
<Exec IgnoreExitCode="true" Command="ldd --version 2&gt;&amp;1 | grep -q musl">
4+
<Output TaskParameter="ExitCode" PropertyName="OSPlatformIsMuslCheck" />
5+
</Exec>
6+
37
<PropertyGroup>
8+
<OSPlatformIsMusl Condition="$(OSPlatformIsMuslCheck) == '0'">true</OSPlatformIsMusl>
9+
<OSPlatformIsMusl Condition="$(OSPlatformIsMusl) == ''">false</OSPlatformIsMusl>
10+
411
<HostRid Condition="'$(HostRid)' == '' and '$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</HostRid>
512
<HostRid Condition="'$(HostRid)' == '' and '$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</HostRid>
613

@@ -9,6 +16,8 @@
916
<HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) ">osx</HostOSName>
1017
<HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD')) ">freebsd</HostOSName>
1118
<HostOSName Condition=" '$(HostOSName)' == '' AND '$(IsLinux)' == 'True' ">linux</HostOSName>
19+
<!-- If platform is musl based, adds information to HostOSName -->
20+
<HostOSName Condition="$(OSPlatformIsMusl) == 'true'">$(HostOSName)-musl</HostOSName>
1221

1322
<OSName Condition=" '$(OSName)' == '' ">$(HostOSName)</OSName>
1423

0 commit comments

Comments
 (0)