Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support virtualized 32-bit build on 64-bit ARM cores #2781

Closed
ayakael opened this issue Feb 23, 2022 · 8 comments
Closed

Support virtualized 32-bit build on 64-bit ARM cores #2781

ayakael opened this issue Feb 23, 2022 · 8 comments

Comments

@ayakael
Copy link

ayakael commented Feb 23, 2022

The output of uname -m in virtualized 32-bit arm environment on 64-bit ARM cores is armv8l. Unfortunately, the build process of dotnet 6.0.102 doesn't know what to do with this output, thus defaults to building x64. Just as armv7l is detected as arm, and builds as such, armv8l should also be detected as arm.

I've thus been trying to figure this out, but I've hit a wall. Here are my current patches:

tarball:

From d759d299a1793b5adba86b4f0c42ff4d2f32aa9f Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Mon, 21 Feb 2022 19:37:21 +0000
Subject: [PATCH 1/1] force arm build

Detection logics for armv7 is broken on Alpine build pipelines due to
detecting CPU armv8l. runtime_detect-armv8l-as-armv7l.patch is supposed
to fix this, but somehow Platform comes off as x64 on aspnetcore, rather
than arm. This patch, more of a temp fix to move things along, forces
arm build on arm7 platform for aspnetcore

---
 repos/aspnetcore.proj | 2 +-
 repos/installer.proj  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/repos/aspnetcore.proj b/repos/aspnetcore.proj
index 480f3c713..43fd35d01 100644
--- a/repos/aspnetcore.proj
+++ b/repos/aspnetcore.proj
@@ -5,7 +5,7 @@
     <!-- StandardSourceBuildArgs include -publish which is not supported by the aspnetcore build script. -->
     <BuildCommandArgs>$(StandardSourceBuildArgs.Replace('--publish', ''))</BuildCommandArgs>
     <!-- The arch flag (defaults to x64) overrides any value of TargetArchitecture that we might set -->
-    <BuildCommandArgs>$(BuildCommandArgs) --arch $(Platform)</BuildCommandArgs>
+    <BuildCommandArgs>$(BuildCommandArgs) --arch arm</BuildCommandArgs>
     <BuildCommandArgs>$(BuildCommandArgs) --no-build-repo-tasks</BuildCommandArgs>
     <BuildCommandArgs>$(BuildCommandArgs) /p:BuildNodeJs=false</BuildCommandArgs>
     <BuildCommandArgs>$(BuildCommandArgs) /p:PublishCompressedFilesPathPrefix=$(SourceBuiltAspNetCoreRuntime)</BuildCommandArgs>
diff --git a/repos/installer.proj b/repos/installer.proj
index 712d7cd14..ab1784af7 100644
--- a/repos/installer.proj
+++ b/repos/installer.proj
@@ -6,6 +6,7 @@
   <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
 
   <PropertyGroup>
+    <Platform>arm</Platform>
     <OverrideTargetRid>$(TargetRid)</OverrideTargetRid>
     <OverrideTargetRid Condition="'$(TargetOS)' == 'OSX'">osx-x64</OverrideTargetRid>
     <OSNameOverride>$(OverrideTargetRid.Substring(0, $(OverrideTargetRid.IndexOf("-"))))</OSNameOverride>
-- 
2.34.1

runtime:

From 79ddbec165071d8f8e51fd7c06600be466972758 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Mon, 21 Feb 2022 06:03:34 +0000
Subject: [PATCH 1/1] detect armv8l as armv7l

Alpine pipeline emulates 32bit arm, but CPU is aarch64 coming off as
arm8l. Thus arm detection logics don't know how to read armv8l, thus
this patch reads armv8l as arm platform.

---
 eng/native/configureplatform.cmake | 2 +-
 eng/native/init-os-and-arch.sh     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake
index af1c88bce5b..99556d80c05 100644
--- a/eng/native/configureplatform.cmake
+++ b/eng/native/configureplatform.cmake
@@ -36,7 +36,7 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux)
         # "amd64" string. Accept either of the two here.
         if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
             set(CLR_CMAKE_HOST_UNIX_AMD64 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv8l)
             set(CLR_CMAKE_HOST_UNIX_ARM 1)
             set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
         elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh
index fc4078fa3a9..9ba5b3c227a 100644
--- a/eng/native/init-os-and-arch.sh
+++ b/eng/native/init-os-and-arch.sh
@@ -41,7 +41,7 @@ case "$CPUName" in
         arch=x64
         ;;
 
-    armv7l)
+    armv7l|armv8l)
         if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
             arch=armel
         else
-- 
2.34.1

Despite that, during installer build, I get the following error:

/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/installer.49861cb924cdd74be8de19206b48de4f04c0ecbe/artifacts/source-build/self/src/src/redist/targets/Crossgen.targets(122,5): error : Error: Unable to load shared library 'clrjit_unix_x64_arm' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libclrjit_unix_x64_arm: No such file or directory [/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/installer.49861cb924cdd74be8de19206b48de4f04c0ecbe/artifacts/source-build/self/src/src/redist/redist.csproj]

So either libclrjit_unix_x64_arm is incorrect, or the file is never generated. I've tried following in the same direction as dotnet/runtime#49734, but instead of armel it's armv8l. Unfortunately, this didn't work.

Are there any arm detection logics that I'm missing?

Made as part of Alpine Linux dotnet6 packaging project, see #2782

@ayakael ayakael changed the title Support 32-bit userspace on 64-bit ARM cores Support virtualized 32-bit build on 64-bit ARM cores Feb 23, 2022
@omajid
Copy link
Member

omajid commented Feb 23, 2022

AFAIK, libclrjit_unix_x64_arm is a cross-compiler version of libclrjit. It's for running on an x64 machine and produces arm code. Since you are building on arm for arm, you shouldn't be using that cross compiler version of libclrjit. So, it sounds like the build system incorrectly thinks you are in cross-compile mode.

Can you try this change:

diff --git a/Directory.Build.props b/Directory.Build.props
index c373c9beb..af0f16f88 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
 
   <PropertyGroup>
     <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
-    <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture>
+    <Architecture Condition="'$(Architecture)' == '' AND ( '$(BuildArchitecture)' == 'arm64' OR '$(BuildArchitecture)' == 'arm') ">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 's390x'">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == ''">x64</Architecture>
   </PropertyGroup>

@omajid
Copy link
Member

omajid commented Feb 23, 2022

Hmm, actually, come to think of it, this should have done the same thing:

-    <BuildCommandArgs>$(BuildCommandArgs) --arch $(Platform)</BuildCommandArgs>
+    <BuildCommandArgs>$(BuildCommandArgs) --arch arm</BuildCommandArgs>

Looking at the build script, it only handles -a or --architecture. --arch is not handled in anyway. So maybe try changing it to --architecture?

@ayakael
Copy link
Author

ayakael commented Feb 23, 2022

diff --git a/Directory.Build.props b/Directory.Build.props
index c373c9beb..af0f16f88 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
 
   <PropertyGroup>
     <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
-    <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture>
+    <Architecture Condition="'$(Architecture)' == '' AND ( '$(BuildArchitecture)' == 'arm64' OR '$(BuildArchitecture)' == 'arm') ">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 's390x'">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == ''">x64</Architecture>
   </PropertyGroup>

Indeed, this patches aspnetcore's proj file, not run-build.sh

@ayakael
Copy link
Author

ayakael commented Feb 24, 2022

Look-a-here, we've moved forward. Now we're crashing at fsharp:

 [01:26:11.27] Building 'fsharp in tarball'
  Running command:
    /builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/build.sh  --ci --configuration Release --restore --build --pack --publish -bl /p:ArcadeBuildFromSource=true /p:CopyWipIntoInnerSourceBuildRepo=true /p:DotNetBuildOffline=true /p:CopySrcInsteadOfClone=true /p:DotNetPackageVersionPropsPath="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props" /p:AdditionalSourceBuiltNupkgCacheDir="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/blob-feed/packages/" /p:ReferencePackageNupkgCacheDir="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/packages/reference/packages/" /p:PreviouslySourceBuiltNupkgCacheDir="/usr/share/dotnet/artifacts/6.0.102/" /p:TreatWarningsAsErrors=false --sourcebuild  /p:DotNetPackageVersionPropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props /p:DotNetRestoreSourcePropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/RestoreSources.props /p:DotNetBuildOffline=true
    Log: /builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/logs/fsharp.log
    With Environment Variables:
      DotNetBuildFromSource=true
      DotNetPackageVersionPropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props
      DotNetRestorePackagesPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/packages/restored/
      DotNetBuildOffline=true
      AddDotnetfeedProjectSource=false
      DOTNET_INSTALL_DIR=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/
      DOTNET_PATH=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/
      DOTNET_HOST_PATH=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/dotnet
      _InitializeDotNetCli=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/
      _DotNetInstallDir=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/
      _InitializeToolset=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj
      _OverrideArcadeInitializeBuildToolFramework=net6.0
      DotNetUseShippingVersions=true
      PreReleaseVersionLabel=beta
      PackageVersionStamp=beta
      PB_VersionStamp=beta
      ContinuousIntegrationBuild=true
      MSBUILDDISABLENODEREUSE=1
      OfficialBuildId=20211022.2
      BUILD_BUILDNUMBER=20211022.2
      GitCommitCount=
      GitCommitHash=6d626ff0752a77d339f609b4d361787dc9ca93a5
      GitInfoCommitHash=6d626ff0752a77d339f609b4d361787dc9ca93a5
      SourceRevisionId=6d626ff0752a77d339f609b4d361787dc9ca93a5
      RepositoryCommit=6d626ff0752a77d339f609b4d361787dc9ca93a5
      COMMIT_SHA=6d626ff0752a77d339f609b4d361787dc9ca93a5
      GIT_COMMIT=6d626ff0752a77d339f609b4d361787dc9ca93a5
      RepositoryType=Git
      DeterministicSourcePaths=true
      SourceRoot=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/
      LatestCommit=6d626ff0752a77d339f609b4d361787dc9ca93a5
      SOURCE_BUILT_SDK_ID_ARCADE=Microsoft.DotNet.Arcade.Sdk
      SOURCE_BUILT_SDK_VERSION_ARCADE=6.0.0-beta.21609.4
      SOURCE_BUILT_SDK_DIR_ARCADE=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/
RepoBuild:
  /builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/build.sh  --ci --configuration Release --restore --build --pack --publish -bl /p:ArcadeBuildFromSource=true /p:CopyWipIntoInnerSourceBuildRepo=true /p:DotNetBuildOffline=true /p:CopySrcInsteadOfClone=true /p:DotNetPackageVersionPropsPath="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props" /p:AdditionalSourceBuiltNupkgCacheDir="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/blob-feed/packages/" /p:ReferencePackageNupkgCacheDir="/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/packages/reference/packages/" /p:PreviouslySourceBuiltNupkgCacheDir="/usr/share/dotnet/artifacts/6.0.102/" /p:TreatWarningsAsErrors=false --sourcebuild  /p:DotNetPackageVersionPropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props /p:DotNetRestoreSourcePropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/RestoreSources.props /p:DotNetBuildOffline=true 
  ##vso[task.setvariable variable=Artifacts;isSecret=false;isOutput=true]/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts
  ##vso[task.setvariable variable=Artifacts.Toolset;isSecret=false;isOutput=true]/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/toolset
  ##vso[task.setvariable variable=Artifacts.Log;isSecret=false;isOutput=true]/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/log/Release
  ##vso[task.setvariable variable=Temp;isSecret=false;isOutput=true]/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/tmp/Release
  ##vso[task.setvariable variable=TMP;isSecret=false;isOutput=true]/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/tmp/Release
  FSharp.sln:
  ##vso[task.setvariable variable=NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS;isSecret=false;isOutput=true]20
  ##vso[task.setvariable variable=NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS;isSecret=false;isOutput=true]20
  ##vso[task.setvariable variable=NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY;isSecret=false;isOutput=true]true
  ##vso[task.setvariable variable=NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT;isSecret=false;isOutput=true]6
  ##vso[task.setvariable variable=NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS;isSecret=false;isOutput=true]1000
  /builds/ayakael/aports/testing/dotnet6-bootstrap/src/bootstrap/sdk/6.0.102/MSBuild.dll /nologo -logger:/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/tools/net6.0/Microsoft.DotNet.ArcadeLogging.dll -maxcpucount /m -verbosity:m /v:minimal /v:minimal /bl:/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/log/Release/Build.binlog /clp:Summary /nr:false /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=true /p:Configuration=Release /p:Projects=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5//FSharp.sln /p:RepoRoot=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/ /p:Restore=true /p:Build=true /p:Rebuild=false /p:Pack=true /p:Publish=true /p:UseRoslynAnalyzers=!false /p:ContinuousIntegrationBuild=true /p:QuietRestore= /p:QuietRestoreBinaryLog=true /p:ArcadeBuildFromSource=true /p:ArcadeBuildFromSource=true /p:CopyWipIntoInnerSourceBuildRepo=true /p:DotNetBuildOffline=true /p:CopySrcInsteadOfClone=true /p:DotNetPackageVersionPropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props /p:AdditionalSourceBuiltNupkgCacheDir=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/blob-feed/packages/ /p:ReferencePackageNupkgCacheDir=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/packages/reference/packages/ /p:PreviouslySourceBuiltNupkgCacheDir=/usr/share/dotnet/artifacts/6.0.102/ /p:TreatWarningsAsErrors=false /p:DotNetPackageVersionPropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/PackageVersions.props /p:DotNetRestoreSourcePropsPath=/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/artifacts/obj/x64/Release/RestoreSources.props /p:DotNetBuildOffline=true /warnaserror /builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj
    FSharp.sln:
    [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.Sdk. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/6.0.0-beta.21609.4' at '/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/'
    [SourceBuiltSdkResolver] Looking for SDK Microsoft.DotNet.Arcade.Sdk. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/6.0.0-beta.21609.4' at '/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/'
    [SourceBuiltSdkResolver] Overriding Microsoft.DotNet.Arcade.Sdk with 'ARCADE'
    [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.SDK.WorkloadAutoImportPropsLocator. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/6.0.0-beta.21609.4' at '/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/'
    [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.ILLink.Tasks. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/6.0.0-beta.21609.4' at '/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/'
    [SourceBuiltSdkResolver] Looking for SDK Microsoft.NET.SDK.WorkloadManifestTargetsLocator. Detected config(s) in env: 'ARCADE' for 'Microsoft.DotNet.Arcade.Sdk/6.0.0-beta.21609.4' at '/builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/Tools/source-built/Microsoft.DotNet.Arcade.Sdk/'
      Determining projects to restore...
    /builds/ayakael/aports/testing/dotnet6-bootstrap/src/source-build-tarball-6.0.102/src/fsharp.6d626ff0752a77d339f609b4d361787dc9ca93a5/artifacts/source-build/self/src/eng/common/tools.sh: line 475:  2975 Segmentation fault      (core dumped) "$_InitializeBuildTool" "$@"
    Build failed with exit code 139. Check errors above.
    Error building tools (exit code '139').

eng/common/tools.sh: line 475

  function RunBuildTool {            
    export ARCADE_BUILD_TOOL_COMMAND="$_InitializeBuildTool $@"
                                                                                                    
    "$_InitializeBuildTool" "$@" || {                                                                             
      local exit_code=$?                                                                                                               
      # We should not Write-PipelineTaskError here because that message shows up in the build summary
      # The build already logged an error, that's the reason it failed. Producing an error here only adds noise.
      echo "Build failed with exit code $exit_code. Check errors above."
      if [[ "$ci" == "true" ]]; then
        Write-PipelineSetResult -result "Failed" -message "msbuild execution failed."
        # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error        
        # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
        ExitWithExitCode 0             
      else                                                   
        ExitWithExitCode $exit_code
      fi                                                                                                                         
    }                     
  }  

eng/common/tools.sh: _InitializeBuildTool

function InitializeBuildTool {                  
  if [[ -n "${_InitializeBuildTool:-}" ]]; then                                                
    return             
  fi                      
                                                                                                       
  InitializeDotNetCli $restore                                                                      
                                                                                      
  # return values                                                                  
  _InitializeBuildTool="$_InitializeDotNetCli/dotnet"                                 
  _InitializeBuildToolCommand="msbuild"                                            
  _InitializeBuildToolFramework="netcoreapp3.1"
}      

Last time I saw code 139, I think it had something to do with lttng-ust 2.13.1. Given that I've neutralized it by deleting libcoreclrtraceptprovider.so, I don't think that it's related to that. Notice that _InitializeDotNetCli should be the bootstrap dotnet, which is built for arm. Any ideas?

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@MichaelSimons MichaelSimons transferred this issue from dotnet/installer Mar 1, 2022
@ayakael
Copy link
Author

ayakael commented Mar 9, 2022

The code 139 bug seems to have disappeared. The clrjit bug is confirmed fixed with your patch, @omajid. It looks like build on armv7 and armhf works. I'll confirm a full rebuild with the following patches:

installer_arm-build.patch

From 1bc1a54dfd9c9d448dc671a2bad2f05e0641885c Mon Sep 17 00:00:00 2001
From: "build@apk-groulx" <build@apk-groulx.praxis>
Date: Wed, 9 Mar 2022 08:17:41 +0000
Subject: [PATCH 1/1] arm build

---
 Directory.Build.props | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Directory.Build.props b/Directory.Build.props
index c373c9beb..af0f16f88 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
 
   <PropertyGroup>
     <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
-    <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture>
+    <Architecture Condition="'$(Architecture)' == '' AND ( '$(BuildArchitecture)' == 'arm64' OR '$(BuildArchitecture)' == 'arm') ">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 's390x'">$(BuildArchitecture)</Architecture>
     <Architecture Condition="'$(Architecture)' == ''">x64</Architecture>
   </PropertyGroup>
-- 
2.35.1

runtime_detect-armv8.patch

From 79ddbec165071d8f8e51fd7c06600be466972758 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Mon, 21 Feb 2022 06:03:34 +0000
Subject: [PATCH 1/1] detect armv8l as armv7l

Alpine pipeline emulates 32bit arm, but CPU is aarch64 coming off as
arm8l. Thus arm detection logics don't know how to read armv8l, thus
this patch reads armv8l as arm platform.

---
 eng/native/configureplatform.cmake | 2 +-
 eng/native/init-os-and-arch.sh     | 2 +-
 src/coreclr/tools/aot/crossgen2/crossgen2.props | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake
index af1c88bce5b..99556d80c05 100644
--- a/eng/native/configureplatform.cmake
+++ b/eng/native/configureplatform.cmake
@@ -36,7 +36,7 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux)
         # "amd64" string. Accept either of the two here.
         if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
             set(CLR_CMAKE_HOST_UNIX_AMD64 1)
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv8l)
             set(CLR_CMAKE_HOST_UNIX_ARM 1)
             set(CLR_CMAKE_HOST_UNIX_ARMV7L 1)
         elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh
index fc4078fa3a9..9ba5b3c227a 100644
--- a/eng/native/init-os-and-arch.sh
+++ b/eng/native/init-os-and-arch.sh
@@ -41,7 +41,7 @@ case "$CPUName" in
         arch=x64
         ;;
 
-    armv7l)
+    armv7l|armv8l)
         if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
             arch=armel
         else
-- 
2.34.1

runtime_aarch64-armv7-armhf-lld-fix.patch

From 91988b0241a77f1f6524c19e2ce55dda06de7242 Mon Sep 17 00:00:00 2001
Patch-Source: https://src.fedoraproject.org/rpms/dotnet6.0/blob/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/eng/native/init-compiler.sh b/eng/native/init-compiler.sh
index 567d18da474..05245c7b9f8 100755
--- a/eng/native/init-compiler.sh
+++ b/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

@ayakael
Copy link
Author

ayakael commented Mar 10, 2022

So, build passes, but there's no artifacts/*/Release directory, so no artifacts/*/Release/dotnet-sdk-$_pkgver_macro*.tar.gz. Trying to find all instance of AND '$(BuildArchitecture)' == 'arm64' to add a OR '$(BuildArchitecture)' == 'arm'

edit actually, there's artifacts/*/Release, but no dotnet-sdk-$_pkgver_macro*.tar.gz
edit 2 okay.. its known-good's fault

@ayakael
Copy link
Author

ayakael commented Sep 24, 2022

With dotnet/runtime#66477, this is fixed. Arm support proper is to be addressed here: dotnet/installer#13378.

Closing.

@ayakael ayakael closed this as completed Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants