Skip to content

Build targets task 1: Basic Target Parameter Support for llgo build/run/test commands#1193

Merged
xushiwei merged 9 commits intogoplus:mainfrom
cpunion:targets-refactor-1176
Aug 1, 2025
Merged

Build targets task 1: Basic Target Parameter Support for llgo build/run/test commands#1193
xushiwei merged 9 commits intogoplus:mainfrom
cpunion:targets-refactor-1176

Conversation

@cpunion
Copy link
Collaborator

@cpunion cpunion commented Jul 28, 2025

Impl #1194

  • Import tinygo's targets definitions
  • crosscompile.UseWithTarget to suppport build .o with target
  • _start entry function when libc not ready

Separate PR 1: support shared/static library

  • Supports llgo build -buildmode=c-archive -target xxx
    • Need buildmode support

Separate PR 2: support executable

  • cross platform libc

Separate PR 3: supports linker scripts and emulator (Task 2)

  • Supports linker scripts
  • run emulator with llgo run/test -target xxx

cpunion and others added 2 commits July 29, 2025 15:12
Add comprehensive target configuration parsing and inheritance system:

- Create internal/targets package with config structures
- Support JSON configuration loading with inheritance resolution
- Implement multi-level inheritance (e.g., rp2040 → cortex-m0plus → cortex-m)
- Add 206 target configurations from TinyGo for embedded platforms
- Support core fields: name, llvm-target, cpu, features, build-tags, goos, goarch, cflags, ldflags
- Provide high-level resolver interface for target lookup
- Include comprehensive unit tests with 100% target parsing coverage

This foundation enables future -target parameter support for cross-compilation
to diverse embedded platforms beyond current GOOS/GOARCH limitations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add license attribution for target configuration files derived from TinyGo project:

- Document source from https://github.com/tinygo-org/tinygo/tree/release/targets
- Include complete BSD 3-Clause license from TinyGo project
- Clarify licensing terms for target configuration files
- Ensure proper attribution to TinyGo Authors and Go Authors
- Maintain compliance with original license requirements

This ensures proper license compliance when using TinyGo's target configurations
in the llgo project.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 86.97479% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.93%. Comparing base (5eb833a) to head (b773de0).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
internal/targets/loader.go 83.48% 12 Missing and 6 partials ⚠️
internal/targets/resolver.go 73.52% 6 Missing and 3 partials ⚠️
internal/crosscompile/crosscompile.go 95.50% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1193      +/-   ##
==========================================
+ Coverage   87.84%   87.93%   +0.09%     
==========================================
  Files          29       32       +3     
  Lines        7298     7653     +355     
==========================================
+ Hits         6411     6730     +319     
- Misses        821      844      +23     
- Partials       66       79      +13     

☔ 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.

@cpunion cpunion changed the title Build targets Build targets task 1: Basic Target Parameter Support for llgo build/run/test commands Jul 30, 2025
cpunion and others added 7 commits July 30, 2025 20:16
…ration

- Add LLVMTarget, CPU, Features, BuildTags fields to Export struct
- Implement UseTarget() function for target name-based configuration loading
- Add UseWithTarget() function combining target and goos/goarch fallback
- Include comprehensive unit tests for target integration
- Support 206+ embedded platform configurations with inheritance

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Target field to build.Config struct
- Update build system to use crosscompile.UseWithTarget()
- Enable target-based cross-compilation in build pipeline
- Maintain backward compatibility with existing GOOS/GOARCH workflow

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Target flag variable to support -target parameter
- Update AddBuildFlags to include target platform option
- Enable syntax: -target platform (e.g., rp2040, wasi)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update build command: llgo build -target platform
- Update run command: llgo run -target platform
- Update test command: llgo test -target platform
- Wire target flag to build configuration
- Update usage documentation for new parameter

Examples:
- llgo build -target rp2040 ./firmware
- llgo run -target wasi ./main.go
- llgo test -target cortex-m ./tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@xushiwei xushiwei merged commit aa49fe6 into goplus:main Aug 1, 2025
33 of 34 checks passed
@cpunion cpunion deleted the targets-refactor-1176 branch August 2, 2025 05:43
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.

2 participants