Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4cc95f8
add nanoclr posix
Ellerbach Apr 14, 2026
31e637e
Code style fixes for nanoframework/nf-interpreter PR#3313 (#3314)
nfbot Apr 15, 2026
20e1127
Update src/CLR/Include/nanoCLR_Hardware.h
Ellerbach Apr 15, 2026
9cfd3d6
some changes on PR feedback
Ellerbach Apr 15, 2026
7b5b411
more changes
Ellerbach Apr 15, 2026
81bb833
fix linux pipeline
Ellerbach Apr 15, 2026
ed98944
Code style fixes for nanoframework/nf-interpreter PR#3313 (#3318)
nfbot Apr 15, 2026
24c3e54
fixibng build
Ellerbach Apr 15, 2026
44df935
more chqnges
Ellerbach Apr 15, 2026
d3a4964
more changes
Ellerbach Apr 15, 2026
889f720
fixing serial port warning and linux build
Ellerbach Apr 15, 2026
fc99cf3
Code style fixes for nanoframework/nf-interpreter PR#3313 (#3320)
nfbot Apr 15, 2026
77e9b2c
fixing linux build, hopefully for real
Ellerbach Apr 15, 2026
5334e7f
trying to fix the zin dll build
Ellerbach Apr 15, 2026
55b091e
revert Thread.cpp to main - debug print block used uninitialized hr c…
Ellerbach Apr 15, 2026
4bb6fc1
latest small fixes
Ellerbach Apr 15, 2026
194468c
Merge branch 'main' into fix-nanoclr-update
Ellerbach Apr 15, 2026
8e6830f
Code style fixes for nanoframework/nf-interpreter PR#3313 (#3323)
nfbot Apr 15, 2026
9e54c14
adjusting for building everything and packaging everything properly
Ellerbach Apr 15, 2026
8139a5f
fix: guard smoke-run for cross-compiled POSIX legs
Ellerbach Apr 15, 2026
3fdd33e
fix: use macOS-latest runner for osx-x64 cross-compile leg
Ellerbach Apr 15, 2026
374c747
fix: cross-compile linux-arm64 on ubuntu-22.04 x64 runner
Ellerbach Apr 15, 2026
7e204c4
chore: publish nupkg as pipeline artifact for inspection
Ellerbach Apr 15, 2026
bcfc304
fix: use TargetFramework for native lib PackagePath in nupkg
Ellerbach Apr 16, 2026
d9d0096
fix: probe portable RID fallback in NativeNanoClrLoader
Ellerbach Apr 16, 2026
78249c6
fixing encoding
Ellerbach Apr 16, 2026
fb342ec
last fix
Ellerbach Apr 16, 2026
4a43e01
adjusting pal time for linux
Ellerbach Apr 16, 2026
591ca49
attempt to fix linux run issues
Ellerbach Apr 16, 2026
61ec205
debug for linux
Ellerbach Apr 16, 2026
d2f0694
timing fix for linux execution
Ellerbach Apr 17, 2026
82477e0
reverting
Ellerbach Apr 17, 2026
f349f9a
fixing linuxfixing properly linux timing
Ellerbach Apr 17, 2026
db7b19e
fix git mess
Ellerbach Apr 17, 2026
27508fe
fixing posix for real this time, yeah!
Ellerbach Apr 17, 2026
5fcb759
more linux fixes
Ellerbach Apr 17, 2026
efea4e0
more fixes from PR review and cleaning
Ellerbach Apr 17, 2026
94db178
Merge branch 'main' into fix-nanoclr-update
Ellerbach Apr 17, 2026
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
110 changes: 110 additions & 0 deletions .github/workflows/posix-nanoclr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: posix-nanoclr

on:
push:
paths:
- "targets/posix/**"
- "src/CLR/**"
- "src/HAL/**"
- "src/PAL/**"
- ".github/workflows/posix-nanoclr.yml"
pull_request:
paths:
- "targets/posix/**"
- "src/CLR/**"
- "src/HAL/**"
- "src/PAL/**"
- ".github/workflows/posix-nanoclr.yml"

jobs:
build-posix-nanoclr:
strategy:
matrix:
include:
- os: macos-14
label: macOS-arm64
posix_rid: osx-arm64
- os: macos-latest
label: macOS-x64
posix_rid: osx-x64
- os: ubuntu-22.04
label: Linux-x64
posix_rid: linux-x64
- os: ubuntu-22.04
label: Linux-arm64
posix_rid: linux-arm64
fail-fast: false

runs-on: ${{ matrix.os }}
name: Build (${{ matrix.label }})

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install arm64 cross-toolchain
if: matrix.posix_rid == 'linux-arm64'
run: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu

- name: Install Ninja (if missing)
run: |
if ! command -v ninja >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -y ninja-build
else
brew install ninja
fi
fi

- name: Configure
run: |
# Derive cmake arch from the RID matrix variable.
case "${{ matrix.posix_rid }}" in
osx-arm64|linux-arm64) NANO_ARCH=arm64 ;;
osx-x64|linux-x64) NANO_ARCH=x86_64 ;;
esac
# For linux-arm64, cross-compile via the aarch64-linux-gnu toolchain.
TOOLCHAIN_ARG=""
if [ "${{ matrix.posix_rid }}" = "linux-arm64" ]; then
TOOLCHAIN_ARG="-DCMAKE_TOOLCHAIN_FILE=$(pwd)/targets/posix/toolchain-aarch64-linux-gnu.cmake"
fi
cmake -S targets/posix -B build/posix -G Ninja \
-DNANO_POSIX_ARCH=${NANO_ARCH} \
-DNANO_POSIX_ENABLE_SMOKE=ON \
${TOOLCHAIN_ARG}

- name: Build
run: cmake --build build/posix --verbose

- name: Smoke Run
run: |
set -euo pipefail
# Normalise host CPU name: Linux arm64 reports 'aarch64'; macOS reports 'arm64'.
case "$(uname -m)" in
arm64|aarch64) HOST_CANONICAL=arm64 ;;
x86_64) HOST_CANONICAL=x86_64 ;;
*) HOST_CANONICAL="$(uname -m)" ;;
esac
case "${{ matrix.posix_rid }}" in
*-arm64) TARGET_ARCH=arm64 ;;
*-x64) TARGET_ARCH=x86_64 ;;
esac
if [ "${HOST_CANONICAL}" = "${TARGET_ARCH}" ]; then
./build/posix/bin/nanoFramework.nanoCLR.test | tee build/posix/smoke.log
if ! grep -Eq '[0-9]+\.[0-9]+\.[0-9]+' build/posix/smoke.log; then
echo "ERROR: smoke output validation failed."
exit 1
fi
else
echo "Skipping smoke run: host=$(uname -m) (${HOST_CANONICAL}), target=${TARGET_ARCH} (cross-compiled binary cannot execute on this runner)."
fi
Comment thread
Ellerbach marked this conversation as resolved.

- name: Upload Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: posix-nanoclr-${{ matrix.label }}
path: |
build/posix/lib/nanoFramework.nanoCLR.*
build/posix/bin/nanoFramework.nanoCLR.test
build/posix/smoke.log
207 changes: 205 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ jobs:
echo "##vso[task.setvariable variable=BUILD_TI;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_THREADX;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_WIN32;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_POSIX;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_NANOCLR_CLI;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_ALL;isOutput=true]false"

Expand Down Expand Up @@ -259,6 +260,14 @@ jobs:

Write-host "##[command] Building nanoCLR target"
}

if( ($files.where{$_.Contains('targets/posix')}).Count -gt 0)
{
# files at POSIX folder
echo "##vso[task.setvariable variable=BUILD_POSIX;isOutput=true]true"

Write-host "##[command] Building POSIX nanoCLR target"
}

if(
(($files.where{$_.Contains('targets/netcore/nanoFramework.nanoCLR.CLI')}).Count -gt 0) -Or
Expand Down Expand Up @@ -354,7 +363,8 @@ jobs:
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_FREERTOS'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_TI'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_THREADX'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_WIN32'], true)
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_WIN32'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_POSIX'], true)
)
)

Expand Down Expand Up @@ -1033,6 +1043,157 @@ jobs:

- template: azure-pipelines-templates/publish-nanoclr.yml

#################
# POSIX host target (macOS + Linux)
- job: Build_POSIX_nanoCLR
strategy:
matrix:
macOS_arm64:
vmImage: 'macos-14'
POSIX_RID: osx-arm64
macOS_x64:
vmImage: 'macOS-latest'
POSIX_RID: osx-x64
Linux_x64:
vmImage: 'ubuntu-22.04'
POSIX_RID: linux-x64
Linux_arm64:
vmImage: 'ubuntu-22.04'
POSIX_RID: linux-arm64
maxParallel: 4
condition: >-
or(
and(
succeeded('Check_Code_Style'),
ne( dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true ),
or(
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_POSIX'], true)
)
),
and(
eq(variables['Build.Reason'], 'Manual'),
or(
eq(variables['BUILD_ALL__'], 'true'),
eq(variables['BUILD_POSIX__'], 'true')
)
)
)

dependsOn:
- Check_Build_Options
- Check_Code_Style

pool:
vmImage: $(vmImage)

variables:
- group: sign-client-credentials

steps:
- checkout: self

- bash: |
set -euo pipefail
if [[ "${BUILD_SOURCEBRANCH}" == *"develop"* || "${BUILD_SOURCEBRANCH}" == *"release"* || "${FORCEUPLOAD}" == "true" ]]; then
echo "##vso[task.setvariable variable=CLOUDSMITH_REPO]nanoframework-images-dev"
else
echo "##vso[task.setvariable variable=CLOUDSMITH_REPO]nanoframework-images"
fi
displayName: Set Cloudsmith repo path
env:
BUILD_SOURCEBRANCH: $(Build.SourceBranch)
FORCEUPLOAD: $(ForceUpload)

- bash: |
set -euo pipefail

# Derive cmake arch and library extension from the POSIX_RID matrix variable.
case "$(POSIX_RID)" in
osx-arm64|linux-arm64) NANO_ARCH=arm64 ; LIB_EXT=dylib ;;
osx-x64) NANO_ARCH=x86_64 ; LIB_EXT=dylib ;;
linux-x64) NANO_ARCH=x86_64 ; LIB_EXT=so ;;
esac
# Correct extension for Linux regardless of arch.
[[ "$(POSIX_RID)" == linux-* ]] && LIB_EXT=so

# Install ninja if not present (Linux agents).
if ! command -v ninja >/dev/null 2>&1; then
sudo apt-get install -y ninja-build
fi

# Install arm64 cross-compiler when building linux-arm64 on an x86_64 agent.
TOOLCHAIN_ARG=""
if [ "$(POSIX_RID)" = "linux-arm64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
TOOLCHAIN_ARG="-DCMAKE_TOOLCHAIN_FILE=$(pwd)/targets/posix/toolchain-aarch64-linux-gnu.cmake"
fi

echo "RID=$(POSIX_RID) ARCH=${NANO_ARCH} LIB_EXT=${LIB_EXT}"

cmake -S targets/posix -B build/posix -G Ninja \
-DNANO_POSIX_ARCH=${NANO_ARCH} \
-DNANO_POSIX_ENABLE_SMOKE=ON \
${TOOLCHAIN_ARG}
cmake --build build/posix
# Smoke-run the test binary only when its architecture matches the runner.
# For cross-compiled builds (e.g. osx-x64 on an arm64 agent) we skip the run
# but the library artifact is still staged and published.
case "$(uname -m)" in
arm64|aarch64) HOST_CANONICAL=arm64 ;;
x86_64) HOST_CANONICAL=x86_64 ;;
*) HOST_CANONICAL="$(uname -m)" ;;
esac
if [ "${HOST_CANONICAL}" = "${NANO_ARCH}" ]; then
./build/posix/bin/nanoFramework.nanoCLR.test | tee build/posix/smoke.log
if ! grep -Eq '[0-9]+\.[0-9]+\.[0-9]+' build/posix/smoke.log; then
echo "ERROR: smoke output validation failed, expected semantic version in output."
exit 1
fi
CLR_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' build/posix/smoke.log | head -1)
else
echo "Skipping smoke run: host=$(uname -m) (${HOST_CANONICAL}), target=${NANO_ARCH} (cross-compiled binary)."
CLR_VERSION="0.0.0.0"
fi
echo "Detected CLR version: ${CLR_VERSION}"
echo "##vso[task.setvariable variable=POSIX_CLR_VERSION]${CLR_VERSION}"
echo "##vso[task.setvariable variable=POSIX_LIB_EXT]${LIB_EXT}"

# Stage under runtimes/{rid}/native/ so the CLI pack job can collect all RIDs.
STAGING="$(Build.ArtifactStagingDirectory)/runtimes/$(POSIX_RID)/native"
mkdir -p "${STAGING}"
cp "build/posix/lib/nanoFramework.nanoCLR.${LIB_EXT}" "${STAGING}/"
displayName: Build and smoke run POSIX nanoCLR

- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish POSIX nanoCLR artifact
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)"
artifactName: nanoclr_posix_$(POSIX_RID)
artifactType: pipeline

- bash: |
set -euo pipefail
pip install --upgrade cloudsmith-cli --quiet
cloudsmith push raw net-nanoframework/$(CLOUDSMITH_REPO) \
"$(Build.ArtifactStagingDirectory)/runtimes/$(POSIX_RID)/native/nanoFramework.nanoCLR.$(POSIX_LIB_EXT)" \
--name "nanoCLR_$(POSIX_RID)" \
--version "$(POSIX_CLR_VERSION)" \
-k "$(CLOUDSMITH_KEY)"
condition: >-
and(
succeeded(),
or(
eq(variables['ForceUpload'], true),
and(
eq(variables['Build.SourceBranchName'], 'main'),
eq(variables['System.PullRequest.PullRequestId'], '')
)
)
)
displayName: Upload POSIX nanoCLR to Cloudsmith

#################
# nanoCLR CLI tool
- job: Build_nanoCLR_CLI
Expand All @@ -1059,6 +1220,7 @@ jobs:
- Check_Build_Options
- Check_Code_Style
- Build_WIN32_nanoCLR
- Build_POSIX_nanoCLR

pool:
vmImage: "windows-2022"
Expand Down Expand Up @@ -1143,13 +1305,44 @@ jobs:
eq(variables['System.PullRequest.PullRequestId'], '')
)

# Download all four POSIX native libraries and merge them into a single
# runtimes/{rid}/native/ staging tree that the pack step will consume.
# continueOnError=true so a skipped POSIX leg doesn't block the CLI pack.
- task: DownloadPipelineArtifact@2
displayName: 'Download POSIX artifact: osx-arm64'
continueOnError: true
inputs:
artifact: nanoclr_posix_osx-arm64
path: "$(Build.SourcesDirectory)/native-libs"

- task: DownloadPipelineArtifact@2
displayName: 'Download POSIX artifact: osx-x64'
continueOnError: true
inputs:
artifact: nanoclr_posix_osx-x64
path: "$(Build.SourcesDirectory)/native-libs"

- task: DownloadPipelineArtifact@2
displayName: 'Download POSIX artifact: linux-x64'
continueOnError: true
inputs:
artifact: nanoclr_posix_linux-x64
path: "$(Build.SourcesDirectory)/native-libs"

- task: DownloadPipelineArtifact@2
displayName: 'Download POSIX artifact: linux-arm64'
continueOnError: true
inputs:
artifact: nanoclr_posix_linux-arm64
path: "$(Build.SourcesDirectory)/native-libs"

- task: MSBuild@1
condition: succeeded()
displayName: Pack nanoCLR CLI
inputs:
solution: "nf-interpreter/targets/netcore/nanoFramework.nanoCLR.CLI/nanoFramework.nanoCLR.CLI.csproj"
platform: "Any CPU"
msbuildArguments: "/p:PublicRelease=true /t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) "
msbuildArguments: "/p:PublicRelease=true /t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:NativeBinRoot=$(Build.SourcesDirectory)/native-libs/"
configuration: "Release"
maximumCpuCount: true

Expand Down Expand Up @@ -1182,6 +1375,14 @@ jobs:
Contents: "nanoFramework.nanoCLR.dll"
TargetFolder: "$(Build.ArtifactStagingDirectory)/nanoclr"

- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish nanoclr NuGet package
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)"
artifactName: nanoclr_nuget
artifactType: pipeline

- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish nanoclr
Expand Down Expand Up @@ -1347,6 +1548,7 @@ jobs:
- Build_TI_SimpleLink_targets
- Build_ThreadX_targets
- Build_WIN32_nanoCLR
- Build_POSIX_nanoCLR
- Build_nanoCLR_CLI
- Check_Code_Style
condition: >-
Expand All @@ -1359,6 +1561,7 @@ jobs:
failed('Build_TI_SimpleLink_targets'),
failed('Build_ThreadX_targets'),
failed('Build_WIN32_nanoCLR'),
failed('Build_POSIX_nanoCLR'),
failed('Build_nanoCLR_CLI')
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/CLR/Core/CLR_RT_StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ void CLR_RT_StackFrame::SetResult_I4(CLR_INT32 val)
top.SetInteger(val);
}

void CLR_RT_StackFrame::SetResult_I8(CLR_INT64 &val)
void CLR_RT_StackFrame::SetResult_I8(const CLR_INT64 &val)
{
NATIVE_PROFILE_CLR_CORE();
CLR_RT_HeapBlock &top = PushValue();
Expand Down
Loading
Loading