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

Build on CBL-mariner host with rootfs #84148

Merged
merged 88 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8735c94
Enable x64 Alpine crossbuild
janvorli Feb 9, 2023
0084966
Set PKG_CONFIG_SYSROOT_DIR
sbomer Feb 22, 2023
bb39763
More build fixes
sbomer Mar 3, 2023
a5f2dbd
test
sbomer Mar 6, 2023
db7bf3e
Print full clang command to show selected linker
sbomer Mar 7, 2023
597a304
Build scripts
sbomer Mar 8, 2023
3e5a366
Fix x64 -> x64 musl cross-build
sbomer Mar 10, 2023
4c369f3
Enable thumb-2 in mono build
sbomer Mar 14, 2023
612c686
Allow cross compiling for x86
sbomer Mar 24, 2023
a9fd083
Enable x86 build with lld
sbomer Mar 24, 2023
d0a1560
Fix x86 mono cross-build
sbomer Mar 24, 2023
2abee9b
Some cleanup
sbomer Mar 24, 2023
54dc641
Add gcc-toolchain arg when aot-ing crossgen
sbomer Mar 24, 2023
2da99a9
Merge remote-tracking branch 'origin/main' into marinerTest
sbomer Mar 27, 2023
825a1d9
Fix AOT compilation of ILCompiler and crossgen2
sbomer Mar 27, 2023
c7468f6
Only pass --gcc-toolchain where required
sbomer Mar 27, 2023
ae6c6ab
Cleanup
sbomer Mar 27, 2023
3d70352
Fix symbol stripping on ci builds
sbomer Mar 29, 2023
2f12a9a
Fix nativeaot test build
sbomer Mar 30, 2023
f6bd3e5
Pick up mariner images, set cross-build arguments
sbomer Mar 30, 2023
e9f17fb
Don't use lld on macos
sbomer Mar 31, 2023
26621ab
Update src/coreclr/pgosupport.cmake
sbomer Mar 31, 2023
39ca0c0
Don't pass clang9
sbomer Mar 31, 2023
220094a
Fix osx linker in tests too
sbomer Mar 31, 2023
d4f71e9
Define separate platform for GCC build
sbomer Mar 31, 2023
d85c7d6
Disable PGO for linux x64 and musl-x64
sbomer Mar 31, 2023
1b3afcb
Build cross tools for x64 and musl-x64
sbomer Mar 31, 2023
938cdf1
Pass crossArg to mono build
sbomer Mar 31, 2023
749ee9c
Pass cross arg in build-test-job.yml
sbomer Mar 31, 2023
6cb0b8e
Fix typo
sbomer Mar 31, 2023
96243bd
Pass through no-PGO arg in global-build-job.yml
sbomer Mar 31, 2023
b84beba
Remove pgoType from job name
sbomer Apr 1, 2023
c9137b3
Pass noPgo arg to native prereqs step
sbomer Apr 2, 2023
d0d3312
Fix crossArg not defined for NativeAOT test build
sbomer Apr 2, 2023
ed0c013
Pass crossBuild through build-test-job.yml
sbomer Apr 2, 2023
2367f3f
Set linker flavor, sysroot in nativeaot library tests
sbomer Apr 2, 2023
a51dbde
Use git diff for AsnXml
sbomer Apr 3, 2023
76c434f
Merge remote-tracking branch 'origin/main' into marinerBuild
sbomer Apr 3, 2023
c30a214
Pass crossBuild through mono's xplat-pipeline-job.yml
sbomer Apr 3, 2023
dd59301
Move crossArg after runtime build params
sbomer Apr 3, 2023
c4c5fa7
Disable PGO from MSBuild instead
sbomer Apr 3, 2023
8a19475
Fix empty container
sbomer Apr 3, 2023
8c41d41
Pass crossArg to mono Build packages step
sbomer Apr 3, 2023
a8cc38d
Fix gcc container definition
sbomer Apr 3, 2023
9aa3527
Use init-compiler.sh for mono cross build
sbomer Apr 3, 2023
cd1f16a
Condition linker selection based on compiler
sbomer Apr 3, 2023
143552e
Fix publish condition
sbomer Apr 4, 2023
04e6182
Pass compilerArg to managed component build
sbomer Apr 4, 2023
47246a3
Use command -v instead of which
sbomer Apr 4, 2023
7ecd081
Use crossArg instead of _crossBuildPropertyArg
sbomer Apr 4, 2023
405fbae
Set mono toolchain for aot build
sbomer Apr 4, 2023
c1da152
Adjust DwarfDump baseline, show expected AOT size
sbomer Apr 4, 2023
9cd348b
Don't use new images for Mono LLVMAot test build
sbomer Apr 4, 2023
d6b0649
Build cross tools when BuildArch != TargetArch
sbomer Apr 4, 2023
8e12626
Fix typo
sbomer Apr 4, 2023
ecd4081
Don't set crossBuild for mono llvmaot
sbomer Apr 5, 2023
028a889
Fix ILCompiler, crossgen invocation for windows
sbomer Apr 6, 2023
7fc39d3
Add PGO instrumentation legs
sbomer Apr 6, 2023
6aa9f0a
Run source-build legs
sbomer Apr 6, 2023
667921b
Pick up arm images
sbomer Apr 7, 2023
cf0ffef
Fix indentation
sbomer Apr 7, 2023
6c0b026
Undo job name change
sbomer Apr 7, 2023
fc9c302
Add linux arm64 libraries build
sbomer Apr 7, 2023
a5e22a0
Don't run AOT'd crossgen that targets musl
sbomer Apr 7, 2023
09f6889
Fix crossgen-corelib logic
sbomer Apr 7, 2023
d23534a
Freeze image versions
sbomer Apr 7, 2023
609f19b
Use existing images for mono arm64 build
sbomer Apr 7, 2023
bedfad7
Don't trigger source-build
sbomer Apr 7, 2023
c708244
Merge remote-tracking branch 'origin/main' into marinerBuild
sbomer Apr 7, 2023
02ec629
Update dwarfdump, size baseline
sbomer Apr 7, 2023
e130eb5
Fix yaml mistakes
sbomer Apr 7, 2023
0fcef90
Update src/tests/nativeaot/SmokeTests/HardwareIntrinsics/X64Baseline.…
sbomer Apr 7, 2023
f1ea8ad
PR feedback
sbomer Apr 8, 2023
04571e5
Fix arm image tags
sbomer Apr 8, 2023
45bb34d
Update src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.…
sbomer Apr 10, 2023
ee57442
Merge remote-tracking branch 'origin/main' into marinerBuild
sbomer Apr 10, 2023
d80a584
Revert "Write linker script for lld to enable gc-sections (#84493)"
sbomer Apr 10, 2023
ddcd261
Update image tags
sbomer Apr 10, 2023
812d284
Revert "Use git diff for AsnXml"
sbomer Apr 10, 2023
e25b5c9
Fix nativeaot libraries test build
sbomer Apr 10, 2023
0fe6ac6
Remove temporary PGO instrumentation legs
sbomer Apr 10, 2023
8406c40
Fix musl_arm tag
sbomer Apr 10, 2023
97a9faf
Remove left-over leg
sbomer Apr 10, 2023
bfad4ea
Merge remote-tracking branch 'origin/main' into marinerBuild
sbomer Apr 11, 2023
018e961
Merge remote-tracking branch 'origin/main' into marinerBuild
sbomer Apr 11, 2023
1e2e056
PR feedback
sbomer Apr 12, 2023
ba6001c
Update src/mono/mono.proj
sbomer Apr 12, 2023
92d1f22
Fix condition for mono aot flags
sbomer Apr 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@
Category="clr" />
</ItemGroup>

<!-- Build the CoreCLR cross-arch tools when we're doing a cross-architecture build and either we're building any CoreCLR native tools for platforms CoreCLR fully supports or when someone explicitly requests them -->
<ItemGroup Condition="(('$(ClrRuntimeBuildSubsets)' != '' and '$(PrimaryRuntimeFlavor)' == 'CoreCLR' and '$(TargetsMobile)' != 'true') or $(_subset.Contains('+clr.crossarchtools+'))) and '$(BuildArchitecture)' != '$(TargetArchitecture)'">
<!-- Build the CoreCLR cross tools when we're doing a cross build and either we're building any CoreCLR native tools for platforms CoreCLR fully supports or when someone explicitly requests them -->
<ItemGroup Condition="(('$(ClrRuntimeBuildSubsets)' != '' and '$(PrimaryRuntimeFlavor)' == 'CoreCLR' and '$(TargetsMobile)' != 'true') or $(_subset.Contains('+clr.crossarchtools+'))) and '$(CrossBuild)' == 'true'">
<ProjectToBuild
Include="$(CoreClrProjectRoot)runtime.proj"
AdditionalProperties="%(AdditionalProperties);
Expand Down Expand Up @@ -325,7 +325,7 @@
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler.csproj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" />
<ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\BuildIntegration\BuildIntegration.proj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" />

<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and '$(TargetArchitecture)' != '$(BuildArchitecture)'" Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_crossarch.csproj" Category="clr" />
<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and '$(CrossBuild)' == 'true'" Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_crossarch.csproj" Category="clr" />
<ProjectToBuild Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" />

<ProjectToBuild Condition="'$(TargetOS)' == 'windows' or ('$(TargetOS)' == 'linux' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')) or '$(TargetOS)' == 'osx'" Include="$(CoreClrProjectRoot)tools\SuperFileCheck\SuperFileCheck.csproj" Category="clr" />
Expand Down Expand Up @@ -367,8 +367,8 @@

<ItemGroup Condition="$(_subset.Contains('+clr.nativecorelib+'))">
<!-- Build crossgen2 that will be used to compile System.Private.CoreLib library for CoreCLR -->
<ProjectToBuild Condition="'$(TargetArchitecture)' != 'x64' and '$(BuildArchitecture)' == 'x64'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" />
<ProjectToBuild Condition="!('$(TargetArchitecture)' != 'x64' and '$(BuildArchitecture)' == 'x64')" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2.csproj" Category="clr" />
<ProjectToBuild Condition="'$(CrossBuild)' == 'true' and '$(BuildArchitecture)' == 'x64'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" />
<ProjectToBuild Condition="!('$(CrossBuild)' == 'true' and '$(BuildArchitecture)' == 'x64')" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2.csproj" Category="clr" />
<ProjectToBuild Include="$(CoreClrProjectRoot)crossgen-corelib.proj" Category="clr" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions eng/common/cross/build-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ while :; do
;;
x64)
__BuildArch=x64
__AlpineArch=x86_64
__UbuntuArch=amd64
__FreeBSDArch=amd64
__FreeBSDMachineArch=amd64
Expand Down
6 changes: 4 additions & 2 deletions eng/common/cross/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ elseif(TARGET_ARCH_NAME STREQUAL "s390x")
set(TOOLCHAIN "s390x-linux-gnu")
elseif(TARGET_ARCH_NAME STREQUAL "x64")
set(CMAKE_SYSTEM_PROCESSOR x86_64)
if(LINUX)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl)
set(TOOLCHAIN "x86_64-alpine-linux-musl")
elseif(LINUX)
set(TOOLCHAIN "x86_64-linux-gnu")
if(TIZEN)
set(TIZEN_TOOLCHAIN "x86_64-tizen-linux-gnu/9.2.0")
Expand Down Expand Up @@ -279,7 +281,7 @@ endif()

# Specify compile options

if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU)
if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x|x64|x86)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN})
Expand Down
2 changes: 1 addition & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<CoreCLRSharedFrameworkDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'sharedFramework'))</CoreCLRSharedFrameworkDir>
<CoreCLRCrossgen2Dir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'crossgen2'))</CoreCLRCrossgen2Dir>
<CoreCLRILCompilerDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'ilc-published'))</CoreCLRILCompilerDir>
<CoreCLRCrossILCompilerDir Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)'">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc'))</CoreCLRCrossILCompilerDir>
<CoreCLRCrossILCompilerDir Condition="'$(CrossBuild)' == 'true'">$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', '$(BuildArchitecture)', 'ilc'))</CoreCLRCrossILCompilerDir>
<CoreCLRAotSdkDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'aotsdk'))</CoreCLRAotSdkDir>
<CoreCLRBuildIntegrationDir>$([MSBuild]::NormalizeDirectory('$(CoreCLRArtifactsPath)', 'build'))</CoreCLRBuildIntegrationDir>

Expand Down
1 change: 1 addition & 0 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ while :; do
hostarch|-hostarch)
if [[ -n "$2" ]]; then
__HostArch="$2"
__ExplicitHostArch=1
shift
else
echo "ERROR: 'hostarch' requires a non-empty option argument"
Expand Down
5 changes: 3 additions & 2 deletions eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/ppc64le-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl)

set(ALPINE_LINUX 1)
Expand Down Expand Up @@ -74,7 +75,7 @@ if(DARWIN)
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
endif()
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86)$" OR FREEBSD OR ILLUMOS OR TIZEN)
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86|x64)$" OR FREEBSD OR ILLUMOS OR TIZEN)
set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0)
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
Expand Down Expand Up @@ -160,6 +161,6 @@ else()
message(FATAL_ERROR "Unsupported platform. OS: ${CMAKE_SYSTEM_NAME}, arch: ${TARGET_ARCH_NAME}")
endif()

if(TARGET_ARCH_NAME MATCHES "^(x86|s390x|armv6|loongarch64|riscv64|ppc64le)$")
if(TARGET_ARCH_NAME MATCHES "^(x86|x64|s390x|armv6|loongarch64|riscv64|ppc64le)$")
set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
endif()
2 changes: 2 additions & 0 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
crossBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

# Linux musl arm
Expand Down Expand Up @@ -222,6 +223,7 @@ jobs:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
crossBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

# Linux x86
Expand Down
14 changes: 9 additions & 5 deletions eng/pipelines/common/templates/pipeline-with-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ resources:
ROOTFS_DIR: /crossrootfs/armv6

- container: linux_arm64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-cross-arm64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64
env:
ROOTFS_DIR: /crossrootfs/arm64

- container: linux_musl_x64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.13-WithNode
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64-alpine
env:
ROOTFS_DIR: /crossrootfs/x64

- container: linux_musl_arm
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-arm-alpine
env:
ROOTFS_DIR: /crossrootfs/arm

- container: linux_musl_arm64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-arm64-alpine
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64-alpine
env:
ROOTFS_DIR: /crossrootfs/arm64
# This container contains all required toolsets to build for Android and for Linux with bionic libc.
Expand All @@ -37,10 +39,12 @@ resources:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-android

- container: linux_x64
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64
env:
ROOTFS_DIR: /crossrootfs/x64

- container: linux_x86
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-x86-linux
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-x86
env:
ROOTFS_DIR: /crossrootfs/x86

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ if(CLR_CMAKE_HOST_UNIX)
endif()
endif()

if(CLR_CMAKE_TARGET_LINUX AND CLR_CMAKE_TARGET_ARCH_I386)
add_linker_flag(-Wl,-z,notext)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix taken from #83682 which was hitting the same issue (getting warnings due to text relocations).

endif()

if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
add_subdirectory(pal)
add_subdirectory(hosts)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ __IntermediatesDir="$__ArtifactsIntermediatesDir/$__ConfigTriplet"

export __IntermediatesDir __ArtifactsIntermediatesDir

if [[ "$__TargetArch" != "$__HostArch" ]]; then
if [[ "$__ExplicitHostArch" == 1 ]]; then
__IntermediatesDir="$__IntermediatesDir/$__HostArch"
__BinDir="$__BinDir/$__HostArch"
fi
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT WIN32)
# Function required to give CMAKE_REQUIRED_* local scope
function(check_have_lto)
set(CMAKE_REQUIRED_FLAGS -flto)
set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=gold)
set(CMAKE_REQUIRED_LIBRARIES -flto -fuse-ld=lld)
check_cxx_source_compiles("int main() { return 0; }" HAVE_LTO)
endfunction(check_have_lto)
check_have_lto()
Expand Down
42 changes: 42 additions & 0 deletions src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,53 @@
<NativeAotSupported Condition="'$(TargetOS)' != 'windows' and '$(TargetOS)' != 'linux' and '$(TargetOS)' != 'osx'">false</NativeAotSupported>
<NativeAotSupported Condition="'$(TargetArchitecture)' != 'x64'">false</NativeAotSupported>
<PublishAot Condition="'$(NativeAotSupported)' == 'true'">true</PublishAot>
<!-- TODO: change to <LinkerFlavor>lld</LinkerFlavor> once we pick up an SDK with https://github.com/dotnet/runtime/pull/83558. -->
<UseLLVMLinker Condition="'$(NativeAotSupported)' == 'true'">true</UseLLVMLinker>
<SysRoot Condition="'$(NativeAotSupported)' == 'true' and '$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">$(ROOTFS_DIR)</SysRoot>
<PublishReadyToRun Condition="'$(NativeAotSupported)' != 'true'">true</PublishReadyToRun>
<PublishSingleFile Condition="'$(NativeAotSupported)' != 'true'">true</PublishSingleFile>
<PublishTrimmed Condition="'$(NativeAotSupported)' != 'true'">true</PublishTrimmed>
</PropertyGroup>

<!-- TODO: remove this once we pick up an SDK with https://github.com/dotnet/runtime/pull/82645.
This works around an incorrect ILC host package name when targeting linux-musl-x64 from linux-x64. -->
<Target Name="_FixIlcHostArch"
BeforeTargets="ImportRuntimeIlcPackageTarget">
<PropertyGroup>
<_hostOS>$(NETCoreSdkPortableRuntimeIdentifier.SubString(0, $(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))))</_hostOS>
<OSIdentifier>$(_hostOS)</OSIdentifier>
<IlcHostPackageName>runtime.$(OSIdentifier)-$(IlcHostArch).Microsoft.DotNet.ILCompiler</IlcHostPackageName>
</PropertyGroup>
</Target>

<!-- Needed for the amd64 -> amd64 musl cross-build to pass the target flag. -->
<Target Name="_FixIlcTargetTriple"
AfterTargets="SetupOSSpecificProps"
Condition="'$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">
<!-- Compute CrossCompileRid, and copy the downstream logic as-is. -->
<PropertyGroup>
<CrossCompileRid>$(RuntimeIdentifier)</CrossCompileRid>

<CrossCompileArch />
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' != 'true'">aarch64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' == 'true'">arm64</CrossCompileArch>

<TargetTriple />
<TargetTriple Condition="'$(CrossCompileArch)' != ''">$(CrossCompileArch)-linux-gnu</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('linux-musl')) or $(CrossCompileRid.StartsWith('alpine')))">$(CrossCompileArch)-alpine-linux-musl</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('freebsd')))">$(CrossCompileArch)-unknown-freebsd12</TargetTriple>
</PropertyGroup>

<ItemGroup>
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'osx' and '$(TargetTriple)' != ''" />
</ItemGroup>
</Target>

<ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
<CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and '$(IlcHostArch)' == '$(TargetArchitecture)' and '$(_hostOS)' != 'windows'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" />
</ItemGroup>

<Target Name="PublishCompiler"
Condition="'$(BuildingInsideVisualStudio)' != 'true'"
AfterTargets="Build"
Expand Down
33 changes: 31 additions & 2 deletions src/coreclr/tools/aot/crossgen2/crossgen2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup Condition="'$(NativeAotSupported)' == 'true'">
<LinkerFlavor>lld</LinkerFlavor>
<IlcToolsPath>$(CoreCLRILCompilerDir)</IlcToolsPath>
<IlcToolsPath Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)'">$(CoreCLRCrossILCompilerDir)</IlcToolsPath>
<SysRoot Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)' and '$(HostOS)' != 'windows'">$(ROOTFS_DIR)</SysRoot>
<IlcToolsPath Condition="'$(CrossBuild)' == 'true'">$(CoreCLRCrossILCompilerDir)</IlcToolsPath>
<SysRoot Condition="'$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">$(ROOTFS_DIR)</SysRoot>
<IlcBuildTasksPath>$(CoreCLRILCompilerDir)netstandard/ILCompiler.Build.Tasks.dll</IlcBuildTasksPath>
<IlcSdkPath>$(CoreCLRAotSdkDir)</IlcSdkPath>
<IlcFrameworkPath>$(MicrosoftNetCoreAppRuntimePackRidLibTfmDir)</IlcFrameworkPath>
<IlcFrameworkNativePath>$(MicrosoftNetCoreAppRuntimePackNativeDir)</IlcFrameworkNativePath>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
</PropertyGroup>

<ItemGroup Condition="'$(NativeAotSupported)' == 'true'">
<CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" />
</ItemGroup>

<Import Project="$(R2ROverridePath)" Condition="'$(R2ROverridePath)' != ''" />
<Import Project="$(CoreCLRBuildIntegrationDir)Microsoft.DotNet.ILCompiler.SingleEntry.targets"
Condition="'$(NativeAotSupported)' == 'true' and '$(_IsPublishing)' == 'true'" />
Expand All @@ -57,6 +62,30 @@
</ItemGroup>
</Target>

<!-- Needed for the amd64 -> amd64 musl cross-build to pass the target flag. -->
<Target Name="_FixIlcTargetTriple"
AfterTargets="SetupOSSpecificProps"
Condition="'$(CrossBuild)' == 'true' and '$(HostOS)' != 'windows'">
<!-- Compute CrossCompileRid, and copy the downstream logic as-is. -->
<PropertyGroup>
<CrossCompileRid>$(RuntimeIdentifier)</CrossCompileRid>

<CrossCompileArch />
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' != 'true'">aarch64</CrossCompileArch>
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-arm64')) and '$(_IsApplePlatform)' == 'true'">arm64</CrossCompileArch>

<TargetTriple />
<TargetTriple Condition="'$(CrossCompileArch)' != ''">$(CrossCompileArch)-linux-gnu</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('linux-musl')) or $(CrossCompileRid.StartsWith('alpine')))">$(CrossCompileArch)-alpine-linux-musl</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('freebsd')))">$(CrossCompileArch)-unknown-freebsd12</TargetTriple>
</PropertyGroup>

<ItemGroup>
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetOS)' != 'osx' and '$(TargetTriple)' != ''" />
</ItemGroup>
</Target>

<Target Name="LocateNativeCompiler"
Condition="'$(NativeAotSupported)' == 'true' and '$(_IsPublishing)' == 'true' and '$(HostOS)' != 'windows'"
BeforeTargets="SetupOSSpecificProps">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
<PermitDllAndExeFilesLackingFileVersion>true</PermitDllAndExeFilesLackingFileVersion>
<!-- Publishing as single-file or NativeAOT means we can't examine the interior DLLs -->
<ShouldVerifyClosure>false</ShouldVerifyClosure>
<!-- Publish crossgen2 as a single-file app on cross-OS builds. Cross-OS NativeAOT compilation is not supported yet -->
<!-- Publish crossgen2 as a single-file app on native-OS builds. Cross-OS NativeAOT compilation is not supported yet -->
<NativeAotSupported Condition="'$(CrossBuild)' == 'true' and '$(TargetOS)' != '$(HostOS)'">false</NativeAotSupported>
<!-- Can't use NativeAOT in source build yet https://github.com/dotnet/runtime/issues/66859 -->
<NativeAotSupported Condition="'$(DotNetBuildFromSource)' == 'true'">false</NativeAotSupported>
<ObjCopyName Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(CrossBuild)' == 'true' and '$(RuntimeIdentifier)' == 'linux-musl-arm64'">llvm-objcopy-15</ObjCopyName>
<ObjCopyName Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(CrossBuild)' == 'true' and '$(RuntimeIdentifier)' == 'linux-arm64'">aarch64-linux-gnu-objcopy</ObjCopyName>
</PropertyGroup>

<Target Name="PublishCrossgen"
Expand Down Expand Up @@ -75,7 +73,7 @@
</Target>

<Target Name="RunPublishedCrossgen" AfterTargets="PublishCrossgen"
Condition="'$(TargetOS)' == '$(HostOS)' and '$(TargetArchitecture)' == '$(BuildArchitecture)'">
Condition="'$(CrossBuild)' != 'true'">
<!-- Run the published crossgen if we're not cross-compiling -->
<Exec Command="@(FilesToPackage) $(CoreCLRArtifactsPath)IL/System.Private.CoreLib.dll --out $(IntermediateOutputPath)S.P.C.tmp" Condition="'%(FileName)%(Extension)' == 'crossgen2$(ExeSuffix)'">
<Output TaskParameter="ExitCode" PropertyName="CrossgenExitCode" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- The following property group can be simplified once runtime repo switches over to SDK 6.0 drop -->
<PropertyGroup>
<CrossDir />
<CrossDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">x64</CrossDir>
<CrossDir Condition="'$(CrossBuild)' == 'true'">$(BuildArchitecture)</CrossDir>
<Crossgen2Dll>$(CoreCLRArtifactsPath)\$(CrossDir)\crossgen2\crossgen2.dll</Crossgen2Dll>

<PublishReadyToRunUseCrossgen2>true</PublishReadyToRunUseCrossgen2>
Expand Down
Loading