Skip to content

Integrate ARM plan9asm support in llgo#1717

Draft
cpunion wants to merge 2 commits intogoplus:mainfrom
cpunion:wt/plan9asm-arm-smoke
Draft

Integrate ARM plan9asm support in llgo#1717
cpunion wants to merge 2 commits intogoplus:mainfrom
cpunion:wt/plan9asm-arm-smoke

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented Mar 14, 2026

Summary

  • update llgo to the latest merged plan9asm revision
  • wire ARM-specific plan9asm integration for internal/bytealg and ARM atomic alt packages
  • filter test-only asm inputs and add baremetal runtime splits needed for ARM embedded builds

Testing

  • go test ./internal/plan9asm -run TestExtraAsmSigsAndDeclMap -v
  • go test ./internal/build -run "TestPkgSFiles|TestSelectedSFiles|TestShouldSkipPlan9AsmSFilesForTarget|TestHasAltPkgForTarget" -v

Notes

  • ARM baremetal targets remain build/integration scope only here; this PR does not claim stdlib runtime smoke via emulator.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances llgo's support for ARM architecture by integrating the latest plan9asm features. It enables ARM-specific assembly optimizations for critical internal packages, streamlines the build process by filtering irrelevant assembly files, and lays the groundwork for ARM embedded builds through comprehensive baremetal runtime adaptations. These changes improve performance and broaden the platform compatibility of llgo for ARM targets.

Highlights

  • Dependency Update: Updated the github.com/goplus/plan9asm dependency to its latest revision.
  • ARM-Specific Plan9asm Integration: Wired ARM-specific plan9asm integration for internal/bytealg and internal/runtime/atomic packages, including manual function signatures and alternative package handling.
  • Assembly File Filtering: Implemented filtering to skip test-only assembly (.s and .S) files during compilation.
  • Baremetal Runtime Splits: Added baremetal runtime splits for ARM embedded builds, providing minimal implementations for godebug, link, poll, signal, and time packages.
  • Syscall Assembly Skipping: Introduced logic to skip Linux/ARM syscall assembly for embedded ARM targets to prevent pulling in syscall-specific plan9asm frame quirks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • go.mod
    • Updated the github.com/goplus/plan9asm module version.
  • go.sum
    • Updated checksums for the github.com/goplus/plan9asm module.
  • internal/build/build.go
    • Modified buildPkg to conditionally compile plan9asm s-files based on alternative package presence.
  • internal/build/plan9asm.go
    • Added logic to skip plan9asm signature generation for alternative packages that are not additive.
    • Extended hasAltPkgForTarget to specifically enable alternative package usage for internal/runtime/atomic on ARM.
    • Extended plan9asmEnabledByDefault to enable plan9asm for internal/runtime/atomic on ARM.
    • Refactored pkgSFiles to use selectedSFiles and shouldSkipPlan9AsmSFilesForTarget for filtering and skipping assembly files.
    • Introduced selectedSFiles function to filter out test-only assembly files.
    • Introduced shouldSkipPlan9AsmSFilesForTarget function to skip syscall assembly for embedded ARM targets.
  • internal/build/plan9asm_altpkg_test.go
    • Added TestHasAltPkgForTarget_UsesAtomicFallbackOnArm to verify atomic fallback behavior on ARM.
  • internal/build/plan9asm_sfiles_test.go
    • Added a new test file plan9asm_sfiles_test.go with tests for selectedSFiles and shouldSkipPlan9AsmSFilesForTarget.
  • internal/plan9asm/bytealg_arm_sigs_test.go
    • Added a new test file bytealg_arm_sigs_test.go to verify plan9asm signatures for internal/bytealg ARM helpers.
  • internal/plan9asm/translate.go
    • Added manual FuncSig definitions for internal/bytealg ARM functions (cmpbody, memeqbody, countbytebody, indexbytebody).
  • internal/plan9asm/translate_helpers_test.go
    • Added test cases to verify ARM manual signatures for internal/bytealg.
  • runtime/build.go
    • Added internal/runtime/atomic to the altPkgs map with altPkgReplace mode.
  • runtime/internal/lib/internal/runtime/atomic/atomic_llgo_arm.go
    • Added a new file atomic_llgo_arm.go providing ARM-specific atomic operations with go:linkname directives.
  • runtime/internal/lib/internal/runtime/atomic/types_llgo_arm.go
    • Added a new file types_llgo_arm.go defining ARM-specific atomic types.
  • runtime/internal/lib/runtime/godebug_baremetal_llgo.go
    • Added a new file godebug_baremetal_llgo.go for baremetal godebug runtime splits.
  • runtime/internal/lib/runtime/godebug_linkname_llgo.go
    • Modified build tags to exclude baremetal.
  • runtime/internal/lib/runtime/link_baremetal_llgo.go
    • Added a new file link_baremetal_llgo.go for baremetal runtime link functions.
  • runtime/internal/lib/runtime/link_linux_llgo.go
    • Modified build tags to exclude baremetal.
  • runtime/internal/lib/runtime/poll_baremetal_llgo.go
    • Added a new file poll_baremetal_llgo.go for baremetal runtime poll hooks.
  • runtime/internal/lib/runtime/poll_linkname_llgo.go
    • Modified build tags to exclude baremetal.
  • runtime/internal/lib/runtime/signal_baremetal_llgo.go
    • Added a new file signal_baremetal_llgo.go for baremetal runtime signal handlers.
  • runtime/internal/lib/runtime/signal_llgo.go
    • Modified build tags to exclude baremetal.
  • runtime/internal/lib/runtime/time_baremetal_legacy_llgo.go
    • Added a new file time_baremetal_legacy_llgo.go for baremetal runtime timer hooks for Go versions before 1.23.
  • runtime/internal/lib/runtime/time_baremetal_llgo.go
    • Added a new file time_baremetal_llgo.go for baremetal runtime timer hooks for Go 1.23+.
  • runtime/internal/lib/runtime/time_llgo.go
    • Modified build tags to exclude baremetal.
  • runtime/internal/lib/runtime/time_llgo_go123.go
    • Modified build tags to exclude baremetal.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request integrates ARM plan9asm support and adds build infrastructure for ARM baremetal targets. The changes are extensive, touching the build system, plan9asm translator, and runtime. The logic for conditional compilation of assembly files and handling of alternative packages for ARM seems correct. The addition of manual signatures for internal/bytealg on ARM is a key part of this. However, there is a critical issue in the new ARM atomic implementation (runtime/internal/lib/internal/runtime/atomic/atomic_llgo_arm.go), where the atomic operations are not actually atomic. This makes them unsafe for any multi-threaded environment. While this might be a placeholder for single-threaded baremetal targets, the build tag //go:build arm is too broad and suggests it applies to all ARM targets. This needs to be addressed. I've also included a minor suggestion for code consistency.

@xgopilot
Copy link
Copy Markdown
Contributor

xgopilot bot commented Mar 14, 2026

Good work wiring up ARM plan9asm support with solid test coverage for the new signatures and helper functions. The baremetal stubs are well-organized with correct build tag exclusions. A few areas need attention:

  1. Build tag scope on ARM atomics//go:build arm applies to all ARM targets, not just baremetal. The non-atomic implementations need either a baremetal guard or prominent documentation.
  2. Hard-coded "internal/runtime/atomic" checks are scattered across plan9asm.go instead of being data-driven through altPkgs.
  3. CAS retry loops in the non-atomic ARM atomics are misleading dead code — they always succeed on the first iteration.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (1398fa6) to head (830986c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1717   +/-   ##
=======================================
  Coverage   93.15%   93.16%           
=======================================
  Files          48       48           
  Lines       13350    13367   +17     
=======================================
+ Hits        12436    12453   +17     
  Misses        727      727           
  Partials      187      187           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cpunion cpunion marked this pull request as draft March 14, 2026 13:51
@cpunion cpunion force-pushed the wt/plan9asm-arm-smoke branch from 8a54b80 to 830986c Compare March 14, 2026 14:44
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

Successfully merging this pull request may close these issues.

1 participant