Skip to content

Add CPU feature detection using elf_aux_info#130901

Merged
janvorli merged 1 commit into
dotnet:mainfrom
am11:patch-55
Jul 20, 2026
Merged

Add CPU feature detection using elf_aux_info#130901
janvorli merged 1 commit into
dotnet:mainfrom
am11:patch-55

Conversation

@am11

@am11 am11 commented Jul 16, 2026

Copy link
Copy Markdown
Member

When running AOT smoke tests on freebsd-arm64, it was failing AOT apps with:

[6](https://github.com/am11/CrossRepoCITesting/actions/runs/29426499240/job/87390152366#step:5:336)
  Running /home/runner/work/CrossRepoCITesting/CrossRepoCITesting/runtime/artifacts/tests/coreclr/freebsd.arm64.Checked/nativeaot/SmokeTests/PInvoke/PInvoke/native/PInvoke...
  
  The current CPU is missing one or more of the following instruction sets: AdvSimd
  Abort trap

It's a net11.0 regression from #118101; now passing: https://github.com/am11/CrossRepoCITesting/actions/runs/29519372748/job/87692356810

@github-actions github-actions Bot added the area-PAL-coreclr only for closed issues label Jul 16, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 16, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@am11 am11 added arch-arm64 os-freebsd FreeBSD OS area-NativeAOT-coreclr and removed area-PAL-coreclr only for closed issues labels Jul 16, 2026
@am11
am11 requested a review from jkotas July 16, 2026 18:13
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@am11 am11 mentioned this pull request Jul 16, 2026
Comment thread src/native/minipal/cpufeatures.c
@am11
am11 requested a review from janvorli July 16, 2026 19:08

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@am11

am11 commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

BA is green, other failures are unrelated to conditional freebsd change.

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "f833df72b91e46156bf20609faea2e180b3d9917",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "a0ad638fb14e9f3ad2c11588f6fb3a1610c8be08",
  "last_reviewed_commit": "f833df72b91e46156bf20609faea2e180b3d9917",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "a0ad638fb14e9f3ad2c11588f6fb3a1610c8be08",
  "last_recorded_worker_run_id": "29687172567",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "f833df72b91e46156bf20609faea2e180b3d9917",
      "review_id": 4730767519
    }
  ]
}

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Holistic Review

Motivation: On freebsd-arm64, NativeAOT smoke tests were aborting with "The current CPU is missing one or more of the following instruction sets: AdvSimd" — a net11.0 regression from #118101. FreeBSD lacks the glibc getauxval/asm/hwcap.h mechanism, so HAVE_AUXV_HWCAP_H is false there and the ARM64 baseline (AdvSimd) was never detected, wrongly marking the CPU as unsupported. The motivation is clear and well documented with reproducing CI links.

Approach: Adds a check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_ELF_AUX_INFO) probe and a corresponding minipalconfig.h.in entry, then introduces a third ARM64 hardware-capability branch. The getauxval/elf_aux_info/sysctlbyname selection is restructured into a single #if HAVE_AUXV_HWCAP_H ... #elif HAVE_ELF_AUX_INFO ... #elif HAVE_SYSCTLBYNAME chain. On the FreeBSD branch, hwCap/hwCap2 are zero-initialized and populated via elf_aux_info(AT_HWCAP, ...) / elf_aux_info(AT_HWCAP2, ...), then feed the existing shared HWCAP_*/HWCAP2_* bit-test logic. hwCap2 is hoisted up so both the glibc and FreeBSD paths declare it once. The include of <sys/auxv.h> is now guarded by HAVE_ELF_AUX_INFO at the top of the file, and minipalconfig.h is included unconditionally (moved out of the #else HOST_WINDOWS block). This is a minimal, well-targeted change that preserves existing Linux and macOS behavior.

Summary: A small, focused, low-risk portability fix that correctly restores ARM64 baseline ISA detection on FreeBSD. The control-flow restructuring keeps the Linux and macOS paths semantically identical. Zero-initializing the hwcaps before elf_aux_info is the right defensive choice since a failed lookup leaves the buffer untouched (it would then just report no optional features rather than crashing). I have one non-blocking portability observation, filed inline, about the scope of the fallback HWCAP_* macro definitions on the new FreeBSD branch. Overall this looks good to merge; verify the FreeBSD CI/cross-repo AOT run is green.

Detailed Findings

See the inline comment on src/native/minipal/cpufeatures.c regarding the fallback HWCAP_*/HWCAP2_* #ifndef definitions being scoped only to the HAVE_AUXV_HWCAP_H include block, which leaves the new elf_aux_info branch dependent on FreeBSD's own headers providing every constant. Non-blocking, but worth considering for robustness across FreeBSD versions.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 68.3 AIC · ⌖ 11.2 AIC · ⊞ 10K

Comment thread src/native/minipal/cpufeatures.c
@janvorli
janvorli merged commit 8cf83fa into dotnet:main Jul 20, 2026
193 of 200 checks passed
@am11
am11 deleted the patch-55 branch July 20, 2026 13:43
@am11 am11 mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-arm64 area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member os-freebsd FreeBSD OS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants