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

Add linux-loongarch64 CI leg #111086

Merged
merged 12 commits into from
Jan 8, 2025
3 changes: 2 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@

<PropertyGroup>
<!-- CLR NativeAot only builds in a subset of the matrix -->
<_IsCommunityCrossArchitecture Condition="'$(CrossBuild)' == 'true' and ('$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64')">true</_IsCommunityCrossArchitecture>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<_NativeAotSupportedOS Condition="'$(TargetOS)' == 'windows' or '$(TargetOS)' == 'linux' or '$(TargetOS)' == 'osx' or '$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvossimulator' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'freebsd'">true</_NativeAotSupportedOS>
<_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true</_NativeAotSupportedArch>
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true'">true</NativeAotSupported>
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true' and '$(_IsCommunityCrossArchitecture)' != 'true'">true</NativeAotSupported>
<UseNativeAotForComponents Condition="'$(NativeAotSupported)' == 'true' and '$(TargetOS)' == '$(HostOS)' and '$(TargetsLinuxBionic)' != 'true'">true</UseNativeAotForComponents>

<!-- If we're building clr.nativeaotlibs and not building the CLR runtime, compile libraries against NativeAOT CoreLib -->
Expand Down
21 changes: 21 additions & 0 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,27 @@ jobs:
crossBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

# Linux LoongArch64

- ${{ if containsValue(parameters.platforms, 'linux_loongarch64') }}:
- template: xplat-setup.yml
parameters:
jobTemplate: ${{ parameters.jobTemplate }}
helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
variables: ${{ parameters.variables }}
osGroup: linux
archType: loongarch64
targetRid: linux-loongarch64
platform: linux_loongarch64
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
container: linux_loongarch64
jobParameters:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
crossBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

# WASI WebAssembly

- ${{ if containsValue(parameters.platforms, 'wasi_wasm') }}:
Expand Down
5 changes: 5 additions & 0 deletions eng/pipelines/common/templates/pipeline-with-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ extends:
env:
ROOTFS_DIR: /crossrootfs/riscv64

linux_loongarch64:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net10.0-cross-loongarch64
env:
ROOTFS_DIR: /crossrootfs/loongarch64

debian-12-gcc14-amd64:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-12-gcc14-amd64

Expand Down
28 changes: 4 additions & 24 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,28 +478,7 @@ extends:
eq(variables['isRollingBuild'], true))

#
# Build CoreCLR without building test assets
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
buildConfig: checked
runtimeFlavor: coreclr
platforms:
- linux_riscv64
jobParameters:
testScope: innerloop
nameSuffix: CoreCLR
buildArgs: -s clr.native+clr.tools+clr.corelib+clr.nativecorelib+clr.aot+clr.packages -c $(_BuildConfig)
timeoutInMinutes: 120
condition: >-
or(
eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'], true),
eq(variables['isRollingBuild'], true))

#
# Build CoreCLR + Libs + Host + Packs
# Build CoreCLR + Libs + Host
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand All @@ -509,10 +488,12 @@ extends:
runtimeFlavor: coreclr
platforms:
- freebsd_x64
- linux_riscv64
- linux_loongarch64
jobParameters:
testScope: innerloop
nameSuffix: CoreCLR
buildArgs: -s clr+libs+host+packs -c $(_BuildConfig) -rc Checked
buildArgs: -s clr+libs+host -c $(_BuildConfig) -rc Checked
timeoutInMinutes: 120
condition: >-
or(
Expand Down Expand Up @@ -793,7 +774,6 @@ extends:
runtimeFlavor: mono
platforms:
- linux_musl_x64
- linux_riscv64
- osx_x64
jobParameters:
testGroup: innerloop
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/loongarch64/GcProbe.S
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ NESTED_ENTRY RhpGcProbeHijack, _TEXT, NoHandler
jirl $r0, $ra, 0

LOCAL_LABEL(WaitForGC):
lu12i.w $t3, ((DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK) >> 12) & 0xfffff
ori $t3, $t3, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK) & 0xfff
lu12i.w $t3, ((DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK_HI) >> 12) & 0xfffff
ori $t3, $t3, (DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_R4 + PTFF_SAVE_R5 + PTFF_THREAD_HIJACK_HI) & 0xfff
b C_FUNC(RhpWaitForGC)
NESTED_END RhpGcProbeHijack

Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/nativeaot/Runtime/unix/PalRedhawkInline.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ FORCEINLINE int64_t PalInterlockedCompareExchange64(_Inout_ int64_t volatile *pD
return result;
}

#if defined(HOST_AMD64) || defined(HOST_ARM64)
#if defined(HOST_AMD64) || defined(HOST_ARM64) || defined(HOST_LOONGARCH64)
FORCEINLINE uint8_t PalInterlockedCompareExchange128(_Inout_ int64_t volatile *pDst, int64_t iValueHigh, int64_t iValueLow, int64_t *pComparandAndResult)
{
__int128_t iComparand = ((__int128_t)pComparandAndResult[1] << 64) + (uint64_t)pComparandAndResult[0];
// NOTE: for LoongArch64, it supports 128bits atomic from 3A6000-CPU which is ISA1.1's version.
// The LA64's compiler will translate the `__sync_val_compare_and_swap` into calling the libatomic's library interface to emulate
Copy link
Member

Choose a reason for hiding this comment

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

Does the build target ISA1.0 or ISA1.1 by default? If it targets ISA1.0 by default, this implementation is broken. This should be TODO instead of NOTE, ideally with a link to an issue that tracks fixing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to TODO linking #109276. This is @shushanhf's comment. CI cross build is not linking libatomic, so it should be ISA1.1.

// the 128-bit CAS by mutex_lock if the target processor doesn't support the ISA1.1.
// But this emulation by libatomic doesn't satisfy requirements here which it must update two adjacent pointers atomically.
__int128_t iResult = __sync_val_compare_and_swap((__int128_t volatile*)pDst, iComparand, ((__int128_t)iValueHigh << 64) + (uint64_t)iValueLow);
PalInterlockedOperationBarrier();
pComparandAndResult[0] = (int64_t)iResult; pComparandAndResult[1] = (int64_t)(iResult >> 64);
return iComparand == iResult;
}
#endif // HOST_AMD64
#endif // HOST_AMD64 || HOST_ARM64 || HOST_LOONGARCH64

#ifdef HOST_64BIT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ bool UnixNativeCodeManager::GetReturnAddressHijackInfo(MethodInfo * pMethodIn
}

*ppvRetAddrLocation = (PTR_PTR_VOID)pRegisterSet->pLR;
#elif
#else
am11 marked this conversation as resolved.
Show resolved Hide resolved
PTR_uintptr_t pRA = pRegisterSet->pRA;
if (!VirtualUnwind(pMethodInfo, pRegisterSet))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ C_FUNC(\Name):
#define PTFF_SAVE_R4 0x00000800
#define PTFF_SAVE_R5 0x00001000
#define PTFF_SAVE_ALL_PRESERVED 0x000001FF // NOTE: r23-r31
#define PTFF_THREAD_HIJACK_HI 0x00000002 // upper 32 bits of the PTFF_THREAD_HIJACK

#define DEFAULT_FRAME_SAVE_FLAGS (PTFF_SAVE_ALL_PRESERVED + PTFF_SAVE_SP)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Force System.Private.CoreLib.dll into a special IL output directory -->
<OutputPath>$(RuntimeBinDir)IL/</OutputPath>
<Configurations>Debug;Release;Checked</Configurations>
<Platforms>x64;x86;arm;armv6;arm64;riscv64;s390x;wasm;ppc64le</Platforms>
<Platforms>x64;x86;arm;arm64</Platforms>
Copy link
Member Author

Choose a reason for hiding this comment

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

Aligned with coreclr. Platforms is relevant in VS context.


<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
Expand Down Expand Up @@ -57,6 +57,9 @@
<PropertyGroup Condition="'$(Platform)' == 'arm64'">
<DefineConstants>$(DefineConstants);TARGET_ARM64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'loongarch64'">
<DefineConstants>$(DefineConstants);TARGET_LOONGARCH64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'riscv64'">
<DefineConstants>$(DefineConstants);TARGET_RISCV64</DefineConstants>
</PropertyGroup>
Expand Down