Updated the out.ll update workflow to document both tools:
- gentests: batch regeneration of all test files (recommended)
- llgen: individual test directory regeneration (for inspection)
Verified gentests works correctly by testing the regeneration
of all out.ll files. The tool successfully processes all
non-Python test directories.
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
Add comprehensive documentation explaining:
- What out.ll files are (IR comparison test files)
- When to update them (after modifying IR generation logic)
- How to update them (reinstall llgen, regenerate files)
- Why this matters (test consistency and regression detection)
This documentation will help avoid wasting time on repeatedly updating
test files, as it clarifies the required workflow when making compiler
changes that affect IR generation.
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
- Moved test from _cmptest/reflect_indirect/ to _demo/go/reflect-indirect/
- Refactored to use panic() for validation instead of fmt.Println
- Added proper assertions for all test cases
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Implements reflect.Indirect function to support pointer dereferencing.
This function returns the value that a pointer points to, or returns
the value unchanged if it's not a pointer.
Fixes#1354
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
The CompareString in the llgo:skip directive is redundant because
the overlay mechanism automatically handles symbol skipping when
an overlay package defines a symbol.
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Use go:linkname to access build.Default and modify Compiler in init function.
This is much simpler than patching defaultContext() and all its dependencies.
- Reduced from 137 lines to 27 lines
- Removed zcgo.go (no longer needed)
- Removed complex parseGoVersion, defaultContext, and helper functions
- Now just sets build.Default.Compiler = "gc" in init()
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Enhanced the demo test to cover comprehensive import scenarios:
- Test 1: build.Default context with GOOS/GOARCH validation
- Test 2: Standard library package import (fmt)
- Test 3: Nested standard library package (os/exec)
- Test 4: Internal package import (internal/cpu)
- Test 5: Runtime package with Dir validation
- Test 6: ImportDir with current directory
- Test 7: IsLocalImport with multiple path formats
- Test 8: Context GOPATH/GOROOT validation
- Test 9: Import with AllowBinary flag
- Test 10: Release tags validation
All tests include proper result validation to ensure go/build
patches work correctly across different use cases.
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Enhanced the demo test to cover more go/build functionality:
- build.Import (existing)
- build.ImportDir (new)
- build.IsLocalImport (new)
- build.Default context verification (existing, improved)
This ensures the go/build patches work correctly across different
public functions, not just Import.
Also ran go fmt to fix formatting issues reported by CI.
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
- Created zcgo.go with defaultCGO_ENABLED constant (Go 1.24 pattern)
- Updated parseGoVersion to panic on unexpected input instead of fallback
- Added runtime.(*Func).Name stub to symtab.go for Go 1.21/1.22 compatibility
- Removed go1.23 build constraint from demo
- Removed internal/buildcfg package (replaced by zcgo.go)
These changes ensure the demo works across Go 1.21+ versions.
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
- Created internal/buildcfg package with DefaultCGO_ENABLED constant
- Updated CGO_ENABLED handling to use buildcfg.DefaultCGO_ENABLED
- Added original Go stdlib comment for release tags
- Simplified toolTags usage by using it directly instead of wrapper function
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
- Link internal/buildcfg.ToolTags variable instead of hardcoding tool tags
- Add comprehensive test cases in demo.go to verify:
- build.Default.Compiler is correctly patched to "gc"
- ToolTags are properly populated from internal/buildcfg
- ReleaseTags are correctly generated
- Validates the go/build patches work as expected
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove /llgo from .gitignore (unnecessary)
- Move cgoSupported linkname to top with other linknames
- Fix goVersion initialization timing by making it local variable
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add linkname directives and stdlib comments for defaultToolTags and
defaultReleaseTags variables to match Go standard library pattern. This
allows external packages (like gopherjs) to access these internal variables
via linkname, maintaining compatibility with packages that depend on this
behavior.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Instead of creating a custom platform package, use the go:linkname
directive to directly link to Go's standard library internal/platform.CgoSupported
function. This approach:
- Eliminates the need to maintain a copy of platform support data
- Uses Go's canonical platform information directly
- Reduces code duplication and maintenance burden
- Follows Go's linkname pattern for accessing internal packages
Changes:
- Added import _ "unsafe" to enable linkname
- Added //go:linkname directive for cgoSupported function
- Removed custom runtime/internal/lib/internal/platform package
- Updated function call from platform.CgoSupported to cgoSupported
🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
Update README to reflect that hash/maphash package has been mostly
implemented and verified by adding it to the Go packages support
section with "(partially)" status.
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
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>
- 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>
- 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>
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>