Commit Graph

3284 Commits

Author SHA1 Message Date
xgopilot
0b00e06185 refactor: update platform package to match original Go structure
Updated runtime/internal/lib/internal/platform/platform.go to match
the original Go internal/platform package structure:

- Added OSArch struct with GOOS and GOARCH fields
- Added osArchInfo struct with CgoSupported, FirstClass, and Broken fields
- Created distInfo map using OSArch as keys
- Updated CgoSupported function to use map lookup (matches original implementation)

This change makes the package structure more consistent with Go's
standard library and follows the established pattern more closely.

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-16 05:53:20 +00:00
xgopilot
c4fdb1edc0 refactor: move cgoSupported to internal/platform package
Created runtime/internal/lib/internal/platform package to house the
CgoSupported function, following the established pattern used by other
internal packages like internal/itoa.

Changes:
- Created runtime/internal/lib/internal/platform/platform.go
- Moved cgoSupported function to platform.CgoSupported
- Updated runtime/internal/lib/go/build/build.go to import and use
  the new package

This refactoring improves code organization by separating
platform-specific utilities into their own package, making the code
more maintainable and reusable.

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-16 04:05:58 +00:00
xgopilot
224e3b9440 fix: add Go 1.23+ build constraint to gobuild demo
Add //go:build go1.23 constraint to skip compilation on Go 1.21/1.22
where runtime.(*Func).Name is not implemented in llgo, causing linker
errors when internal/bisect is pulled in as a dependency.

The demo works correctly on Go 1.23+ where the dependency chain or
internal/bisect behavior avoids calling the unimplemented method.

Fixes compatibility issue reported in PR review.

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-16 03:14:32 +00:00
xgopilot
7fbcc8cd10 refactor: use runtime.Version() instead of hardcoded goVersion
Replaced hardcoded goVersion constant with parseGoVersion() function
that dynamically extracts the Go version from runtime.Version().
This eliminates the need to update the version manually.

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-16 02:33:53 +00:00
xgopilot
938f883be9 refactor: use hasAltPkg with minimal implementation (94% reduction)
Learned from other AltPkg implementations to create a truly minimal patch:
- Moved from 2073-line overlay to 127-line hasAltPkg implementation
- Replaced internal package dependencies:
  * internal/buildcfg → runtime.GOARCH/GOOS
  * internal/goversion → hardcoded constant (24)
  * internal/platform.CgoSupported → simplified implementation
  * internal/buildcfg.ToolTags → simplified buildToolTags()
- Used type alias (Context = build.Context) to reference stdlib types
- Added go/build to hasAltPkg map
- Removed overlay entirely

This follows the pattern used by other AltPkg packages and achieves
the minimal patching approach requested.

Demo verified working with llgo.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-15 14:54:29 +00:00
xgopilot
d145967c35 revert: restore full overlay approach for go/build
After investigating the hasAltPkg mechanism, determined that it's not
suitable for go/build.defaultContext() because:

1. hasAltPkg works well for providing additional/alternative functions
2. But defaultContext() needs to REPLACE an existing function that depends
   on internal/buildcfg, internal/goversion, and internal/platform
3. These internal packages cannot be imported from runtime/internal/lib

The full overlay approach (2073 lines) works correctly. Seeking guidance
on whether this is acceptable or if there's an alternative approach.

Demo verified working:
- runtime.Compiler = "llgo"
- go/build.Import() works correctly
- No "unknown compiler" error

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-15 13:11:22 +00:00
xgopilot
2e0fc5fb7f refactor: reduce go/build overlay to minimal 87-line patch
Reduced the go/build overlay from 2073 lines to just 87 lines by only
including the patched defaultContext() function and its direct dependencies
(envOr, defaultGOPATH, and related variables).

The overlay system works by merging with the standard library, so we only
need to provide the functions we're modifying. Unpatched functions
automatically fall back to the Go standard library implementation.

This makes the patch much more maintainable and clearly shows what's
being modified: just the Compiler field assignment in defaultContext().

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-15 12:33:48 +00:00
xgopilot
d8cf93a6cd refactor: move go/build overlay to runtime/internal for minimal patching
- Moved full overlay file from runtime/_overlay/go/build/build.go to
  runtime/internal/go/build/build.go to make it clearer what's being overridden
- Updated runtime/overlay.go to embed from new location
- Created demo under _demo/go/gobuild to demonstrate go/build package working with llgo
- The overlay still contains the full file but is now organized under runtime/internal
  following the project's pattern for patched standard library packages

Fixes #1346

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-15 12:17:38 +00:00
xgopilot
01ada11b74 fix: override go/build.defaultContext() to use gc compiler
Fixes #1346 by creating an overlay for go/build/build.go that sets
Compiler to "gc" in defaultContext(). This allows user code using
go/build package to work with llgo while preserving runtime.Compiler
as "llgo" for identification purposes.

The overlay replaces the entire go/build/build.go file with a modified
version where line 342 changes from 'c.Compiler = runtime.Compiler' to
'c.Compiler = "gc"'. This minimal change ensures go/build recognizes
llgo-compiled binaries without requiring changes to user code.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-15 11:58:36 +00:00
xushiwei
e03f4dacfb Merge pull request #1339 from goplus/xgopilot/claude/issue-1338-1760425043
fix: add runtime.rand and runtime.memhash for hash/maphash support
2025-10-15 06:41:39 +08:00
xushiwei
75fa863da2 Merge pull request #1336 from goplus/xgopilot/claude/issue-1335-1760330027
Add CLAUDE.md: AI Assistant Guide
2025-10-15 06:34:15 +08:00
xushiwei
18ef7200bc Merge pull request #1341 from luoliwoshang/fix-ci-duplicate-runs
ci: prevent duplicate workflow runs for xgopilot branches
2025-10-15 06:30:59 +08:00
luoliwoshang
bf05779f2f ci: prevent duplicate workflow runs for xgopilot branches
Add !xgopilot/** exclusion pattern to all workflow trigger configurations,
matching the existing dependabot pattern. This ensures that xgopilot branches
only trigger CI checks on pull_request events, eliminating redundant push
event triggers.

Fixes #1340

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 19:00:47 +08:00
xgopilot
2b92b527e1 fix: resolve compilation errors in maphash demo
- Fix line 67: Change unused variable 'n' to blank identifier '_'
- Fix line 102: Correct WriteByte call to expect only error return value
  (WriteByte returns only error, not (int, error))

These fixes resolve the compilation errors reported by the CI.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 10:33:30 +00:00
xgopilot
ed3176a6cc test: expand maphash demo with comprehensive API coverage
- Add tests for all major hash/maphash public APIs:
  * Hash basics (WriteString, Sum64, Reset)
  * MakeSeed and SetSeed functionality
  * Write methods (Write, WriteByte, WriteString)
  * Bytes and String convenience functions
- Use panic() for unexpected errors instead of silent failures
- Add proper error checking and validation
- Document Comparable/WriteComparable limitations in overlay

Note: Comparable() and WriteComparable() are not yet supported and will
panic with 'intrinsic' error as they require runtime intrinsic support.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 10:18:28 +00:00
xgopilot
e5ebc32583 fix: add randUint64 wrapper for Go 1.21 compatibility
Implement randUint64() directly in the maphash overlay to ensure compatibility
across Go versions. Go 1.21's randUint64() calls runtime.fastrand64, while
Go 1.22+ calls runtime.rand. The wrapper function bridges to llgo's fastrand64
implementation, avoiding undefined symbol errors on Go 1.21.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 09:19:55 +00:00
xgopilot
3ce198f103 fix: remove llgo:skipall directive from maphash overlay
The llgo:skipall directive was preventing fallback to the standard library,
causing undefined symbol errors for functions like WriteString, MakeSeed, etc.
The overlay now only defines the two linkname functions, allowing typepatch
to handle the rest.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 08:29:26 +00:00
xgopilot
e05c91530e refactor: move hash/maphash linkname bindings to maphash package
Move runtime_rand and runtime_memhash linkname declarations from
runtime/internal/lib/runtime/runtime.go to runtime/internal/lib/hash/maphash/maphash.go
to avoid polluting the runtime package namespace.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 08:01:10 +00:00
xgopilot
8aadfde64a style: apply linter fixes to maphash test
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-14 07:11:42 +00:00
xgopilot
441b4b15a8 test: add hash/maphash demo test case
Add test case in _demo/go/maphash to verify hash/maphash functionality
with the new runtime.rand and runtime.memhash support.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-14 07:11:17 +00:00
xgopilot
cf6cc937ef fix: add runtime.rand and runtime.memhash for hash/maphash support
- Register hash/maphash in hasAltPkg map in runtime/build.go
- Add rand() function that bridges to fastrand64() in runtime overlay
- Add memhash() function that bridges to internal memhash() in runtime overlay
- Fixes issue where hash/maphash package failed with undefined symbols

Fixes #1338

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-14 07:04:42 +00:00
xgopilot
391e09a407 docs: migrate all build commands to Common Development Tasks
- Add 'Build llgo command specifically' and 'Check llgo version' commands
- Consolidate all build-related commands in one section
- Reduce redundancy by having single section for development tasks

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 08:07:23 +00:00
xgopilot
d6f45c67fb docs: merge Testing and Validation into single section
- Move Build Commands into Common Development Tasks section
- Remove duplicate Validation Workflow section
- Simplify document structure by consolidating build commands

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 08:05:56 +00:00
xgopilot
62198a59ba docs: add descriptive instructions to Code Quality section
- Add requirement to run formatting before submitting code updates
- Emphasize that go fmt must be run before committing changes
- Clarify that formatting ensures consistent code formatting

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 07:53:12 +00:00
xgopilot
00d5aad528 docs: remove duplicate validation section from CLAUDE.md
- Remove 'Validated Commands and Expected Outputs' section (lines 71-95)
- This information is already covered in 'Validation Workflow' section
- Reduces redundancy and improves document clarity

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 07:45:24 +00:00
xgopilot
72602d606d docs: address review feedback on CLAUDE.md
- Move demo examples to Project Structure with simplified descriptions
- Change 'Test a simple example' to focus on writing and running test cases
- Remove standalone Running Examples section to reduce redundancy

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 07:36:11 +00:00
xgopilot
a99f3d9409 docs: refactor Important Notes with clear workflow and requirements
- Add clear 'Validation Workflow' section with numbered steps
- Create prominent 'LLGO_ROOT Environment Variable' section
- Add requirement: All bug fixes/features MUST include tests
- Reorganize Important Notes for better clarity

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 07:16:39 +00:00
xgopilot
1edd4b863e docs: merge Testing and Validation into single section
- Combines Testing and Validation sections for better organization
- Emphasizes these steps are essential when fixing bugs or implementing features
- Maintains all validation information with clearer structure

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 06:52:02 +00:00
xgopilot
c7e3408782 docs: simplify CLAUDE.md per review feedback
- Link Development Environment section to README to avoid redundancy
- Remove 'Verified Environment' subsection
- Remove 'Build pydump' section as not needed for current doc

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 06:39:52 +00:00
xgopilot
f65072d997 docs: address review feedback on CLAUDE.md
- Update _cmptest/ description to clarify its purpose
- Remove scattered 'Verified output' sections
- Consolidate all validation information into unified Validation section

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-13 06:16:41 +00:00
xgopilot
cadafde540 Merge pull request #1333 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.19.3
chore(deps): bump github.com/goplus/gogen from 1.19.2 to 1.19.3
2025-10-13 04:40:16 +00:00
xushiwei
7e1abf1486 Merge pull request #1333 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.19.3
chore(deps): bump github.com/goplus/gogen from 1.19.2 to 1.19.3
2025-10-12 09:42:42 +08:00
dependabot[bot]
cf55925ff5 chore(deps): bump github.com/goplus/gogen from 1.19.2 to 1.19.3
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.19.2 to 1.19.3.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.19.2...v1.19.3)

---
updated-dependencies:
- dependency-name: github.com/goplus/gogen
  dependency-version: 1.19.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-10 00:12:17 +00:00
xushiwei
dba7bd498f Merge pull request #1325 from luoliwoshang/ci/rmllvm
ci/gorelease:remove reduant llvm download
2025-09-27 06:15:03 +08:00
luoliwoshang
8ce0574b9e Merge remote-tracking branch 'upstream/main' into ci/rmllvm 2025-09-26 17:07:10 +08:00
luoliwoshang
dd4cf69e25 Merge remote-tracking branch 'upstream/main' into ci/rmllvm 2025-09-26 17:01:47 +08:00
xushiwei
1ee4da9851 Merge pull request #1320 from aofei/ci
chore(ci): migrate from `macos-13` to `macos-15-intel` runner
2025-09-26 16:57:46 +08:00
xushiwei
9e1b321ce6 Merge pull request #1308 from visualfc/cabi_riscv
internal/cabi: support risc-v specific target-abi
2025-09-26 16:30:43 +08:00
xushiwei
b52caefebd Merge pull request #1327 from visualfc/fixabi
ssa: fix abiTupleOf
2025-09-26 16:26:24 +08:00
xushiwei
0c63138ccd Merge pull request #1328 from visualfc/reflect
runtime/internal/lib/reflect: fix Field closure kind to func
2025-09-26 16:25:08 +08:00
xushiwei
f40da557af Merge pull request #1323 from visualfc/big
runtime: math/big use math_big_pure_go
2025-09-26 16:20:31 +08:00
xushiwei
0e28ac7ce4 Merge pull request #1329 from luoliwoshang/ci/link-python
ci:fix brew python & update macos-13 -> macos-15
2025-09-26 16:14:12 +08:00
luoliwoshang
4a6331c668 ci:rm unuse llvm download tool 2025-09-26 15:07:01 +08:00
luoliwoshang
036bb858e2 ci:link --overwrite python 2025-09-26 11:58:17 +08:00
luoliwoshang
5e86d1aee2 ci:fix brew python & update macos-13 -> macos-15 2025-09-26 11:29:20 +08:00
xushiwei
c4223df087 Merge pull request #1301 from luoliwoshang/xtensa/o0
llgo/embed:compile with `Oz`  & link with `-s` for embed target to reduce size
2025-09-26 11:13:22 +08:00
luoliwoshang
4cff9bb0a7 ci:release-build use macos-15-intel instead macos-13 https://github.com/goplus/llgo/pull/1320 2025-09-26 10:51:07 +08:00
visualfc
ccaf59ec62 runtime/internal/lib/reflect: fix Field closure kind to func 2025-09-26 10:27:56 +08:00
luoliwoshang
087696e31b ci:rm zlib link 2025-09-26 10:23:32 +08:00
visualfc
5592a8fc26 ssa: fix abiTupleOf 2025-09-25 20:16:44 +08:00