Compare commits

..

915 Commits

Author SHA1 Message Date
xgopilot
022ba1c067 refactor(runtime): combine two if cases in methods() function
Simplified the methods() function in z_face.go by combining two
if statements that both return u.Methods() into a single condition
using logical OR operator.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-31 02:28:17 +00:00
xgopilot
a3a7876d16 chore: regenerate out.ll files with updated llgen
Regenerated all out.ll files after reinstalling llgen to fix TestFromTestrt and TestFromTestgo test failures.

Updated files:
- cl/_testgo/equal/out.ll
- cl/_testrt/asmfull/out.ll
- cl/_testrt/makemap/out.ll
- cl/_testrt/tpmap/out.ll

The changes correctly update interface PkgPath from specific package paths to empty strings (zeroinitializer) for interfaces with only exported methods, which aligns with the fix in PR #1380 for issue #1370.

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 09:49:51 +00:00
xgopilot
eb0fa2e107 fix(ssa): revert unnecessary formatting changes
Reverted two unnecessary formatting changes based on code review:
- ssa/interface.go: Restored single-line format for val function
- ssa/abitype.go: Moved pkg variable declaration back to original position

These changes don't affect functionality, just code formatting.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 08:06:40 +00:00
xgopilot
210d8858d5 chore: regenerate out.ll files with llgen after interface changes
Regenerated all out.ll test files using llgen after the interface
metadata changes. The updated files now reflect:
- Anonymous interfaces use empty PkgPath (zeroinitializer)
- Anonymous interface types have unique identifiers
- Runtime correctly handles empty PkgPath for method visibility

Files regenerated:
- cl/_testgo/errors/out.ll
- cl/_testgo/ifaceconv/out.ll
- cl/_testgo/ifaceprom/out.ll
- cl/_testgo/interface/out.ll
- cl/_testgo/interface1370/out.ll
- cl/_testgo/invoke/out.ll
- cl/_testgo/reader/out.ll
- cl/_testgo/reflect/out.ll
- cl/_testgo/tpinst/out.ll
- cl/_testrt/tpabi/out.ll
- cl/_testrt/tpmethod/out.ll
- cl/_testrt/vamethod/out.ll

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 07:53:06 +00:00
xgopilot
79bf753c0e fix(ssa): use empty PkgPath for anonymous interfaces
Based on meeting discussion, this commit reverts the previous approach
of extracting PkgPath from interface methods. Instead, anonymous
interfaces now use an empty PkgPath string, and the runtime's methods()
function handles empty PkgPath by returning all methods.

Changes:
- Reverted unsafeInterface() to remove originType parameter
- Set anonymous interface PkgPath to empty string in abitype.go:202
- Added early return in methods() in z_face.go for empty PkgPath
- All call sites of unsafeInterface() updated to pass rawIntf directly

This approach is cleaner because anonymous interfaces don't belong to
any package, and the compiler already guarantees safety for cross-package
private method access.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 07:33:20 +00:00
xgopilot
88d32c9930 fix(ssa): correct PkgPath for interface metadata in cross-package conversions
Fixes #1370 - Segmentation Fault When Calling Interface Private Methods Cross-Package

This commit fixes a critical bug where interface metadata's PkgPath was incorrectly
set when converting concrete type pointers to interfaces with private methods across
package boundaries.

Problem:
- When a concrete type pointer was converted to an interface with private methods
  in a package different from the interface definition package, the compiler
  incorrectly set the interface metadata's PkgPath to the current compilation
  package instead of the interface definition package
- This caused the runtime to only fill exported methods in the itab, leaving
  private method slots as NULL (0x0), resulting in segmentation faults

Solution:
- Modified abiInterfaceOf() in ssa/abitype.go to extract the package path from
  the interface's private methods (if any)
- Use that package path instead of the current compilation package path
- Fall back to current package path only if all methods are exported

Changes:
- ssa/abitype.go: Use abi.PathOf() to get correct package path
- ssa/interface.go: Refactor to simplify interface type handling
- Added comprehensive test cases and demos for go/types, go/token, and go/ast
- Updated all test outputs to reflect correct interface metadata generation

This fix resolves segmentation faults when using Go standard library interfaces
and user-defined interfaces with private methods across package boundaries.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 06:24:23 +00:00
xushiwei
d2a22252c2 Merge pull request #1342 from goplus/dependabot/github_actions/actions/setup-node-6
chore(deps): bump actions/setup-node from 5 to 6
2025-10-16 08:49:12 +08:00
xushiwei
58352e3ee4 Merge pull request #1345 from goplus/xgopilot/claude/issue-1344-1760494923
docs: add hash/maphash to README with partial support status
2025-10-16 08:48:02 +08:00
xushiwei
325e9a93b5 Merge pull request #1347 from cpunion/feature/tls-gc
tls: add gc-aware pthread slots
2025-10-16 08:10:53 +08:00
Li Jie
00dd09c7f4 ssa: improve hasTypeParam coverage 2025-10-15 13:51:16 +08:00
Li Jie
1ed418e77e tls: document package and guard helpers 2025-10-15 13:11:35 +08:00
Li Jie
2110db7263 tls: add gc-aware pthread slots 2025-10-15 12:21:51 +08:00
xgopilot
27efaa2eda docs: add hash/maphash to README with partial support status
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>
2025-10-15 02:23:46 +00:00
dependabot[bot]
355ff1009d chore(deps): bump actions/setup-node from 5 to 6
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-15 00:13:38 +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
luoliwoshang
dc587f684d ci:restore yml 2025-09-25 18:22:21 +08:00
luoliwoshang
5e6501642d release:instal zlib 2025-09-25 17:35:02 +08:00
luoliwoshang
5f3c1e2de3 gorelease:/usr/lib/arch -> /lib/arch 2025-09-25 17:21:37 +08:00
luoliwoshang
215bba2472 gorelease:search /usr/lib/arch 2025-09-25 17:02:14 +08:00
luoliwoshang
bcadacdf21 gorelease:target triple 2025-09-25 16:55:00 +08:00
luoliwoshang
c24506b7e9 ci:reset sysroot set 2025-09-25 16:05:20 +08:00
luoliwoshang
1811ca1220 ci:-z 2025-09-25 15:51:14 +08:00
luoliwoshang
f34ccc1b0c ci:zlib 2025-09-25 15:36:52 +08:00
luoliwoshang
7180f20366 ci:build-essential 2025-09-25 15:24:21 +08:00
luoliwoshang
bb8e81fb9b ci:rm linux llvm download 2025-09-25 15:02:00 +08:00
luoliwoshang
21e7d62c7d ci:rm unuse shell decl 2025-09-25 14:46:00 +08:00
luoliwoshang
35e9ffe31e ci:remove macos llvm download when release 2025-09-25 14:37:29 +08:00
visualfc
62d0ee39de runtime: math/big use math_big_pure_go 2025-09-24 10:32:57 +08:00
Aofei Sheng
79f404ac88 chore(ci): migrate from macos-13 to macos-15-intel runner
GitHub announced the deprecation of the `macos-13` runner image[^1],
which will be completely removed by December 4th, 2025.

This commit migrates all workflows to use `macos-15-intel` runners
following the announcement's recommendation.

This also uses `ubuntu-latest` alias instead of explicit `ubuntu-24.04`.

[^1]: https://github.blog/changelog/2025-09-19-github-actions-macos-13-runner-image-is-closing-down/

Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
2025-09-22 10:01:20 +08:00
xushiwei
8959c83397 Merge pull request #1302 from MeteorsLiu/move-embdemo
chore: move _embdemo to _demo
2025-09-21 11:36:38 +08:00
xushiwei
67a3cb2e7e Merge pull request #1314 from luoliwoshang/internal/build/genll
fix:GenLL flag to correct compile
2025-09-21 11:35:19 +08:00
xushiwei
1195ce9b03 Merge pull request #1318 from visualfc/tpunsafe
ssa: impl builtin alignof offsetof
2025-09-21 11:32:52 +08:00
visualfc
7323187f90 ssa: impl builtin alignof offsetof 2025-09-18 21:16:06 +08:00
luoliwoshang
bbcbddfcad internal/crosscompile:ld -S to ensure emit-reloc correct 2025-09-18 15:45:25 +08:00
luoliwoshang
8fa3819714 internal/crosscompile:ld -s for embed target 2025-09-18 15:22:02 +08:00
luoliwoshang
c562f05b51 fix:GenLL correct compile 2025-09-17 14:17:17 +08:00
luoliwoshang
cc5c1144a7 internal/crosscompile:Oz optimize level for embed target 2025-09-16 16:40:45 +08:00
visualfc
db28648d29 internal/cabi: support riscv64/riscv32 target-abi 2025-09-16 12:42:30 +08:00
Haolan
03e617d902 chore: remove _embdemo 2025-09-15 14:44:55 +08:00
Haolan
e84f859d6c fix: unexpected string 2025-09-15 11:04:30 +08:00
Haolan
4b2e1e777c chore: move _embdemo to _demo 2025-09-15 10:57:31 +08:00
xushiwei
18e036568d Merge pull request #1299 from MeteorsLiu/fix-export-check-ci
ci: fix clite init() causing linting failure
2025-09-15 09:17:15 +08:00
Haolan
e4f77f00a6 ci: fix clite init() causing linting failure 2025-09-14 23:06:09 +08:00
visualfc
8bfe133bee internal/cabi: support target esp32c3 2025-09-14 20:50:13 +08:00
xushiwei
897f944760 Merge pull request #1296 from visualfc/cabi_esp32
internal/cabi: support target esp32
2025-09-14 10:32:20 +08:00
xushiwei
a202b484a9 Merge pull request #1285 from cpunion/impl-build-mode
Implement llgo build mode support
2025-09-14 10:30:47 +08:00
xushiwei
17dfdd38c2 Merge pull request #1283 from cpunion/reorganize-demos
reorganize: consolidate demo directories
2025-09-14 10:26:45 +08:00
xushiwei
30a3e73d4f Merge pull request #1268 from MeteorsLiu/emb-runtime
fix(runtime): go runtime when building in baremetal environment
2025-09-14 10:26:02 +08:00
visualfc
6170c1dcb9 internal/cabi: support target esp32 2025-09-12 11:16:25 +08:00
Li Jie
cc65ee18b5 full test params passing of exported functions 2025-09-12 10:08:01 +08:00
Li Jie
50d1d2e19a remove duplicated return 2025-09-11 15:02:45 +08:00
Li Jie
c3b674d804 add export demo and test 2025-09-11 14:08:52 +08:00
Li Jie
3605eeeef7 export c header file for build library 2025-09-11 14:07:58 +08:00
Li Jie
729e5772a0 process //export with initLink 2025-09-11 08:53:17 +08:00
Li Jie
a2742a9de4 set buildmode to exe for non-build mode 2025-09-11 08:53:17 +08:00
Li Jie
68947bfc1f Fix library mode linking by optimizing genMainModuleFile
- For library modes (c-archive, c-shared), only generate minimal code with __llgo_argc/__llgo_argv globals
- For executable mode, generate full main function with runtime initialization
- This fixes undefined symbol errors when linking libraries that reference these globals
2025-09-11 08:53:17 +08:00
Li Jie
e05c8b9f46 Implement llgo build mode support (#1197)
- Add BuildMode type with three build modes: exe, c-archive, c-shared
- Restrict buildmode flag to llgo build command only (not run/install/test)
- Implement build mode specific linker arguments:
  - c-shared: use -shared -fPIC flags
  - c-archive: use ar tool to create static archive
  - exe: default executable mode
- Add normalizeOutputPath function for platform-specific file naming conventions
- Generate C header files for library modes
- Fix buildmode flag conflict by removing from PassArgs
- Add comprehensive test coverage for all build modes
- Resolve duplicate logic between defaultAppExt and normalizeOutputPath

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 08:53:17 +08:00
Haolan
dc59333657 test: remove chinses commets 2025-09-10 17:05:38 +08:00
Haolan
c50395b2b9 test: add esp32 libc and rt test 2025-09-10 17:03:05 +08:00
Haolan
a1d7417684 chore: remove unused file 2025-09-10 14:15:22 +08:00
Haolan
0bbdb6c204 fix: change clite's LLGoPackage to true to execute its init() 2025-09-10 14:14:22 +08:00
Haolan
0ed3a54244 Merge branch 'main' of https://github.com/goplus/llgo into emb-runtime 2025-09-10 14:06:06 +08:00
xushiwei
d5ad4d997d Merge pull request #1272 from visualfc/cabi_opt
internal/cabi: call optimization
2025-09-10 13:49:48 +08:00
Haolan
3cc8fd1c91 Merge branch 'main' of https://github.com/goplus/llgo into emb-runtime 2025-09-10 13:49:19 +08:00
xushiwei
d0962d8adc Merge pull request #1264 from MeteorsLiu/libc-version
Fix xtensa newlib `stdio` stuck and support libc version
2025-09-10 13:46:36 +08:00
xushiwei
d7b9968d9a Merge pull request #1253 from luoliwoshang/release/esp-clang
release:compile & release with esp clang/llvm
2025-09-10 13:40:12 +08:00
xushiwei
b72311cd6d Merge pull request #1275 from luoliwoshang/update/clang
internal/crosscompile:update clang with older glibc & more small size
2025-09-10 13:38:00 +08:00
Haolan
073e79d03b chore: rename ArchiveSrcDir 2025-09-10 11:47:02 +08:00
visualfc
dd50d4dff0 internal/cabi: option optimize 2025-09-09 21:10:53 +08:00
visualfc
b6d43ae88a internal/cabi: transformFuncBody check AttrWidthType(2) 2025-09-09 21:04:24 +08:00
visualfc
89e93f9e7a internal/cabi: transformCallInstr check AttrPointer 2025-09-09 21:04:24 +08:00
visualfc
0b6a558667 internal/cbi: replaceParamAlloc 2025-09-09 21:04:24 +08:00
visualfc
937f8339c7 internal/cabi: call optimization 2025-09-09 21:04:24 +08:00
luoliwoshang
a17f1f0bb0 set origin test
avoid  transform
2025-09-09 19:05:26 +08:00
Haolan
8ce6c3b9ab chore: fix commets and format
Update internal/crosscompile/compile/rtlib/rt_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

Update internal/crosscompile/compile/libc/libc_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

Update internal/crosscompile/compile/libc/libc_test.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

chore: format contents
2025-09-09 18:23:31 +08:00
Haolan
d4474be921 chore: fix some wrong commets 2025-09-09 18:23:31 +08:00
Haolan
6aa63121ff chore: upgrade newlib 2025-09-09 18:23:31 +08:00
Haolan
b239494a9f test: add test for getting config 2025-09-09 18:23:31 +08:00
Haolan
f573ebe40b fix: xtensa stdio 2025-09-09 18:23:31 +08:00
Haolan
95bd495d7b feat: support libc version 2025-09-09 18:23:31 +08:00
xushiwei
b1d95bb73c Merge pull request #1284 from visualfc/valist_demo
cl/_testrt/vamethod: optimize code
2025-09-09 17:29:38 +08:00
visualfc
5dbf1a7561 cl/_testrt/vamethod: optimize code 2025-09-09 17:25:22 +08:00
xushiwei
0dbc686960 Merge pull request #1281 from goplus/dependabot/github_actions/actions/setup-go-6
build(deps): bump actions/setup-go from 5 to 6
2025-09-09 17:19:39 +08:00
xushiwei
4e7526d68e Merge pull request #1282 from visualfc/embed_vamethod
cl: embed struct / interface support __llgo_va_list
2025-09-09 17:19:16 +08:00
visualfc
fd17a43ade cl: interface support __llgo_va_list 2025-09-09 16:51:08 +08:00
visualfc
89af430329 cl: embed struct support __llgo_va_list 2025-09-09 16:14:25 +08:00
Li Jie
64df39b3c5 reorganize: consolidate demo directories
- Consolidate _demo, _pydemo, _embdemo into single _demo directory structure
- Organize demos by language: _demo/{go,py,c,embed}/
- Categorize demos based on imports:
- Python library demos (py imports) → _demo/py/
- C/C++ library demos (c/cpp imports) → _demo/c/
- Go-specific demos → _demo/go/
- Embedded demos → _demo/embed/
- Move C-related demos (asm*, cabi*, cgo*, linkname, targetsbuild) from go/ to c/
- Update all path references in README.md and GitHub workflows
- Improve demo organization and navigation as requested in #1256

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 15:06:55 +08:00
luoliwoshang
e63ebb8151 goreleaser:avoid fail 2025-09-09 15:05:52 +08:00
luoliwoshang
7907e69719 Merge remote-tracking branch 'upstream/main' into release/esp-clang 2025-09-09 14:26:42 +08:00
xushiwei
849b23079b Merge pull request #1279 from luoliwoshang/ci/refreshCacheKey
ci:update .sysroot cache key & catch docker exit
2025-09-09 14:12:48 +08:00
luoliwoshang
3be12dce44 ci:test helloword with embed target 2025-09-09 13:44:56 +08:00
luoliwoshang
f66bbb7fc3 execute rpath search 2025-09-09 12:52:26 +08:00
luoliwoshang
9f48753203 allow sysroot 2025-09-09 12:34:36 +08:00
luoliwoshang
e05f890b94 temp remove origin rpath set 2025-09-09 12:25:39 +08:00
luoliwoshang
d0cf57fa95 ci:test release without llvm dependency 2025-09-09 12:10:14 +08:00
luoliwoshang
92beb562bf goreleaser:relative rpath 2025-09-09 11:57:38 +08:00
luoliwoshang
6ce28e4d4e goreleaser:keep file level 2025-09-09 11:36:29 +08:00
luoliwoshang
0340ef2a75 goreleaser:move clang to result 2025-09-09 11:06:55 +08:00
luoliwoshang
68623f0b27 env:find crosscompile llvm 2025-09-09 10:22:43 +08:00
luoliwoshang
13b5f39125 ci:fail when docker start error 2025-09-09 09:52:22 +08:00
dependabot[bot]
2a022be510 build(deps): bump actions/setup-go from 5 to 6
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-09 00:44:54 +00:00
luoliwoshang
848432ea68 ci:sysroot for linux 2025-09-08 22:53:39 +08:00
luoliwoshang
a19011897c install with esp-clang & new cache key 2025-09-08 22:52:51 +08:00
luoliwoshang
9cea3226db ci:fail when docker start error 2025-09-08 19:07:12 +08:00
luoliwoshang
bb89ef5c5d ci:refresh ci .sysroot cache key 2025-09-08 17:44:46 +08:00
Haolan
b39f0aa4bf Merge branch 'main' of https://github.com/goplus/llgo into emb-runtime 2025-09-08 16:03:52 +08:00
xushiwei
1556b29e0a Merge pull request #1271 from cpunion/embed-cmds
Embed cmds
2025-09-08 16:00:08 +08:00
Li Jie
d46a3f2f49 Merge commit '7de4137d4678a3bcbd735f887028489f97f1e479' into embed-cmds
# Conflicts:
#	internal/build/build.go
2025-09-08 15:22:48 +08:00
xushiwei
7de4137d46 Merge pull request #1261 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.19.2
build(deps): bump github.com/goplus/gogen from 1.19.1 to 1.19.2
2025-09-08 14:43:53 +08:00
xushiwei
16b3473f52 Merge pull request #1274 from luoliwoshang/fix/ldl
fix:ldflags -ldl for earlier glibc version
2025-09-08 14:43:15 +08:00
xushiwei
1f7883654a Merge pull request #1269 from luoliwoshang/ci/dependbot
ci:avoid dependbot trigger reduant push event
2025-09-08 14:42:30 +08:00
xushiwei
fb94329c87 Merge pull request #1259 from luoliwoshang/test/refine
CI: Release Testing
2025-09-08 14:40:20 +08:00
xushiwei
2f3c322076 Merge pull request #1233 from cpunion/optional-esp-clang
Optional esp clang
2025-09-08 14:38:25 +08:00
luoliwoshang
922d174402 fix yml conflict 2025-09-08 14:33:40 +08:00
Haolan
d9a20e8000 fix: stdio and typo 2025-09-08 14:13:25 +08:00
luoliwoshang
d2a021ceae test:with esp-clang version 2025-09-08 10:02:27 +08:00
luoliwoshang
66bf801fd6 internal/crosscompile:update clang with older glibc & more same size 2025-09-08 09:40:43 +08:00
Li Jie
20ce823b68 fix: targets tests 2025-09-07 16:37:42 +08:00
Li Jie
3ecf9b35f3 refine: safe shell cmd line parse 2025-09-07 16:37:38 +08:00
Li Jie
dba719a8d7 doc: update embeded doc of llgo cmds 2025-09-07 16:37:38 +08:00
Li Jie
806b16c2c8 refine: reduce duplicated env expand funcs 2025-09-07 16:37:38 +08:00
Li Jie
9eeb14ae31 feat: support generic bin and intel hex firmware 2025-09-07 16:37:37 +08:00
Li Jie
df07513a37 refine: reduce unnecessary format conversion 2025-09-07 16:37:34 +08:00
Li Jie
16c8402065 refactor: multi format generation and llgo build flags 2025-09-07 16:23:31 +08:00
Li Jie
c0afe199c2 refactor: move device types definition into flash 2025-09-07 16:23:31 +08:00
Li Jie
1c2aea10f0 feat: add Arduino 1200bps reset support before flashing
- Add touchSerialPortAt1200bps function from TinyGo for Arduino bootloader reset
- Update Flash function to trigger 1200bps reset when flash-1200-bps-reset is true
- Add 2-second wait after reset for device to enter bootloader mode
- Support retry mechanism with Windows-specific error handling

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-07 16:23:31 +08:00
Li Jie
4e590d42be feat: auto guess port for monitoring 2025-09-07 16:23:30 +08:00
Li Jie
228d7cee31 feat: make -port optional 2025-09-07 16:23:30 +08:00
Li Jie
c6676917b3 refine: check msd paths 2025-09-07 16:23:30 +08:00
Li Jie
88e0844ada ignore codecov from internal/{monitor,flash} 2025-09-07 16:23:30 +08:00
Li Jie
a2c9c7f10a feat: llgo run -target target -port port auto start monitor 2025-09-07 16:23:30 +08:00
Li Jie
9a5b231c88 feat: llgo monitor -target target -port port 2025-09-07 16:23:27 +08:00
Li Jie
519faabfe1 feat: ignore firmware files 2025-09-06 20:54:39 +08:00
Li Jie
1a3bca40bc feat: implement flash functionality 2025-09-06 20:53:28 +08:00
Li Jie
549beeb101 test output format for all target/emuator/flash-method 2025-09-06 19:46:33 +08:00
Li Jie
7cad146013 refactor build/install/run pipeline 2025-09-06 19:45:48 +08:00
luoliwoshang
054591c279 fix:ldflags -ldl for earlier glibc version 2025-09-06 18:56:58 +08:00
Li Jie
da9865104f export flash, openocd, msd 2025-09-06 16:21:15 +08:00
Li Jie
1033452e8f extract run from linkMainPkg, add flash scaffold 2025-09-06 16:16:04 +08:00
luoliwoshang
82ed8468e7 ci:avoid dependbot trigger reduant push event 2025-09-06 10:57:16 +08:00
Li Jie
5e5d5c2a83 Build and run for embeded 2025-09-06 10:35:58 +08:00
Li Jie
df8f67db5a remove debug log 2025-09-06 10:35:58 +08:00
Li Jie
e9170e4cef feat: add -file-format flag for flexible output formats
Add support for -file-format flag to llgo build command allowing users to specify output format independently of target configuration.

Changes:
- Add -file-format flag supporting bin, hex, elf, uf2, zip formats
- Implement two-stage conversion: firmware format → file format
- Add ConvertOutput function with hex format conversion support
- Update build logic to handle different modes (build vs run/install)
- Add verbose logging for conversion operations

For build command: only convert firmware when -file-format is specified
For run/install commands: always convert firmware when target requires it

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 10:35:58 +08:00
xushiwei
f41badde20 Merge pull request #1266 from goplus/dependabot/github_actions/actions/setup-node-5
build(deps): bump actions/setup-node from 4 to 5
2025-09-06 10:14:00 +08:00
xushiwei
ac753070fa Merge pull request #1267 from goplus/dependabot/github_actions/actions/setup-go-6
build(deps): bump actions/setup-go from 5 to 6
2025-09-06 10:13:02 +08:00
xushiwei
e6768584d7 Merge pull request #1263 from luoliwoshang/ci/cancel-before
ci:concurrency config added & timeout at 30min
2025-09-06 10:12:21 +08:00
Haolan
7ca8abc788 fix: println 2025-09-05 19:00:53 +08:00
Haolan
e444c4b6ac fix: typo 2025-09-05 16:55:38 +08:00
Haolan
0d02a7273e fix: rethrow in baremental 2025-09-05 16:41:58 +08:00
Haolan
0c418073b3 revert unix 2025-09-05 16:29:58 +08:00
Haolan
2d1120bf69 fix: symbol not found when building in baremental environment 2025-09-05 16:27:38 +08:00
luoliwoshang
22c26c1aaa ci:every job settimeout 30min 2025-09-05 11:26:29 +08:00
dependabot[bot]
c97d541936 build(deps): bump actions/setup-go from 5 to 6
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 00:11:41 +00:00
dependabot[bot]
f6bb1d9922 build(deps): bump actions/setup-node from 4 to 5
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 5.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 00:11:37 +00:00
luoliwoshang
7ae6686f6b ci:concurrency config added 2025-09-04 19:09:30 +08:00
luoliwoshang
5a602830a6 ci(release test):restore other ci 2025-09-04 17:36:36 +08:00
luoliwoshang
00dbc91745 ci(release test):cache with sh & gh yml 2025-09-04 17:07:55 +08:00
luoliwoshang
1684512308 ci(release test):cache key to env 2025-09-04 16:49:10 +08:00
luoliwoshang
40b142f947 ci(release test):hello check cpp & todo build 2025-09-04 15:36:06 +08:00
luoliwoshang
e5c86fe936 ci(release test):lookup cache 2025-09-04 14:41:46 +08:00
luoliwoshang
9d7664373e ci(release test):setup releaser 2025-09-04 14:32:05 +08:00
luoliwoshang
825f0bd83f ci(release test):cache linux & set qemu 2025-09-04 11:12:55 +08:00
luoliwoshang
bedb454427 ci(release test):cache linux & check file 2025-09-04 10:43:32 +08:00
dependabot[bot]
a9f74b7e55 build(deps): bump github.com/goplus/gogen from 1.19.1 to 1.19.2
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.19.1 to 1.19.2.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.19.1...v1.19.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-03 22:16:23 +00:00
luoliwoshang
002a68009e ci(release test):cache macos 2025-09-03 22:17:31 +08:00
luoliwoshang
23b5e77dcc ci(release test):test cache macos tarball 2025-09-03 21:33:35 +08:00
luoliwoshang
b8b0ae00d0 ci(release test):revert to cache linux 2025-09-03 20:48:16 +08:00
luoliwoshang
b58cce09ab ci(release test):cache with tar -xzvf 2025-09-03 20:20:14 +08:00
luoliwoshang
a1f9afc88f debug 2025-09-03 20:00:14 +08:00
luoliwoshang
6ba182afc7 ci(release test):output sysroot 2025-09-03 19:34:56 +08:00
luoliwoshang
da319e2a7c ci(release test):use cache .sysroot both for test & release 2025-09-03 19:11:37 +08:00
luoliwoshang
5e32a15146 ci(release test):set go dep 2025-09-03 18:21:30 +08:00
luoliwoshang
07d69295b9 ci(release test):test with hello 2025-09-03 18:07:50 +08:00
luoliwoshang
740a260708 ci(release test):with dependency 2025-09-03 17:26:26 +08:00
luoliwoshang
96cd52dccc ci(release test):use macos13 instead macos-latest-large try to resolve action bug 2025-09-03 17:16:05 +08:00
luoliwoshang
8650952145 ci(release test):with macos/arm macos/amd linux/arm linux/amd 2025-09-03 17:06:51 +08:00
luoliwoshang
58e5f5e4a1 release:check upload 2025-09-03 16:32:25 +08:00
luoliwoshang
7c792e8ca6 release:check artifact 2025-09-03 16:08:51 +08:00
luoliwoshang
d3ded9f861 release:cache .sysroot 2025-09-03 16:03:01 +08:00
luoliwoshang
7f05aa54c2 release:upload goreleaser result to artifact & test it 2025-09-03 15:35:13 +08:00
luoliwoshang
77a7d9e549 release:with --snapshot for release test 2025-09-03 15:04:08 +08:00
luoliwoshang
0ff2d5d931 ci:goreleaser file to artifacts & temp move ci for test 2025-09-03 14:19:48 +08:00
Li Jie
62fc21e22b Merge commit '6588f36123eababf6e24564b49e5af374285d2b5' into optional-esp-clang
# Conflicts:
#	internal/crosscompile/crosscompile.go
#	internal/crosscompile/crosscompile_test.go
2025-09-03 09:32:38 +08:00
xushiwei
6588f36123 Merge pull request #1246 from MeteorsLiu/esp-libc
feat: support libc/compiler-rt for small places
2025-09-03 07:05:51 +08:00
Haolan
977806affc test: add more libc test 2025-09-02 22:35:08 +08:00
Haolan
dd3c1f923d test: fix _embdemo write test 2025-09-02 22:25:27 +08:00
Haolan
1bd9ceb444 test: fix _embdemo 2025-09-02 20:06:48 +08:00
Haolan
5a4c83ef85 test: add _embdemo print test 2025-09-02 18:27:59 +08:00
Haolan
82bb6e84d0 test: add rt test 2025-09-02 18:23:28 +08:00
Haolan
b99c073cca test: add test for compile options 2025-09-02 18:04:35 +08:00
Haolan
4b383b179a ci: revert 2025-09-02 17:18:25 +08:00
Haolan
a8bc617e18 test: skip llgo test 2025-09-02 17:16:55 +08:00
xushiwei
656a2a43b5 Merge pull request #1247 from goplus/dependabot/go_modules/github.com/goplus/lib-0.3.0
build(deps): bump github.com/goplus/lib from 0.2.0 to 0.3.0
2025-09-02 15:15:44 +08:00
xushiwei
7e01f69d7e Merge pull request #1255 from cpunion/fix-llgo-root-check
Check LLGO_ROOT with pkg github.com/goplus/llgo/runtime
2025-09-02 15:15:06 +08:00
Haolan
f875347ad9 test: fix compile test
test: add asm test

test: add libc.go test

test: add DownloadAndExtractLibInternalDir test

test: fix checkDownload test

test: fix asm test

fix: check isCompile

fix: remove debug

fix: remove debug
2025-09-02 13:42:23 +08:00
Haolan
1d3ecb287a fix: export libc cflags for compiler-rt
fix: libc include dir

fix: xtensa internal src dir

fix: xtensa internal src dir

fix: ignore wasm target

fix: export libc cflags to global cflags

fix: rtlib libc include dir

fix: ignore some errors for libc

fix: don's search system path for libc

fix: adjust compiling options

ci: add libc

fix: libc cflags

fix: test path

fix: libc cflags

fix: libc cflags
2025-09-02 13:40:42 +08:00
Li Jie
0cac1c8a9d fix #1252 check LLGO_ROOT with pkg github.com/goplus/llgo/runtime 2025-09-01 20:18:31 +08:00
Haolan
cb2fa5dd2d fix: picolibc.h 2025-09-01 17:19:32 +08:00
Haolan
5997a296c2 fix: update url 2025-09-01 16:54:12 +08:00
Haolan
96c5ce90e4 fix: compiler rt file path 2025-09-01 16:36:58 +08:00
Haolan
8ecbfe9ade feat: support arm/risc64/avr for compiler rt 2025-09-01 16:33:19 +08:00
Haolan
012a5d7d69 fix: remove unused file 2025-09-01 14:49:37 +08:00
Haolan
997ea2849b feat: support riscv32 2025-09-01 14:48:54 +08:00
Haolan
1b3889ebc9 feat: add target name design 2025-08-29 19:25:09 +08:00
Haolan
53e22488c8 fix: remove debug compiler options 2025-08-29 17:54:08 +08:00
Haolan
19ddee0241 test: add compile test 2025-08-29 17:48:34 +08:00
Haolan
61143a6ff0 fix: newlib url and rt url 2025-08-29 16:27:23 +08:00
Haolan
3f2fe83718 fix: check needStart by libc name 2025-08-29 16:02:23 +08:00
Haolan
4639ee13e7 feat: support compiler-rt 2025-08-29 11:30:25 +08:00
dependabot[bot]
5810b29372 build(deps): bump github.com/goplus/lib from 0.2.0 to 0.3.0
Bumps [github.com/goplus/lib](https://github.com/goplus/lib) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/goplus/lib/releases)
- [Commits](https://github.com/goplus/lib/compare/v0.2.0...v0.3.0)

---
updated-dependencies:
- dependency-name: github.com/goplus/lib
  dependency-version: 0.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-29 00:12:37 +00:00
Haolan
f3ecce86ee feat: support libc for small devices 2025-08-28 20:11:13 +08:00
xushiwei
2160710884 Merge pull request #1243 from luoliwoshang/llgo/safesplit
xtool/safesplit:properly handle consecutive short flags
2025-08-28 11:50:06 +08:00
xushiwei
71353baf59 Merge pull request #1245 from luoliwoshang/llgo/targetsdir
internal/target:read targets consist use LLGoROOT
2025-08-28 11:48:48 +08:00
xushiwei
6144987f06 Merge pull request #1224 from luoliwoshang/instr/asmfull
cl(feat): llgo.asm implement tinygo.AsmFull
2025-08-28 11:41:31 +08:00
luoliwoshang
b68686e542 internal/target:read targets use LLGoROOT 2025-08-28 11:12:26 +08:00
luoliwoshang
0935d10edf xtool/safesplit:properly handle consecutive short flags 2025-08-27 20:25:31 +08:00
xushiwei
fdc7d53904 Merge pull request #1240 from visualfc/readdir
runtime/internal/lib/os: fix readdir for darwin-amd64
2025-08-27 17:43:41 +08:00
visualfc
69fe6d6377 runtime/internal/lib/os: fix readdir for darwin-amd64 2025-08-26 22:23:30 +08:00
xushiwei
cf2d1ef9ca Merge pull request #1234 from visualfc/rpath
internal/build: fix warning duplicate -rpath
2025-08-26 13:56:44 +08:00
visualfc
ab57a13eb1 internal/build: fix warning duplicate -rpath 2025-08-26 13:54:15 +08:00
Haolan
5587fd2885 feat: add libc 2025-08-25 19:05:30 +08:00
Li Jie
f361d195f0 clean debug log 2025-08-25 10:52:22 +08:00
Li Jie
11e1348a2c add force-espclang to force using esp-clang for dev mode 2025-08-24 17:31:57 +08:00
Li Jie
ca30338066 optional use esp clang for non-cross-compilation 2025-08-24 17:28:42 +08:00
xushiwei
e4218f90d7 Merge pull request #1226 from visualfc/alpine
doc: alpine 386
2025-08-24 08:43:17 +08:00
xushiwei
3bfedb2588 Merge pull request #1228 from visualfc/dev_check
build: dev support checkLinkArgs/CheckLLFiles/GenLLFiles
2025-08-24 08:42:38 +08:00
xushiwei
d87deebbef Merge pull request #1231 from visualfc/cabi_alloca
internal/cabi: fix llvm.alloca for callInsrt
2025-08-24 08:38:02 +08:00
xushiwei
76e4f4ab92 Merge pull request #1203 from cpunion/esp-llvm
Build Target Task 2: Multi-Platform LLVM Support and Bootable Code Generation
2025-08-24 08:36:02 +08:00
Li Jie
ddc61adc63 test compiler downloading of crosscompile 2025-08-23 18:33:20 +08:00
Li Jie
96001ce9b1 disable incompatible tests for llgo test 2025-08-23 18:01:16 +08:00
Li Jie
4a02b1f23b test internal/clang 2025-08-23 17:53:09 +08:00
Li Jie
e40bdc196b binary-format supports uf2, nrf-dfu 2025-08-23 17:45:20 +08:00
Li Jie
508b23a584 refine and test internal/crosscompile 2025-08-23 17:45:20 +08:00
Li Jie
b7181592a9 hide unused arguments warnings 2025-08-23 17:45:20 +08:00
Li Jie
59e1df5478 don't collect test coverage of internal/firmware 2025-08-23 17:42:34 +08:00
Li Jie
ecaf7c8ac6 supports binary-format, only esp* supported for now 2025-08-22 21:05:29 +08:00
visualfc
cd69092a60 internal/cabi: fix llvm.alloca for callInsrt 2025-08-22 19:16:06 +08:00
luoliwoshang
f3de14da4b cl/instr:note for why asm not support pointer type: 2025-08-22 16:14:57 +08:00
luoliwoshang
49b9b92790 ci/instr:fix asmFull return type to match function signature when no output 2025-08-22 15:01:59 +08:00
Li Jie
1f193c8533 refine internal/clang: don't depends internal/crosscompile 2025-08-22 09:08:26 +08:00
Li Jie
3ce63965bf refine build.sh and CI 2025-08-22 08:54:55 +08:00
Li Jie
50d8dbee05 fix targets extra files 2025-08-22 08:43:04 +08:00
Li Jie
c8eb871252 report error if extra file not exist 2025-08-22 08:42:29 +08:00
Li Jie
ad8aa6ac1a add __dynamic_loader into targetsbuild for nintendo switch 2025-08-22 08:42:01 +08:00
Li Jie
d3d39876d3 report llvm-target/cpu empty warning in all targets check 2025-08-22 07:41:59 +08:00
Li Jie
44cb4f2649 report error if target cpu is not set 2025-08-22 07:40:52 +08:00
Li Jie
d0f89e456c allow clang unused parameters 2025-08-22 07:40:18 +08:00
Li Jie
90a16e8c90 add handleInterrupt into _demo/targetsbuild 2025-08-22 07:39:18 +08:00
Li Jie
ea6266c79f add _demo/targetsbuld/build-all.sh to check all targets 2025-08-22 07:09:42 +08:00
Li Jie
077f114373 _demo/empty -> _demo/targetsbuild 2025-08-22 07:09:42 +08:00
Li Jie
2508674227 report target error if llvm-target not set 2025-08-22 07:09:38 +08:00
Li Jie
c9c703dfe6 remove duplicated CCFLSGS args 2025-08-22 06:57:20 +08:00
luoliwoshang
d9dc4d5943 cl/instr:move to one asm 2025-08-21 23:44:46 +08:00
luoliwoshang
04f613dd15 cl/test:asmFull error 2025-08-21 23:44:46 +08:00
luoliwoshang
0faef117ca cl/instr:refine register collect 2025-08-21 23:44:46 +08:00
luoliwoshang
f6bc5ac538 cl/instr:regexp compile one time 2025-08-21 23:44:46 +08:00
luoliwoshang
26fb156d6b cl/instr:only permit interger at asmfull 2025-08-21 23:44:46 +08:00
luoliwoshang
d548671b91 test:linux with leaq to confirm asmFull 2025-08-21 23:44:46 +08:00
luoliwoshang
ef1f2bce49 test:linux asmFull function test 2025-08-21 23:44:46 +08:00
luoliwoshang
b428a8af08 test:asmFull function test 2025-08-21 23:44:46 +08:00
luoliwoshang
9dfc6d1d52 ssa:refine asmFull interface 2025-08-21 23:44:46 +08:00
luoliwoshang
6beb50b367 cl/instr:asmFull test case with multiple input & output 2025-08-21 23:44:46 +08:00
luoliwoshang
9e0c50dafe cl/instr:asmFull test case with input only 2025-08-21 23:44:46 +08:00
luoliwoshang
f5d4f93ed7 ssa:inlineAsmFull 2025-08-21 23:44:46 +08:00
luoliwoshang
ae36ef4a0e cl/instr:replace register & build constraints 2025-08-21 23:44:46 +08:00
luoliwoshang
485dbe4021 cl/instr:asm with two situation 2025-08-21 23:44:46 +08:00
Li Jie
2f8f85a404 filter out failed targets in ci 2025-08-21 22:20:46 +08:00
Li Jie
87c50cf22a _demo/empty exports Reset_Handler and handleHardFault (to compatible with tinygo) 2025-08-21 22:18:14 +08:00
Li Jie
6e20a435af targets supports extra-files 2025-08-21 21:55:42 +08:00
Li Jie
2eb7d542d2 targets supports code-model, target-abi, relocation-model 2025-08-21 20:43:43 +08:00
Li Jie
c414add29f update targets tests 2025-08-21 19:51:20 +08:00
Li Jie
372a09d2ca inspired compiler and linker args from tinygo 2025-08-21 18:53:27 +08:00
Li Jie
06568da140 expand template vars in targets config 2025-08-21 18:51:54 +08:00
visualfc
96c7afcf3a build: dev support checkLinkArgs/CheckLLFiles/GenLLFiles 2025-08-21 17:26:20 +08:00
Li Jie
5cfd996659 fix cross compilation tests 2025-08-21 17:16:29 +08:00
Li Jie
21189f378e fix libunwind include path 2025-08-21 17:16:29 +08:00
Li Jie
9a90eaed76 fix ldflags 2025-08-21 17:16:28 +08:00
Li Jie
d8122d14aa fix lld -target 2025-08-21 17:16:28 +08:00
Li Jie
7bf0146e2f add file lock to avoid parallel downloading 2025-08-21 17:16:25 +08:00
Li Jie
93ca632f7a fix rpath for libc++ 2025-08-21 15:38:56 +08:00
Li Jie
49e5963b0a Merge commit '6de3bdcdd9b3959d244e7b3b7e97fc4e3408cd78' into esp-llvm
# Conflicts:
#	internal/build/build.go
2025-08-21 14:19:53 +08:00
Li Jie
7e8df050a1 fix cross compilation 2025-08-21 14:18:37 +08:00
Li Jie
50a2650e67 upgrade to esp-clang prebuilt 19.1.2_20250820 2025-08-21 14:12:57 +08:00
visualfc
1137749980 doc: alpine 386 2025-08-21 12:14:49 +08:00
xushiwei
6de3bdcdd9 Merge pull request #1223 from visualfc/cpuid
runtime/internal/lib/internal/cpu: use __cpuid_count
2025-08-21 11:45:34 +08:00
xushiwei
7c4fb8d6f1 Merge pull request #1222 from visualfc/dev
llgo flags -abi enable in build tags dev
2025-08-21 11:44:49 +08:00
visualfc
a11a71eb93 llgo flags -abi enable in build tags dev 2025-08-21 11:09:13 +08:00
xushiwei
b8d0a26bdc Merge pull request #1163 from luoliwoshang/internal/build/rpath
internal/build:support relocatable lib
2025-08-21 11:07:13 +08:00
xushiwei
a8432252e1 Merge pull request #1220 from visualfc/cabi
internal/cabi: support arch 386
2025-08-21 10:55:43 +08:00
visualfc
56733e1dbd runtime/internal/lib/internal/cpu: use __cpuid_count 2025-08-20 17:09:02 +08:00
Li Jie
246278ff80 add tinygo device files 2025-08-20 10:27:01 +08:00
Li Jie
1b8b500fd7 add esp-clang download prompts 2025-08-20 10:23:32 +08:00
Li Jie
e8bae52f66 decision _start generation by target, add some fake variables 2025-08-20 08:54:38 +08:00
Li Jie
3431354cb2 refactor clang command 2025-08-20 08:53:36 +08:00
Li Jie
b2b407c2c2 upgrade to prebuilt esp-clang 19.1.2_20250819 2025-08-20 08:53:36 +08:00
luoliwoshang
1d76f515e0 internal/build:support relocatable lib 2025-08-19 22:48:23 +08:00
visualfc
fd0b2ff72d internal/cabi: support arch 386 2025-08-19 15:01:35 +08:00
xushiwei
cbac24cf97 Merge pull request #1188 from visualfc/cabi
cabi transform
2025-08-19 14:56:10 +08:00
xushiwei
ff40a80569 Merge pull request #1211 from luoliwoshang/emb/start
fix: set correct argc=0 in _start() function
2025-08-19 08:33:02 +08:00
xushiwei
c0a0e889e7 Merge pull request #1214 from luoliwoshang/emb/esp32/tag
internal/build:include target build-tags in Go package compilation
2025-08-19 08:30:56 +08:00
xushiwei
c5b4452a1b Merge pull request #1217 from luoliwoshang/llgo/asm
cl(feat):llgo.asm implement tinygo.Asm
2025-08-19 08:14:22 +08:00
luoliwoshang
afee2beebe cl/instr:rm llgoAsmBase 2025-08-17 18:41:38 +08:00
xushiwei
630b63744a Merge pull request #1212 from goplus/dependabot/github_actions/actions/checkout-5
build(deps): bump actions/checkout from 4 to 5
2025-08-17 18:17:15 +08:00
xushiwei
1399c40243 Merge pull request #1215 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.19.1
build(deps): bump github.com/goplus/gogen from 1.19.0 to 1.19.1
2025-08-17 18:04:41 +08:00
luoliwoshang
a148964878 feat:llgo.Asm
test:asm test with `nop`
2025-08-17 16:50:16 +08:00
Li Jie
b831952e2e build native/wasi with clang++ and keep embed building with clang 2025-08-16 10:49:00 +08:00
Li Jie
21174e44bb fix wasi-libc caching path 2025-08-16 10:48:16 +08:00
Li Jie
b650a546cd supports linkerscript 2025-08-16 10:47:39 +08:00
Li Jie
e580ecc55c fix sysroot on macos with esp clang 2025-08-16 10:46:44 +08:00
visualfc
04bb3eb5a9 internal/cabi: check and skip param empty type 2025-08-15 21:29:43 +08:00
visualfc
28962a1c6c internal/cabi: test composite 2025-08-15 15:34:55 +08:00
visualfc
2fca50b7e5 internal/cabi: test wasm 2025-08-15 10:31:16 +08:00
visualfc
3617c82e8b internal/cabi: fix arch amd64 2025-08-14 11:22:01 +08:00
dependabot[bot]
bf0f81afd7 build(deps): bump github.com/goplus/gogen from 1.19.0 to 1.19.1
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.19.0 to 1.19.1.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.19.0...v1.19.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-14 00:25:06 +00:00
visualfc
ef07188534 internal/cabi: fix arch arm 2025-08-13 16:54:49 +08:00
visualfc
5fe7ee9b6a internal/cabi: TestBuild TestABI 2025-08-13 15:28:04 +08:00
luoliwoshang
a069e1d438 internal/build:include target build-tags in Go package compilation 2025-08-12 18:59:49 +08:00
dependabot[bot]
827f8b0e88 build(deps): bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 08:37:24 +00:00
luoliwoshang
b9fdc2a25c fix: set correct argc=0 in _start() function 2025-08-12 15:42:44 +08:00
visualfc
d2d999d369 internal/cabi: transform cfunc check called 2025-08-12 10:54:32 +08:00
visualfc
7b36cca86b _demo/cabi: abi test demo 2025-08-12 09:46:03 +08:00
visualfc
843dd03553 cmd: llgo -abi flag (default 2) 2025-08-12 09:43:47 +08:00
visualfc
6460724feb chore: llgen -abi flags (default 0) 2025-08-12 09:42:58 +08:00
visualfc
8e87bb6e86 internal/build: cabi transformer 2025-08-12 09:31:43 +08:00
visualfc
3ac2929789 internal/cabi: transform pkg to cabi 2025-08-12 09:30:16 +08:00
visualfc
2a88d5777a ssa: export target and module 2025-08-12 09:29:43 +08:00
xushiwei
b2c6534c92 Merge pull request #1209 from goplus/dependabot/go_modules/github.com/goplus/llvm-0.8.5
build(deps): bump github.com/goplus/llvm from 0.8.3 to 0.8.5
2025-08-08 19:49:51 +08:00
xushiwei
303b620062 Merge pull request #1208 from goplus/dependabot/go_modules/golang.org/x/tools-0.36.0
build(deps): bump golang.org/x/tools from 0.35.0 to 0.36.0
2025-08-08 19:49:32 +08:00
xushiwei
6940a5846b Merge pull request #1210 from visualfc/ssa_typeassert
ssa: fix TypeAssert check null
2025-08-08 19:48:27 +08:00
xushiwei
aa165829c6 Merge pull request #1199 from visualfc/pyptr
ssa: PyVal support pointer to long
2025-08-08 19:46:43 +08:00
visualfc
56f90dbcf9 ssa: fix TypeAssert check null 2025-08-08 12:11:17 +08:00
dependabot[bot]
1e09f54e56 build(deps): bump github.com/goplus/llvm from 0.8.3 to 0.8.5
Bumps [github.com/goplus/llvm](https://github.com/goplus/llvm) from 0.8.3 to 0.8.5.
- [Release notes](https://github.com/goplus/llvm/releases)
- [Commits](https://github.com/goplus/llvm/compare/v0.8.3...v0.8.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 00:51:16 +00:00
dependabot[bot]
39f0877ba0 build(deps): bump golang.org/x/tools from 0.35.0 to 0.36.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.35.0 to 0.36.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.35.0...v0.36.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-version: 0.36.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-08 00:51:11 +00:00
visualfc
54dfd3c701 ssa: PyVal support pointer to long 2025-08-07 20:39:35 +08:00
xushiwei
f43e2c0dee Merge pull request #1204 from visualfc/checklink
internal/build: set CheckLinkArgs disable on default
2025-08-07 17:17:22 +08:00
xushiwei
b03b8146df Merge pull request #1202 from visualfc/build
internal/build: delete duplicate linkObjFiles
2025-08-07 17:15:29 +08:00
xushiwei
1f94cfbe57 Merge pull request #1173 from luoliwoshang/os/direntNamePtr
os:direntNamePtr for array
2025-08-07 16:59:56 +08:00
xushiwei
6648e43bba Merge pull request #1205 from goplus/dependabot/github_actions/actions/download-artifact-5
build(deps): bump actions/download-artifact from 4 to 5
2025-08-07 16:55:46 +08:00
Li Jie
87f4f618aa feat(crosscompile): use versioned cache directory for ESP Clang
Add version suffix to ESP Clang cache directory path to enable
automatic updates when espClangVersion changes.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-06 20:25:50 +08:00
visualfc
dab8379392 internal/build: set CheckLinkArgs disable on default 2025-08-06 15:01:05 +08:00
dependabot[bot]
2fde31d782 build(deps): bump actions/download-artifact from 4 to 5
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-06 00:16:30 +00:00
Li Jie
7c4c8b8726 use prebuilt esp-llvm 2025-08-05 20:28:26 +08:00
Li Jie
deea8754ae feat(crosscompile): add ESP Clang multi-platform support
- Add ESP Clang download and extraction for cross-compilation
- Support multiple platforms: darwin/amd64, darwin/arm64, linux/amd64, linux/arm64, windows/amd64
- Integrate ESP Clang with target-based configuration system
- Add ClangRoot and ClangBinPath fields to Export struct
- Support .tar.xz extraction for ESP Clang packages
- Prioritize LLGoROOT clang installation over cached downloads
- Update build system to use custom clang for embedded platforms

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 15:18:15 +08:00
visualfc
69c1787e22 internal/build: delete duplicate linkObjFiles 2025-08-04 10:39:43 +08:00
Li Jie
3ac881b191 feat(crosscompile): add wasi-libc support with LLGoROOT priority
- Check LLGoROOT/crosscompile/wasi-libc first before downloading
- Fallback to cached wasi-sdk download if not found locally
- Update downloadAndExtract to return wasiSdkRoot path directly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-02 20:18:37 +08:00
xushiwei
aa49fe665f Merge pull request #1193 from cpunion/targets-refactor-1176
Build targets task 1: Basic Target Parameter Support for llgo build/run/test commands
2025-08-02 06:09:52 +08:00
Li Jie
b773de0815 ci: add build -target tests 2025-07-30 20:25:05 +08:00
Li Jie
49a5d3a350 dummy _start function for libc-free cases 2025-07-30 20:16:30 +08:00
Li Jie
6f829d0d43 add empty demo for build -target tests 2025-07-30 20:16:29 +08:00
Li Jie
daf0d7e56e feat(cmd): enable -target parameter for build, run, and test commands
- 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>
2025-07-30 20:16:29 +08:00
Li Jie
0136344282 feat(cmd): add -target flag support for build commands
- 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>
2025-07-30 20:16:29 +08:00
Li Jie
f571dde538 feat(build): integrate target configuration system into build pipeline
- 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>
2025-07-30 20:16:29 +08:00
Li Jie
5424b53b62 feat(crosscompile): extend Export struct and add target-based configuration
- 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>
2025-07-30 20:16:25 +08:00
xushiwei
86519b471e Merge pull request #1198 from visualfc/pybytes
ssa: PyVal support py bytes
2025-07-30 15:18:22 +08:00
visualfc
36fa18b28c ssa: PyVal support py bytes 2025-07-30 12:12:19 +08:00
xushiwei
d8da4364fd Merge pull request #1196 from visualfc/pyfunc
ssa: PyVal support pyfunc
2025-07-29 21:42:17 +08:00
visualfc
2538be9318 ssa: PyVal support pyfunc 2025-07-29 20:55:56 +08:00
xushiwei
a9193e36ff Merge pull request #1195 from visualfc/pyexpr
ssa: PyVal support bool,int,uint,string,complex
2025-07-29 20:09:16 +08:00
visualfc
0a6588c348 ssa: PyVal support bool,int,uint,string,bytearray,complex 2025-07-29 16:08:09 +08:00
Li Jie
0c11c93b3a docs: add LICENSE file for targets directory
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>
2025-07-29 15:13:02 +08:00
Li Jie
b80a54eb0f feat: implement target configuration system for issue #1176
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>
2025-07-29 15:12:58 +08:00
xushiwei
5eb833a984 Update README.md 2025-07-15 12:30:41 +08:00
xushiwei
66fd3a552d Merge pull request #1186 from goplus/dependabot/go_modules/golang.org/x/tools-0.35.0
build(deps): bump golang.org/x/tools from 0.34.0 to 0.35.0
2025-07-14 23:19:16 +08:00
dependabot[bot]
7f4b0d6215 build(deps): bump golang.org/x/tools from 0.34.0 to 0.35.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.34.0 to 0.35.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-version: 0.35.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-14 01:07:12 +00:00
xushiwei
5e6dd7644b Update README.md 2025-07-08 16:09:22 +08:00
xushiwei
a430e325ed Merge pull request #1184 from visualfc/syscall-js
runtime: support syscall/js
2025-07-07 11:02:15 +08:00
visualfc
e77c3a040d runtime: support syscall/js 2025-07-07 10:31:22 +08:00
xushiwei
734b3a075e Merge pull request #1183 from visualfc/patch
cl: patchType check func signature
2025-07-07 08:10:22 +08:00
xushiwei
6b5f299ccd Merge pull request #1182 from visualfc/emjs
runtime/js: impl CopyBytesToGo/CopyBytesToJS
2025-07-07 08:09:20 +08:00
visualfc
281b3ecf64 runtime/js: itoa 2025-07-04 10:00:46 +08:00
visualfc
d7f2f4efdd cl: patchType check func signature 2025-07-03 20:48:51 +08:00
visualfc
08077f03f1 runtime/js: impl CopyBytesToGo,CopyBytesToJS 2025-07-02 20:00:08 +08:00
visualfc
3d41514abd runtime/js: fix call args value incref 2025-07-02 14:36:08 +08:00
xushiwei
f2c16beab6 Merge pull request #1174 from luoliwoshang/build/rpathmode
refactor(internal/build):remove rpath change
2025-07-01 13:25:12 +08:00
xushiwei
8983b146f2 Merge pull request #1180 from visualfc/emcc_js
[WIP] runtime/js: js for emscripten
2025-07-01 13:24:04 +08:00
xushiwei
8b0c6eae02 Merge pull request #1181 from visualfc/trace
debug: fix print stack for wasm
2025-07-01 13:22:42 +08:00
visualfc
013f2ef00d debug: fix print stack for wasm 2025-07-01 11:31:15 +08:00
visualfc
e972be8dab runtime/js: js for emscripten 2025-06-30 20:55:32 +08:00
luoliwoshang
e60c3bd943 refactor(internal/build):remove rpath change 2025-06-26 13:55:58 +08:00
luoliwoshang
417a5692e3 os:direntNamePtr for array 2025-06-26 11:44:40 +08:00
xushiwei
f0728c4fe0 Merge pull request #1164 from visualfc/codegen
build: gen pkg.ll to object
2025-06-25 23:14:45 +08:00
visualfc
249f85a25e build: gen pkg to object 2025-06-25 21:01:18 +08:00
xushiwei
9c59ac297d Merge pull request #1171 from luoliwoshang/internal/build/test
fix(build):test all pkg with llgo test ./...
2025-06-25 18:17:41 +08:00
luoliwoshang
6e8f3d1d19 test(build):collect llgo test ./... output to test 2025-06-25 15:38:20 +08:00
luoliwoshang
3df783de13 test(build):case with llgo test ./... 2025-06-24 16:34:33 +08:00
luoliwoshang
b469fc990f fix(build):test all pkg with llgo test ./... 2025-06-24 14:07:20 +08:00
xushiwei
6df688e62e Merge pull request #1168 from xushiwei/q
#1165 cpkgimp: import c package
2025-06-23 23:07:12 +08:00
xushiwei
4f6f1c4453 #1165 cpkgimp: import c package 2025-06-23 22:58:26 +08:00
xushiwei
891e47ef60 Merge pull request #1167 from xushiwei/q
Write a C package in Go
2025-06-23 22:51:41 +08:00
xushiwei
84f0c0fd9f codecov: skip cl/cltest 2025-06-23 22:43:30 +08:00
xushiwei
25d64f2812 Merge pull request #1166 from xushiwei/q
rm llgo.old
2025-06-23 22:04:00 +08:00
xushiwei
915cdf2c23 #1165 2025-06-23 22:01:42 +08:00
xushiwei
b7b6e3bc93 testFrom: use test.Diff 2025-06-23 21:14:26 +08:00
xushiwei
3d53b12dea rm llgo.old 2025-06-23 15:45:07 +08:00
xushiwei
132e240e87 Delete doc/How-to-support-a-Rust-Library.md 2025-06-22 15:47:05 +08:00
xushiwei
0b233ea155 Merge pull request #1149 from luoliwoshang/readme/dep
ci/doc:install libunwind-19 & libc++-19
2025-06-22 15:29:36 +08:00
xushiwei
e9c96390e6 Merge pull request #1151 from luoliwoshang/internal/build/testdir
internal/build:switch workdir from testpkg like go behavior
2025-06-22 15:26:07 +08:00
xushiwei
50bd078620 Merge pull request #1130 from visualfc/globals
link globals importpath.name=value
2025-06-22 07:20:53 +08:00
luoliwoshang
65f1c2589c chore:consist install llvm component lib order 2025-06-20 18:07:30 +08:00
luoliwoshang
695329b9dd ci/doc:install libunwind-19 & libc++-19 2025-06-20 18:07:30 +08:00
visualfc
4726e824a0 build: link globals importpath.name=value 2025-06-17 11:11:06 +08:00
xushiwei
e68355d94f Merge pull request #1148 from visualfc/makefunc
reflect: makeFunc
2025-06-16 17:02:19 +08:00
xushiwei
f5c08a2681 Merge pull request #1152 from luoliwoshang/badge/xgo
chore(xgo):gop_autogen => xgo_autogen
2025-06-16 17:00:35 +08:00
xushiwei
b14520954c Merge pull request #1153 from luoliwoshang/readme/xgo
readme(xgo):xgo project
2025-06-16 17:00:10 +08:00
xushiwei
04ac5de29d Merge pull request #1154 from luoliwoshang/release/xgo
goreleaser:gop => xgo
2025-06-16 16:59:50 +08:00
visualfc
2118849d27 cl/_testgo/reflectmkfn 2025-06-13 09:13:48 +08:00
luoliwoshang
5e928b5ae1 goreleaser:gop => xgo 2025-06-12 19:05:50 +08:00
luoliwoshang
3576ed36e2 ci:fmt check ignore xgo_autogen.go 2025-06-12 18:55:18 +08:00
luoliwoshang
fc88c89f7c readme(xgo):xgo project 2025-06-12 18:53:08 +08:00
luoliwoshang
f48b37a218 chore(xgo):gop_autogen => xgo_autogen 2025-06-12 18:49:17 +08:00
luoliwoshang
48bd1d46af internal/build:switch workdir from testpkg like go behavior 2025-06-12 16:49:40 +08:00
visualfc
20a7d0f120 runtime/internal/lib/reflect: fix funcOf for runtime 2025-06-12 16:12:34 +08:00
visualfc
84729e21b8 reflect: makeFunc 2025-06-12 15:50:56 +08:00
xushiwei
26aaa65c1d Merge pull request #1144 from visualfc/ffi_wasm
libffi: support wasm32
2025-06-12 12:55:35 +08:00
xushiwei
c863daf873 Merge pull request #1147 from luoliwoshang/c++
cl:compile with clang++
2025-06-12 12:54:13 +08:00
luoliwoshang
93197e7621 internal/build:compile with c mode,when c file 2025-06-12 11:55:47 +08:00
luoliwoshang
9001cdb8f2 test:lib/cpp test 2025-06-11 21:11:21 +08:00
luoliwoshang
e7e9530eb8 some wrap to cpp 2025-06-11 21:02:32 +08:00
luoliwoshang
bdff346a20 temp moveup testdemo 2025-06-11 20:49:56 +08:00
luoliwoshang
4f5c95045d chore:keep origin c format 2025-06-11 20:30:44 +08:00
luoliwoshang
efabdf27c8 fcntl_unix.cpp 2025-06-11 20:04:13 +08:00
luoliwoshang
f36098d704 internal:link by LLGoFile to find libunwind 2025-06-11 19:46:49 +08:00
luoliwoshang
a5fd7f2eba internal/cl:include llvm-config --cflags to find libunwind.h 2025-06-11 19:34:59 +08:00
luoliwoshang
0cb29ab388 internal/runtime:runtime.cpp 2025-06-11 19:02:58 +08:00
luoliwoshang
9c66cb9b00 ci:install libunwind-19-dev 2025-06-11 18:23:32 +08:00
luoliwoshang
c2a50fa98d internal/clite:wrap with cpp 2025-06-11 18:18:52 +08:00
luoliwoshang
ac352179da ci:install libc++-dev in linux 2025-06-11 18:13:41 +08:00
luoliwoshang
f2f93c7f5f cl:compile with clang++ 2025-06-11 17:01:12 +08:00
visualfc
ce984d44a0 libffi: support wasm32 2025-06-11 09:10:46 +08:00
xushiwei
900ae67369 Merge pull request #1142 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.19.0
build(deps): bump github.com/goplus/gogen from 1.18.1 to 1.19.0
2025-06-09 18:07:16 +08:00
xushiwei
ffaac95c11 Merge pull request #1143 from visualfc/js
GOOS=js set -sENVIRONMENT=web,worker
2025-06-09 17:46:40 +08:00
visualfc
6fbc5c6fd0 GOOS=js set -sENVIRONMENT=web,worker 2025-06-09 13:34:13 +08:00
dependabot[bot]
f3c6d7e90f build(deps): bump github.com/goplus/gogen from 1.18.1 to 1.19.0
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.18.1 to 1.19.0.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.18.1...v1.19.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 01:04:12 +00:00
xushiwei
47c119a2d7 Merge pull request #1141 from goplus/dependabot/go_modules/golang.org/x/tools-0.34.0
build(deps): bump golang.org/x/tools from 0.30.0 to 0.34.0
2025-06-06 18:32:45 +08:00
dependabot[bot]
29904f8f22 build(deps): bump golang.org/x/tools from 0.30.0 to 0.34.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.30.0 to 0.34.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.30.0...v0.34.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-version: 0.34.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-06 01:16:01 +00:00
xushiwei
fc86634e29 Merge pull request #1140 from luoliwoshang/internal/dir
runtime:forkAndExecInChild chdir
2025-06-06 09:12:05 +08:00
xushiwei
c89c845b98 Merge pull request #1139 from visualfc/stat
syscall: Stat_t for js/wasip1
2025-06-06 09:09:57 +08:00
xushiwei
452d840512 Merge pull request #1138 from goplus/dependabot/go_modules/github.com/goplus/mod-0.17.1
build(deps): bump github.com/goplus/mod from 0.17.0 to 0.17.1
2025-06-06 09:09:19 +08:00
luoliwoshang
701568e011 internal:forkAndExecInChild chdir 2025-06-05 18:54:25 +08:00
visualfc
dade77d719 syscall: Stat_t for js/wasip1 2025-06-05 14:53:28 +08:00
dependabot[bot]
ae8b7bb1f5 build(deps): bump github.com/goplus/mod from 0.17.0 to 0.17.1
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.17.0 to 0.17.1.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.17.0...v0.17.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-04 00:37:13 +00:00
xushiwei
87c7b65223 Merge pull request #1134 from MeteorsLiu/fix-uninitiated-chan-mu
fix:  uninitiated mutex
2025-05-27 06:27:21 +08:00
xushiwei
71815a4963 Merge pull request #1131 from goplus/dependabot/go_modules/github.com/goplus/mod-0.17.0
build(deps): bump github.com/goplus/mod from 0.16.1 to 0.17.0
2025-05-27 06:14:37 +08:00
Haolan
69b2bfdeb2 fix: uninitiated mutex 2025-05-26 17:21:19 +08:00
dependabot[bot]
57d74dfdbf build(deps): bump github.com/goplus/mod from 0.16.1 to 0.17.0
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.16.1 to 0.17.0.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.16.1...v0.17.0)

---
updated-dependencies:
- dependency-name: github.com/goplus/mod
  dependency-version: 0.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-26 00:22:04 +00:00
xushiwei
450a3637e4 Merge pull request #1129 from luoliwoshang/test/exitrefine
chore:test exit code.
2025-05-22 22:10:46 +08:00
luoliwoshang
780c927ea6 chore:test exit code. 2025-05-22 09:53:34 +08:00
xushiwei
254db35ef1 Merge pull request #1128 from luoliwoshang/test/exit
build:exit when test fail
2025-05-22 05:50:49 +08:00
luoliwoshang
0463230533 build:exit when test fail 2025-05-21 16:21:06 +08:00
xushiwei
44e1435c65 Merge pull request #1127 from runsys/main
widows build support
2025-05-19 02:21:38 +08:00
runsys
73270f0e87 windows mingw64 llvm 20 support patch 2 2025-05-18 17:05:12 +08:00
runsys
c1550cf608 windows mingw64 llvm 20 support patch 1 2025-05-18 17:03:47 +08:00
xushiwei
cd2e8aa40a Merge pull request #1126 from visualfc/runtime
runtime: GOOS GOARCH Compiler
2025-05-17 21:16:16 +08:00
visualfc
bb70b6eeab runtime: GOOS GOARCH Compiler 2025-05-17 16:28:26 +08:00
xushiwei
9b28d2ac70 Merge pull request #1123 from cpunion/wasm-emscripten1
Build js/wasm with emscripten
2025-05-17 15:08:05 +08:00
Li Jie
fd1def7885 build js/wasm target with emscripten 2025-05-17 10:48:27 +08:00
Li Jie
9a79078441 clang.Cmd.CheckLinkArgs compiles to temp file and remove 2025-05-17 10:48:26 +08:00
Li Jie
bb43622fe7 runtime: wasm compatible with js build tag 2025-05-17 10:48:26 +08:00
xushiwei
9203c366e7 Merge pull request #1121 from visualfc/closure
fix reflect.pointer  for closure; fix runtime unsafe.pointer ptrBytes
2025-05-17 01:19:40 +08:00
xushiwei
11a8af1db2 Merge pull request #1122 from visualfc/syscall
runtime/internal/clite/syscall: fix init
2025-05-17 01:19:04 +08:00
visualfc
c8fb7eafa0 runtime/internal/clite/os: fix stat for macOS 2025-05-16 20:36:43 +08:00
visualfc
ffc1f712a3 runtime/internal/clite/syscall: fix init 2025-05-16 16:29:31 +08:00
visualfc
cfc8687851 lib/reflect: fix closure pointer 2025-05-16 12:00:59 +08:00
visualfc
953699b2fd internal/runtime: fix abi.UnsafePointer PtrBytes 2025-05-16 12:00:59 +08:00
xushiwei
9a16fff27e Merge pull request #1118 from tsingbx/llgo.buildflag
fix gop run . flag provided but not defined: -ldflags
2025-05-16 11:21:24 +08:00
xushiwei
ac0d104231 Merge pull request #1117 from visualfc/bound
cl: funcName check $bound
2025-05-16 10:59:25 +08:00
xushiwei
881efea006 Merge pull request #1119 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.18.1
build(deps): bump github.com/goplus/gogen from 1.18.0 to 1.18.1
2025-05-16 10:47:17 +08:00
dependabot[bot]
f6a380d293 build(deps): bump github.com/goplus/gogen from 1.18.0 to 1.18.1
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.18.0...v1.18.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-16 00:57:11 +00:00
tsingbx
a971b93994 fix gop run . flag provided but not defined: -ldflags 2025-05-16 00:44:37 +08:00
visualfc
c4f0dd124d cl: funcName check $bound 2025-05-15 21:12:18 +08:00
xushiwei
93b9b7d44c Merge pull request #1112 from goplus/dependabot/go_modules/github.com/qiniu/x-1.14.6
build(deps): bump github.com/qiniu/x from 1.14.0 to 1.14.6
2025-05-13 11:03:01 +08:00
dependabot[bot]
7552bfe39b build(deps): bump github.com/qiniu/x from 1.14.0 to 1.14.6
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.14.0 to 1.14.6.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.14.0...v1.14.6)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-version: 1.14.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-13 00:30:42 +00:00
xushiwei
2601faaff2 Merge pull request #1111 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.12
build(deps): bump github.com/goplus/cobra from 1.9.11 to 1.9.12
2025-05-13 01:02:28 +08:00
dependabot[bot]
cb2e28d086 build(deps): bump github.com/goplus/cobra from 1.9.11 to 1.9.12
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.11 to 1.9.12.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.11...v1.9.12)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 00:59:41 +00:00
xushiwei
337877313a Merge pull request #1109 from xushiwei/q
rm xtool/{cppkg,cpgithubpkg}
2025-05-12 04:04:08 +08:00
xushiwei
1693942cee rm xtool/{cppkg,cpgithubpkg} 2025-05-12 03:50:07 +08:00
xushiwei
867a1ce2f4 Merge pull request #1108 from xushiwei/q
github api: release/asset id => int64
2025-05-12 02:28:34 +08:00
xushiwei
26b997537f getAppManager: rm notFoundMgs 2025-05-12 02:26:46 +08:00
xushiwei
19056b8a19 Merge remote-tracking branch 'gop/main' into q 2025-05-12 02:25:26 +08:00
xushiwei
10d603b377 Merge pull request #1104 from luoliwoshang/unix/install
xtool/cppkg:install in linux
2025-05-12 02:24:36 +08:00
xushiwei
3f41c313ad github api: release/asset id => int64 2025-05-11 20:55:59 +08:00
xushiwei
d440949c1d Merge pull request #1103 from tsingbx/llgo.usage
add usage for llgo
2025-05-10 11:29:30 +08:00
xushiwei
64314dc6cf Merge pull request #1107 from xushiwei/q
github api: EnumTags
2025-05-10 11:28:17 +08:00
xushiwei
decb9d7f11 github api: EnumTags 2025-05-10 11:27:50 +08:00
tsingbx
975b0b74ee panic err => return 2025-05-10 07:15:48 +08:00
xushiwei
9aa7807b02 Merge pull request #1106 from xushiwei/q
xtool/cppkg: ConanStderr
2025-05-09 23:36:12 +08:00
xushiwei
337c6cfa25 xtool/cppkg: ConanStderr 2025-05-09 23:31:31 +08:00
luoliwoshang
f09a423ee7 xtool/cppkg:tips when app managers not found 2025-05-09 14:25:44 +08:00
tsingbx
3bf28f52c4 add usage for llgo 2025-05-09 12:59:11 +08:00
luoliwoshang
f794592f42 xtool/cppkg install by pipx 2025-05-09 10:20:05 +08:00
xushiwei
98bd05b47b Merge pull request #1102 from xushiwei/q
cmd/llog: main_cmd.gox => main_app.gox
2025-05-08 09:41:20 +08:00
xushiwei
3edbde0839 cmd/llog: main_cmd.gox => main_app.gox 2025-05-08 09:34:01 +08:00
xushiwei
a2d92eac0b Merge pull request #1100 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.11
build(deps): bump github.com/goplus/cobra from 1.9.9 to 1.9.11
2025-05-08 09:31:35 +08:00
xushiwei
eb47c545ec Merge pull request #1101 from xushiwei/q
xtool/cppkg: InstallPkg allows to customize cacheDir
2025-05-08 09:30:06 +08:00
xushiwei
c858f79449 xtool/cppkg: InstallPkg allows to customize cacheDir 2025-05-08 09:26:45 +08:00
dependabot[bot]
27f6efbdec build(deps): bump github.com/goplus/cobra from 1.9.9 to 1.9.11
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.9 to 1.9.11.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.9...v1.9.11)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-08 00:59:40 +00:00
xushiwei
bba7494ffd Merge pull request #1099 from xushiwei/q
xtool/cppkg: InstallPkg KnownLatestVersion
2025-05-08 08:17:20 +08:00
xushiwei
0f79cad5a7 xtool/cppkg: InstallPkg KnownLatestVersion 2025-05-08 08:10:56 +08:00
xushiwei
9e7bacbe23 Merge pull request #1098 from xushiwei/q
cmd/llgo: main cmd
2025-05-07 22:31:39 +08:00
xushiwei
2301a4834d cmd/llog: main cmd 2025-05-07 22:30:54 +08:00
xushiwei
40e0f58079 Merge pull request #1094 from goplus/dependabot/go_modules/github.com/goplus/cobra-1.9.9
build(deps): bump github.com/goplus/cobra from 1.9.8 to 1.9.9
2025-05-07 03:40:46 +08:00
xushiwei
c23fb144cf Merge branch 'main' into dependabot/go_modules/github.com/goplus/cobra-1.9.9 2025-05-07 03:33:04 +08:00
xushiwei
caac681ac3 Merge pull request #1095 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.18.0
build(deps): bump github.com/goplus/gogen from 1.17.3 to 1.18.0
2025-05-07 03:32:18 +08:00
xushiwei
9ba3b3ef8f Merge pull request #1097 from goplus/dependabot/go_modules/github.com/goplus/mod-0.16.1
build(deps): bump github.com/goplus/mod from 0.16.0 to 0.16.1
2025-05-07 03:24:15 +08:00
dependabot[bot]
d7e523948b build(deps): bump github.com/goplus/mod from 0.16.0 to 0.16.1
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.16.0 to 0.16.1.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.16.0...v0.16.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:31 +00:00
dependabot[bot]
10a75138d1 build(deps): bump github.com/goplus/gogen from 1.17.3 to 1.18.0
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.17.3 to 1.18.0.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.17.3...v1.18.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:25 +00:00
dependabot[bot]
d48b19c866 build(deps): bump github.com/goplus/cobra from 1.9.8 to 1.9.9
Bumps [github.com/goplus/cobra](https://github.com/goplus/cobra) from 1.9.8 to 1.9.9.
- [Release notes](https://github.com/goplus/cobra/releases)
- [Commits](https://github.com/goplus/cobra/compare/v1.9.8...v1.9.9)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 15:00:21 +00:00
xushiwei
1fdcb55eba Merge pull request #1080 from xushiwei/q
xtool/cpgithubpkg
2025-05-06 09:44:05 +08:00
xushiwei
16cec9f045 merge upstream 2025-05-06 09:41:19 +08:00
xushiwei
438b0bd1b0 Merge pull request #1091 from visualfc/go123
go.mod go1.23
2025-05-06 08:32:06 +08:00
visualfc
e8a91696d6 go.mod go1.23 2025-05-05 10:19:23 +08:00
xushiwei
8882c31eb4 Merge pull request #1090 from xushiwei/cppkg
xtool/cppkg: support latest version
2025-05-04 17:40:07 +08:00
xushiwei
8455ee8226 xtool/cppkg: support latest version 2025-05-04 17:34:02 +08:00
xushiwei
3f74aded8a Merge pull request #1089 from xushiwei/cppkg
llgo cppkg: remove unused import
2025-05-04 16:44:38 +08:00
xushiwei
2e19c2013c llgo cppkg: remove unused import 2025-05-04 16:43:07 +08:00
xushiwei
1edaa2d09b Merge pull request #1088 from xushiwei/cppkg
cmd: llgo cppkg install
2025-05-04 16:06:20 +08:00
xushiwei
beee018287 cmd: llgo cppkg install 2025-05-04 16:01:58 +08:00
xushiwei
34266ea59d Merge pull request #1087 from xushiwei/cppkg
llgo.next => llgo
2025-05-04 15:39:50 +08:00
xushiwei
f26127ce98 llgo.next => llgo 2025-05-04 15:34:32 +08:00
xushiwei
ccf321d178 Merge pull request #1086 from xushiwei/cppkg
llgo.next: support build, run, cmptest
2025-05-04 15:23:40 +08:00
xushiwei
355721c47a llgo.next: support build, run, cmptest 2025-05-04 15:18:49 +08:00
xushiwei
d400663e5d Merge pull request #1085 from xushiwei/cppkg
cmd: llgo.next
2025-05-04 14:14:10 +08:00
xushiwei
2203be945a codecov: ignore llgo.next 2025-05-04 14:10:43 +08:00
xushiwei
b9a2bf4b42 fmt: ignore gop_autogen.go 2025-05-04 14:08:43 +08:00
xushiwei
cc08195cf2 cmd: llgo.next 2025-05-04 14:04:43 +08:00
xushiwei
50c40a7828 Merge pull request #1084 from xushiwei/cppkg
go mod tidy
2025-05-04 10:41:57 +08:00
xushiwei
158be3f949 go mod tidy 2025-05-04 10:28:24 +08:00
xushiwei
0f87c322ca Merge pull request #1082 from xushiwei/cppkg
xtool/cppkg: Main => Install
2025-05-04 00:15:26 +08:00
xushiwei
d5dd19b64c xtool/cppkg: Main => Install 2025-05-04 00:08:20 +08:00
xushiwei
3ac9055493 xtool/cpgithubpkg 2025-05-03 23:30:29 +08:00
xushiwei
3032d730b7 Merge pull request #1079 from xushiwei/q
package: xtool/cppkg
2025-05-03 23:22:55 +08:00
xushiwei
e93e7126b6 package: xtool/cppkg 2025-05-03 23:13:10 +08:00
xushiwei
9bcf41d28f Merge pull request #1078 from xushiwei/q
github api: release, tag, commit
2025-05-03 22:58:01 +08:00
xushiwei
604ce47d5e github api: release, tag, commit 2025-05-03 22:50:04 +08:00
xushiwei
e1ebe150d4 Merge pull request #1077 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.17.3
build(deps): bump github.com/goplus/gogen from 1.17.2 to 1.17.3
2025-04-28 08:28:56 +08:00
dependabot[bot]
ae992737e8 build(deps): bump github.com/goplus/gogen from 1.17.2 to 1.17.3
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.17.2 to 1.17.3.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.17.2...v1.17.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-28 00:15:49 +00:00
xushiwei
c59d609eb8 Merge pull request #1076 from xushiwei/t
_cmptest: mathbigdemo
2025-04-28 01:18:10 +08:00
xushiwei
9f26d12a3e _cmptest: mathbigdemo 2025-04-28 01:03:13 +08:00
xushiwei
9102577eba Merge pull request #1075 from xushiwei/t
go/parser demo
2025-04-28 00:46:00 +08:00
xushiwei
f0fcfde22b README: go/parser 2025-04-28 00:37:11 +08:00
xushiwei
d9d813db56 go/parser demo 2025-04-28 00:35:45 +08:00
xushiwei
a8808855ae Merge pull request #1074 from visualfc/fix_amd64
runtime/internal/clite/pthread/sync/sync_darwin_amd64: PthreadMutexSize = 64
2025-04-27 16:20:35 +08:00
visualfc
5583f9418a runtime/internal/clite/pthread/sync/sync_darwin_amd64: PthreadMutexSize = 64 2025-04-27 12:40:32 +08:00
xushiwei
7369ffd2aa Merge pull request #1073 from xushiwei/t
_demo: hello
2025-04-26 23:04:06 +08:00
xushiwei
ab15f30b13 _demo: hello 2025-04-26 22:55:46 +08:00
xushiwei
8bff07d66b Merge pull request #1072 from xushiwei/t
fix #965 Dead loop in cl/blocks.Infos
2025-04-26 22:38:45 +08:00
xushiwei
e2e2cb38be fix #965 2025-04-26 22:23:36 +08:00
xushiwei
10d84a6a6b Merge pull request #1070 from goplus/dependabot/go_modules/github.com/goplus/mod-0.16.0
build(deps): bump github.com/goplus/mod from 0.15.1 to 0.16.0
2025-04-26 06:40:51 +08:00
dependabot[bot]
a4b4c1574b build(deps): bump github.com/goplus/mod from 0.15.1 to 0.16.0
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.15.1 to 0.16.0.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.15.1...v0.16.0)

---
updated-dependencies:
- dependency-name: github.com/goplus/mod
  dependency-version: 0.16.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-25 22:33:17 +00:00
xushiwei
94bc39bdb2 Merge pull request #1071 from goplus/dependabot/go_modules/github.com/qiniu/x-1.13.19
build(deps): bump github.com/qiniu/x from 1.13.18 to 1.13.19
2025-04-26 06:32:13 +08:00
dependabot[bot]
7c93b37125 build(deps): bump github.com/qiniu/x from 1.13.18 to 1.13.19
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.13.18 to 1.13.19.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.13.18...v1.13.19)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-version: 1.13.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 00:11:24 +00:00
xushiwei
4371cc10bd Merge pull request #1068 from goplus/dependabot/go_modules/github.com/qiniu/x-1.13.18
build(deps): bump github.com/qiniu/x from 1.13.17 to 1.13.18
2025-04-22 00:55:37 +08:00
xushiwei
eaa2628934 Merge pull request #1069 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.17.2
build(deps): bump github.com/goplus/gogen from 1.17.1 to 1.17.2
2025-04-21 22:21:09 +08:00
dependabot[bot]
30e247186c build(deps): bump github.com/goplus/gogen from 1.17.1 to 1.17.2
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.17.1 to 1.17.2.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.17.1...v1.17.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-21 00:49:42 +00:00
dependabot[bot]
2714da8d98 build(deps): bump github.com/qiniu/x from 1.13.17 to 1.13.18
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.13.17 to 1.13.18.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.13.17...v1.13.18)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-version: 1.13.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-21 00:48:47 +00:00
xushiwei
0ef3a7ec25 Merge pull request #1067 from cpunion/llgo-env
Fix args parsing
2025-04-18 19:42:14 +08:00
Li Jie
489a0069aa extract common cmd flags 2025-04-18 13:12:05 +08:00
xushiwei
a257b7bdfa Merge pull request #1059 from cpunion/wasm-dev
Wasm dev
2025-04-18 08:55:20 +08:00
Li Jie
739cc66d0d test wasm with _demo/hello 2025-04-18 00:37:02 +08:00
Li Jie
28d944c6af remove unused wasm_import 2025-04-17 22:59:34 +08:00
Li Jie
19b98393a6 TODO: defer workaround, should remove after fix 2025-04-17 10:06:59 +08:00
Li Jie
5a13e7400e update outdated github.com/goplus/llgo/c references 2025-04-17 10:06:56 +08:00
Li Jie
a56129d675 blank syscall.SetNonblock on wasm 2025-04-17 09:58:52 +08:00
Li Jie
0d75bbace0 fix itab on 32bit 2025-04-17 09:58:52 +08:00
Li Jie
29ec4a7a0e allow config LLGO_WASM_RUNTIME with args 2025-04-17 09:58:52 +08:00
Li Jie
8b26c48d9b execute clang -v in verbose mode 2025-04-17 09:58:52 +08:00
Li Jie
ddd0535d30 split llfiles and ldflags and extract compileAndLinkLLFiles to prepare multi-phase build 2025-04-17 09:58:52 +08:00
xushiwei
adcd370c27 Merge pull request #1066 from goplus/dependabot/go_modules/github.com/goplus/mod-0.15.1
build(deps): bump github.com/goplus/mod from 0.13.17 to 0.15.1
2025-04-16 01:50:01 +08:00
dependabot[bot]
dbead0d725 build(deps): bump github.com/goplus/mod from 0.13.17 to 0.15.1
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.13.17 to 0.15.1.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.13.17...v0.15.1)

---
updated-dependencies:
- dependency-name: github.com/goplus/mod
  dependency-version: 0.15.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-14 04:26:37 +00:00
xushiwei
207aea813b Merge pull request #1065 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.17.1
build(deps): bump github.com/goplus/gogen from 1.16.9 to 1.17.1
2025-04-14 12:25:03 +08:00
xushiwei
7a771154a7 Merge pull request #1063 from goplus/dependabot/go_modules/github.com/qiniu/x-1.13.17
build(deps): bump github.com/qiniu/x from 1.13.12 to 1.13.17
2025-04-14 12:24:38 +08:00
dependabot[bot]
18c6b9b404 build(deps): bump github.com/goplus/gogen from 1.16.9 to 1.17.1
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.9 to 1.17.1.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.9...v1.17.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-14 00:40:41 +00:00
Li Jie
3110382d88 fix abi methods crash on wasm 2025-04-11 17:16:02 +08:00
Li Jie
9ee55896e3 update link args for wasm target 2025-04-11 16:28:48 +08:00
Li Jie
ad6f41f312 add LLGO_STDIO_NOBUF to toggle stdout/stderr buffer 2025-04-11 16:28:48 +08:00
Li Jie
8512395985 AllocCStr allocates on heap 2025-04-11 16:28:48 +08:00
Li Jie
7284042823 run wasm with iwasm 2025-04-11 16:28:47 +08:00
Li Jie
0ef683bba9 add LLGO_WASI_THREADS to toggle wasi threads support 2025-04-11 16:28:47 +08:00
Li Jie
d4bf66936a specify setjmp/longjmp function names on wasm 2025-04-11 16:28:47 +08:00
Li Jie
be4737461a make runtime compatible with wasm 2025-04-11 16:28:44 +08:00
dependabot[bot]
0d22b3be05 build(deps): bump github.com/qiniu/x from 1.13.12 to 1.13.17
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.13.12 to 1.13.17.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.13.12...v1.13.17)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-version: 1.13.17
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-11 00:33:04 +00:00
Li Jie
7c81d9293b blank ffi for wasm 2025-04-09 14:57:33 +08:00
Li Jie
d1dce65313 update link flags 2025-04-09 14:57:33 +08:00
Li Jie
641f9bbf7c select WASM runtime by LLGO_WASM_RUNTIME 2025-04-09 14:57:32 +08:00
xushiwei
be0e42cf82 Merge pull request #1057 from cpunion/cross-compiling
Cross compiling
2025-04-09 14:26:09 +08:00
Li Jie
3a883b8821 upgrade to github.com/goplus/lib v0.2.0 2025-04-08 19:32:26 +08:00
Li Jie
4bbc58d62d test cross compile on macos 2025-04-08 11:53:21 +08:00
Li Jie
5f4b09bede regenerate snapshot tests 2025-04-08 11:13:00 +08:00
Li Jie
f0ade21155 update docs and CI 2025-04-08 11:12:59 +08:00
Li Jie
f35063ee6e build: download and compile with wasi-sdk 2025-04-08 11:12:57 +08:00
Li Jie
e6c7627ee8 cross compilation 2025-04-08 10:46:14 +08:00
Li Jie
a85d937482 enable command tests 2025-04-08 09:38:00 +08:00
Li Jie
b17632a352 xtool: clang.Cmd supports Env/Verbose/Stdio, add CCFLAGS support 2025-04-08 09:25:49 +08:00
xushiwei
b11eb742cb Merge pull request #1055 from cpunion/fix-ll
fix remote install test
2025-04-03 18:16:09 +08:00
Li Jie
b63a7f64fd fix _readme tests 2025-04-03 17:35:45 +08:00
xushiwei
cafc438972 Merge pull request #1054 from cpunion/fix-ll
fix readme link and tests
2025-04-03 17:29:22 +08:00
Li Jie
33ef7f737b fix doc links 2025-04-03 17:08:13 +08:00
Li Jie
3e26685a44 fix _readme tests 2025-04-03 17:02:06 +08:00
xushiwei
6a306be480 Merge pull request #1052 from cpunion/fix-ll
mv llgo/{c,cpp,py,x} => lib/{c,cpp,py,x}
2025-04-03 16:56:37 +08:00
Li Jie
9defb6289b separate doc/_readme as a module 2025-04-03 16:44:44 +08:00
Li Jie
a47ad2886f fix broken links 2025-04-03 16:43:23 +08:00
Li Jie
c8d791f206 fix llgo test unit test 2025-04-03 16:32:46 +08:00
Li Jie
8c5f915569 update installation scripts and docs 2025-04-03 16:26:15 +08:00
Li Jie
ed366568b4 move out c/cpp/py 2025-04-03 16:26:11 +08:00
xushiwei
0a8a4eb6a6 Merge pull request #1050 from cpunion/llvm-19
Llvm 19
2025-04-03 11:55:32 +08:00
Li Jie
fdc6cf4838 ci: add -mmacosx-version-min=10.13 to goreleaser macos build 2025-04-03 01:00:53 +08:00
Li Jie
e52af0077b doc: brew link lld@19 2025-04-03 00:26:10 +08:00
Li Jie
847f544839 ci: hide sync progress 2025-04-02 23:28:13 +08:00
Li Jie
685d3202d0 ci: update goreleaser config 2025-04-02 21:49:11 +08:00
Li Jie
33a2580cc3 xtool: update llvm@19 env 2025-04-02 21:49:11 +08:00
Li Jie
a8da654597 ci: make doc verify continue on error 2025-04-02 21:06:07 +08:00
Li Jie
ae01a023ad cl: update snapshot tests 2025-04-02 20:13:02 +08:00
Li Jie
ec20af3c4d ci: upgrade to llvm 19 2025-04-02 20:12:41 +08:00
Li Jie
a6f1ad1c2c compiler: upgrade to llvm@v0.8.3 (llvm 19) 2025-04-02 20:07:52 +08:00
xushiwei
c3532f17de Merge pull request #1047 from visualfc/wasm32
wasm32
2025-04-01 23:32:21 +08:00
visualfc
86eac2f04d wasm32 2025-04-01 22:40:04 +08:00
xushiwei
3b9b71643c Merge pull request #1044 from visualfc/wasmsizes
compiler: check wasm sizes
2025-04-01 13:27:26 +08:00
visualfc
19417cdd52 compiler: check wasm sizes 2025-03-31 17:25:40 +08:00
xushiwei
a7c23e25d8 Merge pull request #1040 from goplus/dependabot/go_modules/compiler/github.com/goplus/gogen-1.16.9
build(deps): bump github.com/goplus/gogen from 1.16.8 to 1.16.9 in /compiler
2025-03-27 11:01:41 +08:00
dependabot[bot]
f96ab87536 build(deps): bump github.com/goplus/gogen in /compiler
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.8 to 1.16.9.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.8...v1.16.9)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-27 01:08:20 +00:00
xushiwei
d65d49f504 Merge pull request #1036 from cpunion/split-debug-and-symbols
Split debug and symbols toggle environment variables
2025-03-24 19:04:15 +08:00
Li Jie
8cd5924bf2 compiler: split LLGO_DEBUG into LLGO_DEBUG, LLGO_DBG_SYMBOLS, disableInline 2025-03-23 13:21:58 +08:00
xushiwei
9f38338c58 Merge pull request #1032 from cpunion/fix-linking
Remove LLVM runtime depencendy, better c toolchain integration
2025-03-20 15:47:43 +08:00
Li Jie
8c76436d81 ci: limit concurrency of doc links checker 2025-03-20 12:45:05 +08:00
Li Jie
0e71576265 build: pass CFLAGS and LDFLAGS to clang 2025-03-20 11:17:27 +08:00
Li Jie
71b34003ca debug: rollback unwind to don't depends llvm runtime, solve libunwind linking on homebrew linux in llgo formal 2025-03-19 14:32:32 +08:00
xushiwei
2c417d75a2 Merge pull request #1030 from cpunion/run-llgo-test
ci: run llgo test
2025-03-19 12:47:31 +08:00
Li Jie
74ededd8c8 ci: run llgo test ./... 2025-03-19 11:35:52 +08:00
Li Jie
a732fa237c test: reduce unnecessary pkgs compilation for llgo test 2025-03-19 11:35:51 +08:00
Li Jie
fd4c22308d ssa: removed unused ssa.Program.goStrs 2025-03-19 11:25:51 +08:00
Li Jie
d6f18894e6 test: add llgo build tag to compiler test cases 2025-03-19 11:25:50 +08:00
xushiwei
992d54693f Merge pull request #1029 from visualfc/gogen
update gogen v1.16.8
2025-03-19 08:51:12 +08:00
visualfc
9be1bd0775 update gogen 2025-03-19 08:32:00 +08:00
xushiwei
29cc689abd Merge pull request #1023 from cpunion/toggle-rpath-change
link: don't run install_name_tool -change by default
2025-03-13 23:15:47 +08:00
xushiwei
39d28e507d Merge pull request #1022 from goplus/dependabot/go_modules/compiler/github.com/goplus/gogen-1.16.7
build(deps): bump github.com/goplus/gogen from 1.16.6 to 1.16.7 in /compiler
2025-03-13 23:12:38 +08:00
Li Jie
eacb5bc6f8 link: don't run install_name_tool -change by default 2025-03-13 19:55:48 +08:00
dependabot[bot]
19658454bd build(deps): bump github.com/goplus/gogen in /compiler
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.6 to 1.16.7.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.6...v1.16.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-13 00:17:09 +00:00
xushiwei
02e3a6ae8b Merge pull request #1018 from cpunion/fix-libunwind
runtime: fix libunwind to compatible with homebrew linux
2025-03-04 19:46:35 +08:00
Li Jie
77376087db ci: optimize model download to avoid Huggingface blocking
Download the LLaMA model as a separate job and share it as an artifact to prevent
repeated downloads from Huggingface which could lead to rate limiting or blocking.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-04 11:20:16 +08:00
Li Jie
52a77f9efb runtime: fix libunwind to compatible with homebrew linux 2025-03-04 10:52:18 +08:00
xushiwei
d483b13107 Merge pull request #1011 from visualfc/deferargs2
support defer args
2025-02-28 18:14:16 +08:00
xushiwei
dea4d9df63 Merge pull request #1015 from luoliwoshang/runtime/rmlog
runtime:rm log of StartProcess
2025-02-28 18:10:54 +08:00
xushiwei
b7601a7f08 Merge pull request #1016 from luoliwoshang/ctype
c:some type & stat's pub
2025-02-28 18:10:27 +08:00
luoliwoshang
2e148d6d0e c/pub:fix stat 2025-02-28 16:45:42 +08:00
luoliwoshang
8835a1a232 c:some type 2025-02-28 16:18:27 +08:00
visualfc
00e3b6b5a0 _demo/defer 2025-02-27 14:38:25 +08:00
visualfc
3bb51c5d51 ssa: defer load/store func and args 2025-02-27 14:32:21 +08:00
luoliwoshang
433df05858 runtime:rm log of StartProcess 2025-02-27 14:18:44 +08:00
xushiwei
22524b03c8 Merge pull request #1013 from tsingbx/llgo/llcppg.pub
add all llcppg.pub for clib
2025-02-27 10:41:44 +08:00
tsingbx
508fa62a48 delete llcppg.pub for debug,llama2,neco,setjmp,sys,syscall 2025-02-26 15:30:45 +08:00
tsingbx
e7f7f98c02 add all llcppg.pub for clib 2025-02-26 15:25:06 +08:00
xushiwei
9edaa8eb93 Merge pull request #1010 from cpunion/fix-empty-content
build: fix empty .ll file name generation
2025-02-22 17:46:36 +08:00
Li Jie
32587c1a40 build: fix empty .ll file name generation 2025-02-22 09:25:44 +08:00
xushiwei
019c482d18 Merge pull request #995 from cpunion/fix-llgo-test-crash
Build on Go 1.24, compatible with Go version directive 1.20-1.24 in go.mod
2025-02-21 06:04:21 +08:00
Li Jie
ca906d9c71 test: add byte and append coverage 2025-02-19 12:27:46 +08:00
Li Jie
35ba8476b0 runtime: net/textproto/textproto.go overlay don't import llgo runtime 2025-02-19 12:09:03 +08:00
Li Jie
a473901cfd runtime: patching testing/testing.go for go1.24 2025-02-19 11:46:47 +08:00
Li Jie
b163d71aed test: 3 attempts to avoid clang errors 2025-02-19 11:35:24 +08:00
Li Jie
d561f1399a test: test compiler/internal/build with verbose to show clang command line 2025-02-19 11:35:24 +08:00
Li Jie
00406e08fb ssa: record NeedRuntime, NeedPyInit in Package to compatible multi-packages building 2025-02-19 11:35:24 +08:00
Li Jie
0e4ca910d6 build: building multi packages outputs to temporary path 2025-02-19 11:35:24 +08:00
Li Jie
b00f52472b build: don't output pkg path 2025-02-19 11:35:24 +08:00
Li Jie
95a6e356ee build: let llgo build without -o outputs executable 2025-02-19 11:35:24 +08:00
Li Jie
f4da8e8876 runtime: disable godebug unimplemented warnings 2025-02-19 11:35:23 +08:00
Li Jie
1a08a59b49 env: fix devel version name 2025-02-19 11:35:23 +08:00
Li Jie
758ceb791b compiler: upgrade x/tools 0.30.0 2025-02-19 11:35:23 +08:00
Li Jie
6a1e0084f4 ssa: support len([]func()) 2025-02-19 11:35:23 +08:00
Li Jie
e318cab252 compiler: add internal/build tests 2025-02-19 11:35:23 +08:00
Li Jie
6b12547303 ci: filter out uncollected packages 2025-02-19 11:35:23 +08:00
Li Jie
96d6c00815 cl: regenerate test snapshots 2025-02-19 11:35:22 +08:00
Li Jie
7be79d81f9 ssa: uniform byte and uint8 name on different platforms 2025-02-19 11:35:22 +08:00
Li Jie
2be558d554 runtime: reflect.Value.Equal 2025-02-19 11:35:22 +08:00
Li Jie
60fac0a010 ci: test on go1.24 2025-02-19 11:35:21 +08:00
Li Jie
df0f239929 runtime: fix patch for testing 2025-02-17 07:50:37 +08:00
Li Jie
4e1aea4597 ci: run llgo test 2025-02-17 07:50:36 +08:00
xushiwei
60224dd77d Merge pull request #1003 from cpunion/fix-sleep
runtime: fix time.Sleep
2025-02-17 06:15:08 +08:00
xushiwei
ded408f145 Merge pull request #1004 from visualfc/goexit2
runtime: goexit use thread key
2025-02-17 06:12:28 +08:00
xushiwei
69deeca321 Merge pull request #1002 from cpunion/fix-global-var-type
cl: fix wrong global variable type patching
2025-02-17 06:09:10 +08:00
xushiwei
5e1e7bdad0 Merge pull request #1005 from cpunion/safe-mutex-init
runtime: safe mutex initialization
2025-02-17 06:08:21 +08:00
Li Jie
22f4924d8e runtime: safe mutex initialization 2025-02-16 20:52:22 +08:00
visualfc
8591275eb2 runtime: goexit use thread key 2025-02-16 19:53:38 +08:00
Li Jie
d91bb33178 runtime: fix time.Sleep 2025-02-16 19:25:59 +08:00
Li Jie
d8e782f3f1 cl: fix wrong global variable type patching 2025-02-16 12:53:42 +08:00
xushiwei
51755b8da3 Merge pull request #998 from visualfc/goexit
runtime: support Goexit
2025-02-16 08:52:10 +08:00
xushiwei
e5c0aed75e Merge pull request #997 from cpunion/fix-release
Fix release build
2025-02-16 08:44:48 +08:00
visualfc
6d7e984238 runtime: support Goexit 2025-02-16 08:24:33 +08:00
Li Jie
4dcc944f53 ci: lock tonistiigi/binfmt:qemu-v7.0.0-28 to avoid binfmt crash 2025-02-15 19:31:01 +08:00
Li Jie
fbb978e8a5 ci: populate linux sysroot in parallel 2025-02-15 19:30:32 +08:00
Li Jie
46a3a4f7e3 ci: disable populate cache 2025-02-15 19:30:07 +08:00
xushiwei
e74d2b45c0 Merge pull request #996 from xushiwei/q
qiniu/x v1.13.12
2025-02-15 18:45:00 +08:00
xushiwei
d40298ac58 qiniu/x v1.13.12 2025-02-15 18:30:57 +08:00
xushiwei
87d7a4862e Merge pull request #978 from visualfc/llruntime
runtime: config hasAltPkg and overlay
2025-02-15 15:26:50 +08:00
visualfc
8be9a560e9 runtime: rm ignoreName 2025-02-15 14:56:59 +08:00
visualfc
0d218bb4b9 runtime: config overlay 2025-02-15 13:25:25 +08:00
visualfc
1b3464b610 runtime: config hasAltPkg and ignoreName 2025-02-15 13:22:28 +08:00
xushiwei
c4e66a104b Merge pull request #994 from xushiwei/q
README: Key modules move into compiler directory
2025-02-15 13:20:19 +08:00
xushiwei
d4eaef6ac8 README: Key modules move into compiler directory 2025-02-15 13:19:38 +08:00
xushiwei
9a634b22a7 Merge pull request #991 from cpunion/update-doc
doc: update install instructions
2025-02-15 12:02:45 +08:00
xushiwei
54f5f38637 Merge pull request #946 from cpunion/testing
llgo test
2025-02-15 12:01:49 +08:00
Li Jie
21a5180b2f cl: regenerate test snapshots 2025-02-15 11:18:03 +08:00
Li Jie
8116d34a60 runtime: runtime.Callers, runtime.CallersFrames 2025-02-15 11:18:03 +08:00
Li Jie
c6462cbcc7 ssa: fix type assertion of same type 2025-02-15 11:18:03 +08:00
Li Jie
4e34ce7470 runtime: fix incorrect function signature 2025-02-15 11:18:03 +08:00
Li Jie
c2299818cd compiler: fix llgo build test 2025-02-14 19:02:35 +08:00
Li Jie
2d06dc5cfe demo: call println, c.Printf, fmt.Println 2025-02-14 19:02:35 +08:00
Li Jie
5329f28580 runtime: testing runtime 2025-02-14 19:02:32 +08:00
Li Jie
66909b3000 ci: continue on error 2025-02-14 15:56:19 +08:00
Li Jie
ae92904e7d ssa: show type assertion failed details 2025-02-14 15:56:19 +08:00
Li Jie
70fb5ec7e1 ci: replace setup-go with custom action to avoid cache error and test pre-release go 2025-02-14 15:56:19 +08:00
Li Jie
058f74c12c deps: add libuv into system deps 2025-02-14 15:56:18 +08:00
Li Jie
3a2d24d7cc doc: update doc test for installation instructions 2025-02-13 16:16:25 +08:00
Li Jie
49f2f0dbfd doc: update install instructions 2025-02-13 15:52:11 +08:00
Li Jie
5b216153e9 cl: LLGO_TRACE 2025-02-13 15:47:53 +08:00
Li Jie
43175bb642 build: supports LLGoFiles in patches 2025-02-13 15:47:53 +08:00
Li Jie
c1da220a99 ssa: toType(ssa.TypeParam) 2025-02-13 15:47:53 +08:00
Li Jie
164c3e0e7b cl: fix null pointer in processing debug location 2025-02-13 15:47:52 +08:00
Li Jie
491a23b21e cl: don't ignore standard libraries 2025-02-13 15:47:52 +08:00
Li Jie
727ec8a5cf build: weak syscall.init for syscall imported but not compiled 2025-02-13 15:47:52 +08:00
Li Jie
28b3ec322c build: show cgo compile errors 2025-02-13 15:47:52 +08:00
Li Jie
38cb89a946 build: show full link errors 2025-02-13 15:47:52 +08:00
Li Jie
b07116f302 build: patch packages supports cgo 2025-02-13 15:47:15 +08:00
Li Jie
623b5a511a cl: process llgo:skip on const, type declaration, deprecate llgo:skip on import 2025-02-13 15:47:15 +08:00
Li Jie
d5d2d6826f build: patch package with ID 2025-02-13 15:47:14 +08:00
Li Jie
227f6a4ed7 build: update go/parser/resolve.go (compatible go 1.23) 2025-02-13 15:47:14 +08:00
Li Jie
e23d7082fe build: overlay testing/testing.go for defer in loop 2025-02-13 15:47:14 +08:00
Li Jie
569a29454e build: run llgo test 2025-02-13 15:47:14 +08:00
Li Jie
a07f711e22 build: only limit run command to single package 2025-02-13 15:47:13 +08:00
Li Jie
946f304bb2 compiler: add go test command 2025-02-13 15:47:13 +08:00
Li Jie
6b11c100ba cl: process all go directives 2025-02-13 15:47:13 +08:00
Li Jie
6048693423 ssa: remove unused funcs 2025-02-13 15:47:13 +08:00
Li Jie
a7287754be compiler: remove unused func llgoRuntimeImported 2025-02-13 15:47:13 +08:00
Li Jie
d9037a7fce build: remove generated code after link 2025-02-13 15:47:12 +08:00
Li Jie
f06d292382 test: regenerate test files with gentests 2025-02-13 15:47:12 +08:00
Li Jie
85d01d6f28 compiler: make main function normally to compatible multiple main functions in testing mode 2025-02-13 15:47:12 +08:00
xushiwei
5cfeddef73 Merge pull request #988 from visualfc/reflect_typeof
runtime/internal/lib/reflect: fix TypeOf check nil
2025-02-13 15:20:24 +08:00
xushiwei
b975e77a63 Merge pull request #990 from cpunion/install-and-devel
Install and devel scripts
2025-02-13 15:19:52 +08:00
Li Jie
ba46181365 add llgo.sh for ease development 2025-02-13 13:46:44 +08:00
Li Jie
370604f8eb add install.sh for local and remote installation 2025-02-13 13:34:45 +08:00
visualfc
368c7d6cda runtime/internal/lib/reflect: fix TypeOf check closure 2025-02-13 10:28:36 +08:00
xushiwei
0a9dfdc5c0 Merge pull request #986 from goplus/dependabot/go_modules/compiler/github.com/goplus/mod-0.13.17
build(deps): bump github.com/goplus/mod from 0.13.16 to 0.13.17 in /compiler
2025-02-12 17:28:06 +08:00
dependabot[bot]
72d0d4e274 build(deps): bump github.com/goplus/mod in /compiler
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.13.16 to 0.13.17.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.13.16...v0.13.17)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-11 00:29:06 +00:00
xushiwei
d0067ccf68 Merge pull request #981 from visualfc/reflectlite
runtime/internal/lib/reflectlite: implement func
2025-02-10 13:55:16 +08:00
xushiwei
409793cb21 Merge pull request #980 from cpunion/fix-env-injection
build: fix goreleaser env injection
2025-02-10 13:52:16 +08:00
xushiwei
a9eb65926f Merge pull request #984 from goplus/dependabot/go_modules/compiler/github.com/qiniu/x-1.13.12
build(deps): bump github.com/qiniu/x from 1.13.11 to 1.13.12 in /compiler
2025-02-10 13:51:08 +08:00
dependabot[bot]
18d8677fe6 build(deps): bump github.com/qiniu/x in /compiler
Bumps [github.com/qiniu/x](https://github.com/qiniu/x) from 1.13.11 to 1.13.12.
- [Release notes](https://github.com/qiniu/x/releases)
- [Commits](https://github.com/qiniu/x/compare/v1.13.11...v1.13.12)

---
updated-dependencies:
- dependency-name: github.com/qiniu/x
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 00:46:38 +00:00
visualfc
09c8567e39 runtime/internal/lib/reflectlite: implement func 2025-02-07 12:04:54 +08:00
Li Jie
6bbd4b214a build: fix goreleaser env injection 2025-02-07 09:58:23 +08:00
xushiwei
a345746cbd Merge pull request #979 from luoliwoshang/clang/presume
c/clang:presume location
2025-02-06 17:00:32 +08:00
luoliwoshang
0a0bb128d6 c/clang:presume location 2025-02-06 16:37:07 +08:00
xushiwei
29ec3014e7 Merge pull request #911 from visualfc/reflect.conv
internal/lib/reflect: convertOp
2025-02-05 20:12:51 +08:00
visualfc
9ddd4d4161 compiler/cl/_testgo: reflectconv 2025-02-05 16:13:29 +08:00
visualfc
3caae31374 internal/runtime: pointer set abi.KindDirectIface 2025-02-05 15:20:20 +08:00
visualfc
b69abd1058 internal/runtime: find type 2025-02-05 15:20:20 +08:00
visualfc
114c6bd6fc internal/lib/reflect: fix call method 2025-02-05 15:20:20 +08:00
visualfc
d81c5e750d internal/runtime: impl ifaceE2I 2025-02-05 15:20:20 +08:00
visualfc
281d29a100 internal/lib/reflect: DeepEqual 2025-02-05 15:20:20 +08:00
visualfc
46492009a1 internal/lib/reflect: specialChannelAssignability 2025-02-05 15:20:20 +08:00
visualfc
ec549a6a25 internal/lib/reflect: value.convert check func 2025-02-05 15:20:20 +08:00
visualfc
71766d9c55 ssa/abi: StructName not pub 2025-02-05 15:20:20 +08:00
visualfc
d2d8bd550a internal/lib/reflect: fix Int/Uint/Float flagIndir 2025-02-05 15:20:20 +08:00
visualfc
0c2f6c46f6 internal/runtime: newPointer set KindDirectIface 2025-02-05 15:20:20 +08:00
visualfc
c90b93c1b7 internal/lib/reflect: convertOp 2025-02-05 15:20:20 +08:00
xushiwei
faef4fffab Merge pull request #977 from visualfc/test_debug
compiler/ssa: test debug check verbose
2025-02-05 12:19:52 +08:00
visualfc
8e8b97f623 compiler/ssa: test debug check verbose 2025-02-05 10:07:55 +08:00
xushiwei
e23d18dab8 Merge pull request #976 from visualfc/ci
ci: go test remove -v
2025-02-05 09:50:21 +08:00
visualfc
3a0d1466cc ci: go test remove -v 2025-02-05 09:32:42 +08:00
xushiwei
83dd77f4c4 Merge pull request #974 from cpunion/fix-doc-links
Fix doc links
2025-02-04 14:53:32 +08:00
xushiwei
c601c992c1 Merge pull request #975 from visualfc/namedslice
compiler/cl: fix named slice type
2025-02-04 14:52:46 +08:00
visualfc
5727761551 compiler/cl: fix named slice type 2025-02-03 20:13:57 +08:00
Li Jie
08365721de test: increase test times to try to avoid clang error 2025-02-03 18:47:24 +08:00
Li Jie
692c3542d9 doc: update links 2025-02-03 18:26:41 +08:00
Li Jie
60dc1f7d75 ci: verify markdown links by lychee 2025-02-03 18:26:16 +08:00
xushiwei
e5ff33fcc6 Merge pull request #969 from cpunion/find-llgo-root
test: retry failed test to avoid clang error
2025-02-01 21:54:50 +08:00
xushiwei
c60979fff7 Merge pull request #970 from xushiwei/q
README: C/C++, ObjC, Swift
2025-02-01 21:10:38 +08:00
xushiwei
961ad6ebca README: C/C++, ObjC, Swift 2025-02-01 21:00:01 +08:00
Li Jie
f18237a005 test: retry llgo test to avoid clang error 2025-02-01 20:56:55 +08:00
xushiwei
cba93e61b4 Merge pull request #960 from visualfc/instnamed
ssa: abi.NamedName for instance named
2025-02-01 19:23:25 +08:00
xushiwei
e0a6e5d2f9 Merge pull request #968 from cpunion/find-llgo-root
Find llgo root
2025-02-01 19:01:34 +08:00
Li Jie
a9ee323760 test: disable log and output to speed up testing 2025-02-01 14:11:46 +08:00
Li Jie
977db86700 env: warning and fallback if LLGO_ROOT is invalid 2025-02-01 14:11:46 +08:00
Li Jie
93d36d40d8 env: fix version 2025-02-01 14:11:46 +08:00
Li Jie
cabc7ffca8 env: find llgo root for development 2025-02-01 14:11:46 +08:00
Li Jie
521b70c715 test: llgo clean, llgo cmptest, llgo cmptest -gen 2025-02-01 14:11:46 +08:00
Li Jie
b6c5503c5b test: chore/llgen 2025-02-01 14:11:46 +08:00
Li Jie
e7e2ba4790 test: test llgo run -v 2025-02-01 14:11:45 +08:00
Li Jie
8749923f1a test: make cmd testable 2025-02-01 14:11:45 +08:00
Li Jie
25a3e19384 ci: update codecov ignore config 2025-02-01 14:11:40 +08:00
visualfc
b6b686665a compiler/cl: inst named stable sort 2025-02-01 13:52:10 +08:00
visualfc
4f5468469b compiler/cl/_testgo: add tpinst 2025-02-01 12:28:09 +08:00
visualfc
7bc7f23125 ssa: abi.NamedName for instance named 2025-02-01 10:29:35 +08:00
xushiwei
25ed652fc0 Merge pull request #966 from visualfc/reflect_go123
runtime: fix reflect type for go1.23
2025-02-01 03:39:45 +08:00
xushiwei
cc2913352a Merge pull request #955 from visualfc/conv
ssa: fix cvtType check types.Alias
2025-01-30 11:59:35 +08:00
visualfc
ad796ebbec compiler: fix build go1.22 for GODEBUG=gotypesalias=1 2025-01-29 19:07:37 +08:00
visualfc
edd561f8ba runtime: fix reflect type for go1.23 2025-01-29 18:58:36 +08:00
xushiwei
0b1c4fb54f Merge pull request #964 from goplus/dependabot/go_modules/compiler/github.com/goplus/gogen-1.16.6
build(deps): bump github.com/goplus/gogen from 1.16.5 to 1.16.6 in /compiler
2025-01-23 13:44:19 +08:00
dependabot[bot]
9f4eb4f7db build(deps): bump github.com/goplus/gogen in /compiler
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.5 to 1.16.6.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.5...v1.16.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-22 01:15:38 +00:00
xushiwei
f6e3a3917e Merge pull request #959 from luoliwoshang/sys/ExecInChild
syscall(linux): forkAndExecInChild
2025-01-21 07:30:48 +08:00
luoliwoshang
1b536bf5f8 syscall(linux):use clone as go instead fork 2025-01-20 08:30:02 +00:00
xushiwei
e3afdb6c02 Merge pull request #962 from cpunion/fix-abi
fix(ssa): fix incorrectly ABI for uninstantiated generic methods
2025-01-18 23:55:27 +08:00
Li Jie
918b36e28f fix(ssa): fix incorrectly generated ABI for uninstantiated generic methods 2025-01-17 20:36:04 +08:00
luoliwoshang
ce26637410 demo:command run 2025-01-17 08:30:07 +00:00
luoliwoshang
2053c72008 c/os:dup3 2025-01-16 11:00:18 +00:00
luoliwoshang
275bde6461 syscall(linux): forkAndExecInChild 2025-01-16 10:59:38 +00:00
luoliwoshang
f85382edd4 c/syscall: zsysnum 2025-01-14 14:09:52 +00:00
xushiwei
e016e92c41 Merge pull request #949 from goplus/dependabot/go_modules/compiler/github.com/goplus/gogen-1.16.5
build(deps): bump github.com/goplus/gogen from 1.16.4 to 1.16.5 in /compiler
2025-01-13 19:48:20 +08:00
dependabot[bot]
2594b8e3f9 build(deps): bump github.com/goplus/gogen in /compiler
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.4 to 1.16.5.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.4...v1.16.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-13 11:08:50 +00:00
xushiwei
1e1ef594c8 Merge pull request #951 from xushiwei/q
xtool/clang: disable types
2025-01-13 19:08:05 +08:00
xushiwei
01c660faba Merge pull request #952 from goplus/dependabot/go_modules/compiler/github.com/goplus/mod-0.13.16
build(deps): bump github.com/goplus/mod from 0.13.15 to 0.13.16 in /compiler
2025-01-13 19:07:35 +08:00
visualfc
9f76237705 ssa: fix cvtType check types.Alias 2025-01-13 12:38:15 +08:00
dependabot[bot]
59d3e3f3da build(deps): bump github.com/goplus/mod in /compiler
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.13.15 to 0.13.16.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.13.15...v0.13.16)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-13 01:05:42 +00:00
xushiwei
e5dd237f12 xtool/clang: disable types 2025-01-13 09:05:19 +08:00
xushiwei
e9729bea7e Merge pull request #945 from goplus/dependabot/go_modules/compiler/github.com/goplus/mod-0.13.15
build(deps): bump github.com/goplus/mod from 0.13.13 to 0.13.15 in /compiler
2025-01-12 09:11:46 +08:00
dependabot[bot]
d46b17d8a0 build(deps): bump github.com/goplus/mod in /compiler
Bumps [github.com/goplus/mod](https://github.com/goplus/mod) from 0.13.13 to 0.13.15.
- [Release notes](https://github.com/goplus/mod/releases)
- [Commits](https://github.com/goplus/mod/compare/v0.13.13...v0.13.15)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-11 19:36:26 +00:00
xushiwei
383d25226e Update dependabot.yml 2025-01-12 03:35:27 +08:00
xushiwei
745eff0783 Merge pull request #943 from goplus/dependabot/github_actions/actions/cache-4
build(deps): bump actions/cache from 3 to 4
2025-01-10 09:59:23 +08:00
dependabot[bot]
ac301045b9 build(deps): bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-10 00:58:56 +00:00
xushiwei
e1f3ca8172 Merge pull request #929 from cpunion/go123
Separate compiler, runtime and llgo library
2025-01-09 20:13:35 +08:00
Li Jie
4ff4ceeb22 ssa: show detail message of runtime failed 2025-01-09 19:50:01 +08:00
Li Jie
4126992a8f compiler: remove completed todo 2025-01-09 19:39:12 +08:00
Li Jie
fd99f63bd6 ci: hello world testing with different version declarations in go.mod and go versions 2025-01-09 18:55:22 +08:00
Li Jie
46dc7c3a77 test: increase test coverage 2025-01-09 18:55:22 +08:00
Li Jie
a8cb551465 env: add tests for codecov 2025-01-09 18:55:21 +08:00
Li Jie
5a5674809c ssa: Builder.TypeName processes types.Alias 2025-01-09 16:59:51 +08:00
Li Jie
761e8a2ac6 compiler: make compiler working on go 1.23 project 2025-01-09 16:11:39 +08:00
Li Jie
dfa7effa14 ci: config release build 2025-01-09 15:39:03 +08:00
Li Jie
09c022e209 cmd: fix return value with arguments 2025-01-09 15:32:27 +08:00
Li Jie
8666a75161 ci: remove unused python libraries installation step 2025-01-09 11:58:24 +08:00
Li Jie
68018d8d04 runtime: clean demo 2025-01-09 09:05:45 +08:00
Li Jie
3d2c014801 cl: clean test 2025-01-09 00:47:45 +08:00
Li Jie
4f9c341103 ci: update codecov ignore 2025-01-09 00:23:30 +08:00
Li Jie
563f03554f test: llgo commands 2025-01-09 00:09:47 +08:00
Li Jie
219376044a ci: fix llgo workflow name 2025-01-08 23:23:58 +08:00
Li Jie
591dac8b41 compiler: remove unused packages 2025-01-08 23:02:46 +08:00
Li Jie
2bc96ade33 lldb: test lldb cross go compilers 2025-01-08 22:16:03 +08:00
Li Jie
95c4456ccc env: get GOROOT from env variable or go env GOROOT 2025-01-08 22:16:03 +08:00
Li Jie
6e6b8b404f runtime: rename clite conflicts function names 2025-01-08 22:16:02 +08:00
Li Jie
27052c21be ci: test lldb last 2025-01-08 22:16:02 +08:00
Li Jie
ec744f7385 chore: move compiler/chore/_xtool to _xtool 2025-01-08 22:16:02 +08:00
Li Jie
d8c5105c91 ci: set LLGO_ROOT for doc test 2025-01-08 22:16:01 +08:00
Li Jie
acd5fb19f5 ci: rename llgo test job name 2025-01-08 15:55:38 +08:00
Li Jie
52ac486814 doc: fix llgo installation 2025-01-08 15:40:11 +08:00
Li Jie
a64b32bf9c ci: compile go with go1.23, test llgo with go 1.20-1.23 2025-01-08 15:36:41 +08:00
Li Jie
b299800e64 compiler: move _lldb into compiler/ 2025-01-08 15:22:09 +08:00
Li Jie
60c430abad test: regenerate test snapshots with gentests 2025-01-08 15:19:38 +08:00
Li Jie
255cce4f9a test: move cchan/cchansel into runtime/_test 2025-01-08 15:03:58 +08:00
Li Jie
1ed99c2574 cl: isAny compatible alias 2025-01-08 14:59:02 +08:00
Li Jie
64b54d4380 ssa: make alias working in go 1.22 2025-01-08 14:59:02 +08:00
Li Jie
6170973b48 compiler: build separation runtime with clite 2025-01-08 14:59:01 +08:00
Li Jie
1172e5bdce build: separate compiler and libs 2025-01-08 14:59:01 +08:00
Li Jie
b0123567cd ci: ignore code coverage of llgo libs 2025-01-08 14:59:00 +08:00
Li Jie
81598621e8 ci: codecov report excludes llgo library 2025-01-08 14:59:00 +08:00
Li Jie
239ac496b2 test: map/slice clear 2025-01-08 14:59:00 +08:00
Li Jie
76fb91619a demo: workaround for reflect abi initialization on go@1.23 2025-01-08 14:58:59 +08:00
Li Jie
e3a2d43ffa runtime: add missing SliceClear 2025-01-08 14:58:59 +08:00
Li Jie
b3f4716616 runtime: patch internal/filepathlite 2025-01-08 14:58:59 +08:00
Li Jie
c602038597 demo: don't use symlinks for x/tools compatible 2025-01-08 14:58:59 +08:00
Li Jie
03b469212e feat: upgrade to x/tools 0.28 2025-01-08 14:58:59 +08:00
xushiwei
db3f6e077e Merge pull request #941 from cpunion/fix-doc-verify
doc: fix macos installation doc verify
2025-01-08 08:58:31 +08:00
Li Jie
06816c51a5 doc: fix macos installation doc verify 2025-01-07 21:28:14 +08:00
xushiwei
9e9e8e82b2 Merge pull request #936 from cpunion/optional-llgo-root
build: make llgo root usage optional for runtime loading
2025-01-07 19:47:40 +08:00
xushiwei
031d4ebedc Merge pull request #937 from MeteorsLiu/main
README: fix dependences requirement for macOS
2025-01-07 18:40:03 +08:00
xushiwei
3446715af8 Merge pull request #934 from cpunion/fix-build
build.ParseArgs returns new slices to fix wrong patterns with flags appending
2025-01-07 18:07:13 +08:00
Rick Guo
c7e68dab62 README: fix dependences for macOS 2025-01-06 17:38:36 +08:00
Li Jie
7093ced2d8 build: make llgo root usage optional for runtime loading
When github.com/goplus/llgo is imported in go.mod, use the user-specified
version instead of LLGoROOT. This allows users to upgrade llgo via go.mod
while maintaining backward compatibility for cases without explicit imports.

Note: This is a temporary solution. The runtime's dependency on
github.com/goplus/llgo/c/* needs to be addressed in future improvements.
2025-01-06 16:36:16 +08:00
Li Jie
179f4dfe22 build: ParseArgs return new slices 2025-01-06 10:10:11 +08:00
xushiwei
03517ce22e Merge pull request #933 from cpunion/independent
env: allow compiling code outside llgo directory
2025-01-05 07:10:29 +08:00
Li Jie
290f99b4d1 env: allow compiling code outside llgo directory 2025-01-04 23:40:13 +08:00
xushiwei
7f10bc2a1b Merge pull request #930 from cpunion/panic-stacktrace
runtime: show stacktrace when panic
2025-01-03 12:04:12 +08:00
Li Jie
9cb48003b0 ci: add libunwind-dev on ubuntu 2025-01-02 23:27:45 +08:00
Li Jie
6df961292d doc: install libunwind-dev on ubuntu 2025-01-02 23:27:45 +08:00
Li Jie
65f855b251 runtime: show stacktrace when panic 2025-01-02 23:27:41 +08:00
xushiwei
5131881bf2 Merge pull request #928 from goplus/dependabot/go_modules/github.com/goplus/llvm-0.8.1
build(deps): bump github.com/goplus/llvm from 0.8.0 to 0.8.1
2024-12-31 19:19:16 +08:00
dependabot[bot]
8fbad90e9d build(deps): bump github.com/goplus/llvm from 0.8.0 to 0.8.1
Bumps [github.com/goplus/llvm](https://github.com/goplus/llvm) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/goplus/llvm/releases)
- [Commits](https://github.com/goplus/llvm/compare/v0.8.0...v0.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-31 11:06:15 +00:00
xushiwei
d0aceebaad Merge pull request #926 from goplus/dependabot/go_modules/github.com/goplus/gogen-1.16.4
build(deps): bump github.com/goplus/gogen from 1.16.3 to 1.16.4
2024-12-31 13:57:06 +08:00
dependabot[bot]
01b6680000 build(deps): bump github.com/goplus/gogen from 1.16.3 to 1.16.4
Bumps [github.com/goplus/gogen](https://github.com/goplus/gogen) from 1.16.3 to 1.16.4.
- [Release notes](https://github.com/goplus/gogen/releases)
- [Commits](https://github.com/goplus/gogen/compare/v1.16.3...v1.16.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-31 05:40:12 +00:00
2492 changed files with 452753 additions and 84654 deletions

72
.github/actions/setup-deps/action.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: "Setup LLGO Dependencies"
description: "Install all required dependencies for LLGO"
inputs:
llvm-version:
description: "LLVM version to install"
required: true
default: "19"
install-llvm:
description: "Whether to install LLVM"
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Install macOS dependencies
if: runner.os == 'macOS'
shell: bash
run: |
brew update
# Install LLVM if requested
if [[ "${{ inputs.install-llvm }}" == "true" ]]; then
brew install llvm@${{inputs.llvm-version}} lld@${{inputs.llvm-version}}
brew link --overwrite llvm@${{inputs.llvm-version}} lld@${{inputs.llvm-version}}
echo "$(brew --prefix llvm@${{inputs.llvm-version}})/bin" >> $GITHUB_PATH
fi
# Install common dependencies
brew install bdw-gc openssl libffi libuv
brew link --overwrite libffi
# Install optional deps for demos.
#
# NOTE: Keep this list updated as new deps are introduced.
opt_deps=(
cjson # for github.com/goplus/lib/c/cjson
sqlite # for github.com/goplus/lib/c/sqlite
)
brew install "${opt_deps[@]}"
brew install python@3.12 || true # for github.com/goplus/lib/py
brew link --overwrite python@3.12
- name: Install Ubuntu dependencies
if: runner.os == 'Linux'
shell: bash
run: |
# Install LLVM if requested
if [[ "${{ inputs.install-llvm }}" == "true" ]]; then
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm-version}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y llvm-${{inputs.llvm-version}}-dev clang-${{inputs.llvm-version}} libclang-${{inputs.llvm-version}}-dev lld-${{inputs.llvm-version}} libunwind-${{inputs.llvm-version}}-dev libc++-${{inputs.llvm-version}}-dev
echo "PATH=/usr/lib/llvm-${{inputs.llvm-version}}/bin:$PATH" >> $GITHUB_ENV
else
sudo apt-get update
fi
# Install common dependencies
sudo apt-get install -y pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libuv1-dev
# Install optional deps for demos.
#
# NOTE: Keep this list updated as new deps are introduced.
opt_deps=(
libcjson-dev # for github.com/goplus/lib/c/cjson
libsqlite3-dev # for github.com/goplus/lib/c/sqlite
python3.12-dev # for github.com/goplus/lib/py
)
sudo apt-get install -y "${opt_deps[@]}"

51
.github/actions/setup-go/action.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: "Setup Go"
description: "Setup Go environment by downloading and extracting from go.dev"
inputs:
go-version:
description: "The Go version to download and use"
required: true
runs:
using: "composite"
steps:
- name: Download and setup Go
shell: bash
run: |
set -e
GO_VERSION="${{ inputs.go-version }}"
GO_VERSION="${GO_VERSION#go}" # Remove 'go' prefix if present
# Determine OS and architecture
if [[ "$RUNNER_OS" == "macOS" ]]; then
OS="darwin"
ARCH="arm64"
else
OS="linux"
ARCH="amd64"
fi
DOWNLOAD_URL="https://go.dev/dl/go${GO_VERSION}.${OS}-${ARCH}.tar.gz"
echo "Downloading Go from: ${DOWNLOAD_URL}"
# Create temporary directory for download
TMP_DIR=$(mktemp -d)
curl -L "${DOWNLOAD_URL}" -o "${TMP_DIR}/go.tar.gz"
# Remove existing Go installation if any
sudo rm -rf /usr/local/go
# Extract to /usr/local
sudo tar -C /usr/local -xzf "${TMP_DIR}/go.tar.gz"
# Clean up
rm -rf "${TMP_DIR}"
# Add to PATH
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: Verify Go installation
shell: bash
run: |
# Verify installation
echo "Verifying Go installation..."
go version

View File

@@ -0,0 +1,28 @@
name: "Setup GoReleaser"
description: "Setup GoReleaser environment"
inputs:
linux-cache-key:
description: "Linux sysroot cache key"
required: true
runs:
using: "composite"
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.x
- name: Restore Linux sysroot cache
id: cache-linux-sysroot
uses: actions/cache/restore@v4
with:
path: .sysroot/linux.tar.gz
key: ${{ inputs.linux-cache-key }}
- name: Populate Linux sysroot
run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot
shell: bash
- name: Check file
run: tree .sysroot
shell: bash
- name: Get Esp clang
run: bash .github/workflows/download_esp_clang.sh
shell: bash

View File

@@ -0,0 +1,63 @@
name: "Test Hello World"
description: "Test Hello World with specific Go and module versions"
inputs:
go-version:
description: "Go version being tested"
required: true
mod-version:
description: "Go module version to use"
required: true
runs:
using: "composite"
steps:
- name: Test Hello World
shell: bash
run: |
echo "Testing with Go ${{ inputs.go-version }} and go.mod ${{ inputs.mod-version }}"
mkdir -p _test/helloworld && cd _test/helloworld
cat > go.mod << 'EOL'
module hello
go ${{ inputs.mod-version }}
EOL
cat > main.go << 'EOL'
package main
import (
"fmt"
"github.com/goplus/lib/c"
"github.com/goplus/lib/cpp/std"
)
func main() {
fmt.Println("Hello, LLGo!")
println("Hello, LLGo!")
c.Printf(c.Str("Hello, LLGo!\n"))
c.Printf(std.Str("Hello LLGo by cpp/std.Str\n").CStr())
}
EOL
go mod tidy
EXPECTED="Hello, LLGo!
Hello, LLGo!
Hello, LLGo!
Hello LLGo by cpp/std.Str"
OUTPUT=$(llgo run . 2>&1 | tee /dev/stderr)
if echo "$OUTPUT" | grep -qF "$EXPECTED"; then
echo "Basic test passed"
else
echo "Basic test failed"
echo "Expected to contain:"
echo "$EXPECTED"
echo "Got:"
echo "$OUTPUT"
exit 1
fi
cd ../..
mkdir -p _test/emb && cd _test/emb
cat > main.go << 'EOL'
package main
func main() {
}
EOL
llgo build -v -target esp32-coreboard-v2 -o demo.out .
test -f demo.out.elf && echo "ESP32 cross-compilation test passed: demo.out.elf generated"
exit $?

15
.github/codecov.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
coverage:
ignore:
- "chore"
- "cmd"
- "cl/cltest"
- "internal/build"
- "internal/llgen"
- "internal/mockable"
- "internal/packages"
- "internal/typepatch"
- "internal/github"
- "internal/firmware"
- "internal/flash"
- "internal/monitor"
- "xtool"

View File

@@ -2,41 +2,57 @@ name: Docs
on:
push:
branches: [ "**" ]
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: [ "**" ]
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
doc_verify:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '20'
node-version: "20"
- name: Install embedme
run: npm install -g embedme
- name: Verify README.md embedded code
run: npx embedme --verify README.md
run: embedme --verify README.md
doc_test:
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: --max-concurrency 3 --retry-wait-time 15 README.md
remote_install:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-24.04
- ubuntu-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
uses: ./.github/actions/setup-go
with:
go-version: '1.20'
go-version: "1.24.2"
- name: Install dependencies on macOS
if: startsWith(matrix.os, 'macos')
@@ -52,7 +68,44 @@ jobs:
set -x
source doc/_readme/scripts/install_ubuntu.sh
- name: Install llgo
- name: Test doc code blocks
run: |
set -e
set -x
source doc/_readme/scripts/run.sh
local_install:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.23"
- name: Install dependencies on macOS
if: startsWith(matrix.os, 'macos')
run: |
set -e
set -x
source doc/_readme/scripts/install_macos.sh
- name: Install dependencies on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
set -e
set -x
source doc/_readme/scripts/install_ubuntu.sh
- name: Install llgo with tools
run: |
set -e
set -x
@@ -65,6 +118,7 @@ jobs:
fi
}
source doc/_readme/scripts/install_llgo.sh
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Test doc code blocks
run: |
@@ -72,3 +126,55 @@ jobs:
set -x
source doc/_readme/scripts/run.sh
local_install_full:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.23"
- name: Install dependencies on macOS
if: startsWith(matrix.os, 'macos')
run: |
set -e
set -x
source doc/_readme/scripts/install_macos.sh
- name: Install dependencies on Ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
set -e
set -x
source doc/_readme/scripts/install_ubuntu.sh
echo "PATH=/usr/lib/llvm-19/bin:$PATH" >> $GITHUB_ENV
- name: Install llgo with tools
run: |
set -e
set -x
git() {
if [ "$1" = "clone" ]; then
# do nothing because we already have the branch
cd ..
else
command git "$@"
fi
}
source doc/_readme/scripts/install_full.sh
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Test doc code blocks
run: |
set -e
set -x
source doc/_readme/scripts/run.sh

67
.github/workflows/download_esp_clang.sh vendored Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/bash
set -e
ESP_CLANG_VERSION="19.1.2_20250905-3"
BASE_URL="https://github.com/goplus/espressif-llvm-project-prebuilt/releases/download/${ESP_CLANG_VERSION}"
get_esp_clang_platform() {
local platform="$1"
local os="${platform%-*}"
local arch="${platform##*-}"
case "${os}" in
"darwin")
case "${arch}" in
"amd64") echo "x86_64-apple-darwin" ;;
"arm64") echo "aarch64-apple-darwin" ;;
*) echo "Error: Unsupported darwin architecture: ${arch}" >&2; exit 1 ;;
esac
;;
"linux")
case "${arch}" in
"amd64") echo "x86_64-linux-gnu" ;;
"arm64") echo "aarch64-linux-gnu" ;;
*) echo "Error: Unsupported linux architecture: ${arch}" >&2; exit 1 ;;
esac
;;
*)
echo "Error: Unsupported OS: ${os}" >&2
exit 1
;;
esac
}
get_filename() {
local platform="$1"
local platform_suffix=$(get_esp_clang_platform "${platform}")
echo "clang-esp-${ESP_CLANG_VERSION}-${platform_suffix}.tar.xz"
}
download_and_extract() {
local platform="$1"
local os="${platform%-*}"
local arch="${platform##*-}"
local filename=$(get_filename "${platform}")
local download_url="${BASE_URL}/${filename}"
echo "Downloading ESP Clang for ${platform}..."
echo " URL: ${download_url}"
mkdir -p ".sysroot/${os}/${arch}/crosscompile/clang"
curl -fsSL "${download_url}" | tar -xJ -C ".sysroot/${os}/${arch}/crosscompile/clang" --strip-components=1
if [[ ! -f ".sysroot/${os}/${arch}/crosscompile/clang/bin/clang++" ]]; then
echo "Error: clang++ not found in ${platform} toolchain"
exit 1
fi
echo "${platform} ESP Clang ready in .sysroot/${os}/${arch}/crosscompile/clang"
}
echo "Downloading ESP Clang toolchain version ${ESP_CLANG_VERSION}..."
for platform in "darwin-amd64" "darwin-arm64" "linux-amd64" "linux-arm64"; do
download_and_extract "${platform}"
done
echo "ESP Clang toolchain completed successfully!"

38
.github/workflows/fmt.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Format Check
on:
push:
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
fmt:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Check formatting
run: |
for dir in . runtime; do
pushd $dir
if [ -n "$(go fmt ./... | grep -v xgo_autogen.go)" ]; then
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
exit 1
fi
popd
done
echo "All files are properly formatted."

View File

@@ -5,84 +5,34 @@ name: Go
on:
push:
branches: [ "**" ]
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: [ "**" ]
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Check formatting
run: |
if [ -n "$(go fmt ./...)" ]; then
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
exit 1
fi
test:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-24.04
llvm: [18]
- ubuntu-latest
llvm: [19]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Install dependencies
if: startsWith(matrix.os, 'macos')
run: |
brew update
brew install llvm@${{matrix.llvm}} bdw-gc openssl libffi
brew link --force libffi
echo "$(brew --prefix llvm@${{matrix.llvm}})/bin" >> $GITHUB_PATH
# Install optional deps for demos.
#
# NOTE: Keep this list updated as new deps are introduced.
opt_deps=(
cjson # for github.com/goplus/llgo/c/cjson
sqlite # for github.com/goplus/llgo/c/sqlite
python@3.12 # for github.com/goplus/llgo/py
)
brew install "${opt_deps[@]}"
- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{matrix.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y llvm-${{matrix.llvm}}-dev clang-${{matrix.llvm}} libclang-${{matrix.llvm}}-dev lld-${{matrix.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev
echo "/usr/lib/llvm-${{matrix.llvm}}/bin" >> $GITHUB_PATH
# Install optional deps for demos.
#
# NOTE: Keep this list updated as new deps are introduced.
opt_deps=(
libcjson-dev # for github.com/goplus/llgo/c/cjson
libsqlite3-dev # for github.com/goplus/llgo/c/sqlite
python3.12-dev # for github.com/goplus/llgo/py
)
sudo apt-get install -y "${opt_deps[@]}"
- name: Install further optional dependencies for demos
run: |
wget -P ./_demo/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin
py_deps=(
numpy # for github.com/goplus/llgo/py/numpy
torch # for github.com/goplus/llgo/py/torch
)
pip3.12 install --break-system-packages "${py_deps[@]}"
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Clang information
run: |
@@ -91,66 +41,22 @@ jobs:
clang --version
- name: Set up Go
uses: actions/setup-go@v5
uses: ./.github/actions/setup-go
with:
go-version: '1.20'
go-version: "1.24.2"
- name: Build
run: go build -v ./...
- name: Install
run: go install ./...
- name: Test
if: ${{!startsWith(matrix.os, 'macos')}}
run: go test -v ./...
run: go test ./...
- name: Test with coverage
if: startsWith(matrix.os, 'macos')
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...
- name: LLGO tests
if: ${{!startsWith(matrix.os, 'ubuntu')}}
run: |
echo "Test result on ${{matrix.os}} with LLVM ${{matrix.llvm}}" > result.md
bash .github/workflows/test_llgo.sh
- name: chore/_xtool build tests
run: |
cd chore/_xtool
llgo build -v ./...
- name: LLDB tests
if: ${{startsWith(matrix.os, 'macos')}}
run: |
echo "Test lldb with llgo plugin on ${{matrix.os}} with LLVM ${{matrix.llvm}}"
bash _lldb/runtest.sh -v
- name: Test demos
run: |
# TODO(lijie): force python3-embed to be linked with python-3.12-embed
# Currently, python3-embed is python-3.13-embed, doesn't work with pytorch
# Will remove this after pytorch is fixed.
pcdir=$HOME/pc
mkdir -p $pcdir
libdir=$(pkg-config --variable=libdir python-3.12-embed)
echo "libdir: $libdir"
ln -s $libdir/pkgconfig/python-3.12-embed.pc $pcdir/python3-embed.pc
export PKG_CONFIG_PATH=$pcdir
bash .github/workflows/test_demo.sh
- name: Show test result
run: cat result.md
- name: PR comment with test result
uses: thollander/actions-comment-pull-request@v3
if: false
with:
filePath: result.md
comment_tag: test-result-on-${{matrix.os}}-with-llvm-${{matrix.llvm}}
run: go test -coverprofile="coverage.txt" -covermode=atomic ./...
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{secrets.CODECOV_TOKEN}}
slug: goplus/llgo

300
.github/workflows/llgo.yml vendored Normal file
View File

@@ -0,0 +1,300 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: LLGo
on:
push:
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
download-model:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Download model file
run: |
mkdir -p ./_demo/c/llama2-c
wget -P ./_demo/c/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin
- name: Upload model as artifact
uses: actions/upload-artifact@v4
with:
name: llama2-model
path: ./_demo/c/llama2-c/stories15M.bin
retention-days: 1
llgo:
needs: download-model
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
llvm: [19]
go: ["1.21.13", "1.22.12", "1.23.6", "1.24.2"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Download model artifact
uses: actions/download-artifact@v5
with:
name: llama2-model
path: ./_demo/c/llama2-c/
- name: Download platform-specific demo libs
run: |
if ${{ startsWith(matrix.os, 'macos') }}; then
DEMO_PKG="cargs_darwin_arm64.zip"
else
DEMO_PKG="cargs_linux_amd64.zip"
fi
mkdir -p ./_demo/c/cargs/libs
cd ./_demo/c/cargs/libs
wget https://github.com/goplus/llpkg/releases/download/cargs/v1.0.0/${DEMO_PKG}
unzip ${DEMO_PKG}
# Process pc template files - replace {{.Prefix}} with actual path
ACTUAL_PREFIX="$(pwd)"
for tmpl in lib/pkgconfig/*.pc.tmpl; do
pc_file="${tmpl%.tmpl}"
sed "s|{{.Prefix}}|${ACTUAL_PREFIX}|g" "$tmpl" > "$pc_file"
done
echo "PKG_CONFIG_PATH=${ACTUAL_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}" >> $GITHUB_ENV
- name: Install further optional dependencies for demos
run: |
py_deps=(
numpy # for github.com/goplus/lib/py/numpy
torch # for github.com/goplus/lib/py/torch
)
pip3.12 install --break-system-packages "${py_deps[@]}"
- name: Set up Go for build
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: actions/setup-go@v6
with:
go-version: ${{matrix.go}}
- name: Test demo without RPATH (expect failure)
run: |
echo "Testing demo without RPATH (should fail)..."
export LLGO_FULL_RPATH=false
pkg-config --libs cargs
if (cd ./_demo/c/cargs && llgo run .); then
echo "ERROR: cargs demo should have failed without RPATH!"
exit 1
else
echo "✓ cargs demo correctly failed without RPATH"
fi
- name: Test demos
run: |
# TODO(lijie): force python3-embed to be linked with python-3.12-embed
# Currently, python3-embed is python-3.13-embed, doesn't work with pytorch
# Will remove this after pytorch is fixed.
pcdir=$HOME/pc
mkdir -p $pcdir
libdir=$(pkg-config --variable=libdir python-3.12-embed)
echo "libdir: $libdir"
ln -s $libdir/pkgconfig/python-3.12-embed.pc $pcdir/python3-embed.pc
export PKG_CONFIG_PATH=$pcdir:${PKG_CONFIG_PATH}
export LLGO_FULL_RPATH=true
bash .github/workflows/test_demo.sh
- name: Test C header generation
run: |
echo "Testing C header generation in different build modes..."
cd _demo/go/export
chmod +x test.sh
./test.sh
- name: _xtool build tests
run: |
cd _xtool
llgo build -v ./...
- name: Show test result
run: cat result.md
- name: LLDB tests
if: ${{startsWith(matrix.os, 'macos')}}
run: |
echo "Test lldb with llgo plugin on ${{matrix.os}} with LLVM ${{matrix.llvm}}"
bash _lldb/runtest.sh -v
test:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
llvm: [19]
go: ["1.24.2"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Install further optional dependencies for demos
run: |
py_deps=(
numpy # for github.com/goplus/lib/py/numpy
torch # for github.com/goplus/lib/py/torch
)
pip3.12 install --break-system-packages "${py_deps[@]}"
- name: Set up Go for build
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: actions/setup-go@v6
with:
go-version: ${{matrix.go}}
- name: run llgo test
run: |
llgo test ./...
hello:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
llvm: [19]
go: ["1.21.13", "1.22.12", "1.23.6", "1.24.2"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Set up Go 1.23 for building llgo
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install llgo
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Set up Go for testing
uses: ./.github/actions/setup-go
with:
go-version: ${{matrix.go}}
- name: Test Hello World with go.mod 1.21
if: startsWith(matrix.go, '1.21') || startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.21"
- name: Test Hello World with go.mod 1.22
if: startsWith(matrix.go, '1.22') || startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.22"
- name: Test Hello World with go.mod 1.23
if: startsWith(matrix.go, '1.23') || startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.23"
- name: Test Hello World with go.mod 1.24
if: startsWith(matrix.go, '1.24')
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go}}
mod-version: "1.24"
cross-compile:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os: [macos-latest]
llvm: [19]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Set up Go for building llgo
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install wamr
run: |
git clone https://github.com/bytecodealliance/wasm-micro-runtime.git
mkdir wasm-micro-runtime/product-mini/platforms/darwin/build
cd wasm-micro-runtime/product-mini/platforms/darwin/build
cmake -D WAMR_BUILD_EXCE_HANDLING=1 -D WAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_SHARED_MEMORY=1 -DWAMR_BUILD_LIB_WASI_THREADS=1 -DWAMR_BUILD_LIB_PTHREAD=1 -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DEBUG_INTERP=1 ..
make -j8
echo "$PWD" >> $GITHUB_PATH
- name: Install llgo
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Test Cross Compilation (wasm)
shell: bash
working-directory: _demo/c
run: |
echo "Testing cross-compilation wasm with Go 1.24.2"
# Compile for wasm architecture
GOOS=wasip1 GOARCH=wasm llgo build -o hello -tags=nogc -v ./helloc
# Check file type
file hello.wasm
# Run the wasm binary using llgo_wasm
iwasm --stack-size=819200000 --heap-size=800000000 hello.wasm

View File

@@ -1,40 +0,0 @@
#!/bin/bash
set -e
TMPDIR="$(mktemp -d)"
export TMPDIR
trap 'rm -rf "${TMPDIR}"' EXIT
DARWIN_AMD64_LLVM_PREFIX=.sysroot/darwin/amd64/usr/local/opt/llvm@18
DARWIN_ARM64_LLVM_PREFIX=.sysroot/darwin/arm64/opt/homebrew/opt/llvm@18
mkdir -p "${DARWIN_AMD64_LLVM_PREFIX}" "${DARWIN_ARM64_LLVM_PREFIX}"
BREW_LLVM_FORMULA_JSON="$(mktemp)"
curl -fsSL https://formulae.brew.sh/api/formula/llvm@18.json > "${BREW_LLVM_FORMULA_JSON}"
BREW_LLVM_AMD64_BOTTLE_URL=$(jq -r '.bottle.stable.files.sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
BREW_LLVM_ARM64_BOTTLE_URL=$(jq -r '.bottle.stable.files.arm64_sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_AMD64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_AMD64_LLVM_PREFIX}"
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_ARM64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_ARM64_LLVM_PREFIX}"
patch_homebrew_lib_dir() {
local LIB_DIR="$1"
local HOMEBREW_PREFIX="$2"
for DYLIB_FILE in "${LIB_DIR}"/*.dylib; do
if [[ -f "${DYLIB_FILE}" ]]; then
ID=$(otool -D "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
if [[ -n "${ID}" ]]; then
NEW_ID=${ID/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
install_name_tool -id "${NEW_ID}" "${DYLIB_FILE}"
fi
DEPS=$(otool -L "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
for DEP in ${DEPS}; do
NEW_DEP=${DEP/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
install_name_tool -change "${DEP}" "${NEW_DEP}" "${DYLIB_FILE}"
done
fi
done
}
patch_homebrew_lib_dir "${DARWIN_AMD64_LLVM_PREFIX}/lib" /usr/lib
patch_homebrew_lib_dir "${DARWIN_ARM64_LLVM_PREFIX}/lib" /opt/homebrew

View File

@@ -17,12 +17,7 @@ cat > "${POPULATE_LINUX_SYSROOT_SCRIPT}" << EOF
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y lsb-release gnupg2 wget rsync
echo "deb http://apt.llvm.org/\$(lsb_release -cs)/ llvm-toolchain-\$(lsb_release -cs)-18 main" | tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
apt-get update
apt-get install -y llvm-18-dev
apt-get install -y build-essential zlib1g-dev rsync
error() {
echo -e "\$1" >&2
@@ -106,7 +101,6 @@ do-sync() {
args+=(-d)
args+=(-h)
args+=(--keep-dirlinks)
args+=("--info=progress2")
args+=(--delete)
args+=(--prune-empty-dirs)
args+=(--sparse)
@@ -139,5 +133,11 @@ populate_linux_sysroot() {
debian:bullseye \
/populate_linux_sysroot.sh
}
populate_linux_sysroot amd64 "${LINUX_AMD64_PREFIX}"
populate_linux_sysroot arm64 "${LINUX_ARM64_PREFIX}"
populate_linux_sysroot amd64 "${LINUX_AMD64_PREFIX}" &
PID1=$!
populate_linux_sysroot arm64 "${LINUX_ARM64_PREFIX}" &
PID2=$!
# Wait for both background processes to complete
wait $PID1 || exit $?
wait $PID2 || exit $?

View File

@@ -2,49 +2,73 @@ name: Release Build
on:
push:
tags:
- "*"
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
tags: ["*"]
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
populate-darwin-sysroot:
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Populate Darwin sysroot
run: bash .github/workflows/populate_darwin_sysroot.sh
- name: Create Darwin sysroot tarball
run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin
- name: Upload Darwin sysroot tarball
uses: actions/upload-artifact@v4
with:
name: darwin-sysroot-tarball
path: .sysroot/darwin.tar.gz
compression-level: 0
build:
setup:
runs-on: ubuntu-latest
needs: populate-darwin-sysroot
outputs:
linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }}
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Calculate cache keys
id: cache-keys
run: |
LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh', '.github/workflows/release-build.yml') }}-v1.0.0"
echo "linux-key=$LINUX_KEY" >> $GITHUB_OUTPUT
populate-linux-sysroot:
runs-on: ubuntu-latest
needs: setup
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Check Linux sysroot cache
id: cache-linux-sysroot
uses: actions/cache/restore@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.20.x
path: .sysroot/linux.tar.gz
key: ${{ needs.setup.outputs.linux-cache-key }}
lookup-only: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Download Darwin sysroot tarball
uses: actions/download-artifact@v4
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
with:
name: darwin-sysroot-tarball
path: .sysroot
- name: Populate Darwin sysroot
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
image: tonistiigi/binfmt:qemu-v7.0.0-28
- name: Populate Linux sysroot
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
run: bash .github/workflows/populate_linux_sysroot.sh
- name: Run GoReleaser
- name: Create Linux sysroot tarball
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
run: tar -czvf .sysroot/linux.tar.gz -C .sysroot linux
- name: Save Linux sysroot cache
if: steps.cache-linux-sysroot.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .sysroot/linux.tar.gz
key: ${{ needs.setup.outputs.linux-cache-key }}
build:
runs-on: ubuntu-latest
needs: [setup, populate-linux-sysroot]
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Set up Release
uses: ./.github/actions/setup-goreleaser
with:
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
- name: Run GoReleaser (Build & Test)
env:
GITHUB_TOKEN: ${{github.token}}
run: |
@@ -55,4 +79,129 @@ jobs:
-v $(pwd):/go/src/llgo \
-w /go/src/llgo \
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
release --clean --skip nfpm,snapcraft
release --verbose --skip=publish,nfpm,snapcraft --snapshot --clean
- name: Upload Darwin AMD64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-darwin-amd64
path: .dist/*darwin-amd64.tar.gz
retention-days: 3
include-hidden-files: true
- name: Upload Darwin ARM64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-darwin-arm64
path: .dist/*darwin-arm64.tar.gz
retention-days: 3
include-hidden-files: true
- name: Upload Linux AMD64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-linux-amd64
path: .dist/*linux-amd64.tar.gz
retention-days: 3
include-hidden-files: true
- name: Upload Linux ARM64 Artifacts
uses: actions/upload-artifact@v4
with:
name: llgo-linux-arm64
path: .dist/*linux-arm64.tar.gz
retention-days: 3
include-hidden-files: true
- name: Upload Checksums
uses: actions/upload-artifact@v4
with:
name: llgo-checksums
path: .dist/*checksums.txt
retention-days: 3
include-hidden-files: true
test-artifacts:
needs: build
strategy:
matrix:
include:
- os: macos-15-intel
goos: darwin
goarch: amd64
go-version: "1.24.2"
go-mod-version: "1.24"
- os: macos-latest
goos: darwin
goarch: arm64
go-version: "1.24.2"
go-mod-version: "1.24"
- os: ubuntu-latest
goos: linux
goarch: amd64
go-version: "1.24.2"
go-mod-version: "1.24"
- os: ubuntu-24.04-arm
goos: linux
goarch: arm64
go-version: "1.24.2"
go-mod-version: "1.24"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
install-llvm: false
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Download Platform Artifact
uses: actions/download-artifact@v5
with:
name: llgo-${{ matrix.goos }}-${{ matrix.goarch }}
path: .
- name: Extract LLGO Archive
run: |
echo "Looking for ${{ matrix.goos }}_${{ matrix.goarch }} archive..."
ARCHIVE=$(ls *.tar.gz | head -n1)
mkdir -p release-llgo
tar -xzf "$ARCHIVE" -C release-llgo
ls -la release-llgo/
echo "${{ github.workspace }}/release-llgo/bin/" >> $GITHUB_PATH
- name: Test Hello World
uses: ./.github/actions/test-helloworld
with:
go-version: ${{matrix.go-version}}
mod-version: ${{ matrix.go-mod-version }}
release:
needs: [setup, test-artifacts, populate-linux-sysroot]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Check out code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Release
uses: ./.github/actions/setup-goreleaser
with:
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
- name: Run GoReleaser (Release)
env:
GITHUB_TOKEN: ${{github.token}}
run: |
echo "Publishing release for tag: ${{ github.ref }}"
echo "All artifact tests passed, proceeding with release..."
docker run \
--rm \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd):/go/src/llgo \
-w /go/src/llgo \
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
release --clean --verbose --skip nfpm,snapcraft

48
.github/workflows/targets.yml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Targets
on:
push:
branches:
- "**"
- "!dependabot/**"
- "!xgopilot/**"
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
llgo:
continue-on-error: true
timeout-minutes: 30
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
llvm: [19]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: ./.github/actions/setup-deps
with:
llvm-version: ${{matrix.llvm}}
- name: Set up Go for build
uses: ./.github/actions/setup-go
with:
go-version: "1.24.2"
- name: Install
run: |
go install ./...
echo "LLGO_ROOT=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Build targets
run: |
cd _demo/embed/targetsbuild
bash build.sh

View File

@@ -1,11 +1,11 @@
#!/bin/bash
set -e
# llgo run subdirectories under _demo and _pydemo that contain *.go files
# llgo run subdirectories under _demo that contain *.go files
total=0
failed=0
failed_cases=""
for d in ./_demo/* ./_pydemo/*; do
for d in ./_demo/go/* ./_demo/py/* ./_demo/c/*; do
if [ -d "$d" ] && [ -n "$(ls "$d"/*.go 2>/dev/null)" ]; then
total=$((total+1))
echo "Testing $d"

View File

@@ -1,36 +0,0 @@
#!/bin/bash
set -e
testcmd=/tmp/test
llgo build -o $testcmd ./c/bdwgc/_test
cases=$($testcmd)
total=$(echo "$cases" | wc -l | tr -d ' ')
failed=0
failed_cases=""
for idx in $(seq 1 $((total))); do
case=$(echo "$cases" | sed -n "${idx}p")
case_name=$(echo "$case" | cut -d',' -f2)
echo "=== Test case: $case_name"
set +e
out=$("$testcmd" "$((idx-1))" 2>&1)
exit_code=$?
set -e
if [ "${exit_code:-0}" -ne 0 ]; then
echo "failed: $out"
failed=$((failed+1))
failed_cases="$failed_cases\n* :x: $case_name"
else
echo "passed"
fi
done
echo "=== Done"
echo "$((total-failed))/$total tests passed"
if [ "$failed" -ne 0 ]; then
echo ":bangbang: Failed llgo cases:" | tee -a result.md
echo -e "$failed_cases" | tee -a result.md
exit 1
else
echo ":white_check_mark: All llgo tests passed" | tee -a result.md
fi

11
.gitignore vendored
View File

@@ -7,6 +7,7 @@
*.dll
*.so
*.dylib
*.a
test.db
demo.ll
@@ -15,6 +16,7 @@ stories*.bin
.DS_Store
err.log
numpy.txt
result.txt
_go/
_runtime/
@@ -22,6 +24,7 @@ _tinygo/
_output/
build.dir/
.vscode/
.venv/
# Test binary, built with `go test -c`
*.test
@@ -42,3 +45,11 @@ go.work*
# GoReleaser
.dist/
.sysroot/
# Embedded firmware files
*.bin
*.hex
*.elf
*.uf2
*.img
*.zip

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "c/llama2/llama2.c"]
path = c/llama2/llama2.c
url = https://github.com/karpathy/llama2.c.git

View File

@@ -17,65 +17,69 @@ before:
builds:
- id: llgo-darwin-amd64
main: ./cmd/llgo
binary: bin/llgo
flags:
- -tags=darwin,amd64,byollvm
ldflags:
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/local/opt/llvm@18/bin/llvm-config
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
env:
- CC=o64-clang
- CXX=o64-clang++
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-18 -lz -lm
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_AMD64}}/crosscompile/clang/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_AMD64}}/crosscompile/clang/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm -Wl,-rpath,@executable_path/../crosscompile/clang/lib
targets:
- darwin_amd64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-darwin-arm64
main: ./cmd/llgo
binary: bin/llgo
flags:
- -tags=darwin,arm64,byollvm
ldflags:
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/opt/homebrew/opt/llvm@18/bin/llvm-config
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
env:
- CC=oa64-clang
- CXX=oa64-clang++
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@18/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@18/lib -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-18 -lz -lm
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_ARM64}}/crosscompile/clang/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_ARM64}}/crosscompile/clang/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm -Wl,-rpath,@executable_path/../crosscompile/clang/lib
targets:
- darwin_arm64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-linux-amd64
main: ./cmd/llgo
binary: bin/llgo
flags:
- -tags=linux,amd64,byollvm
ldflags:
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-18/bin/llvm-config
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -I{{.Env.SYSROOT_LINUX_AMD64}}/usr/include/llvm-18 -I{{.Env.SYSROOT_LINUX_AMD64}}/usr/include/llvm-c-18 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -L{{.Env.SYSROOT_LINUX_AMD64}}/usr/lib/llvm-18/lib -lLLVM-18
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -I{{.Env.SYSROOT_LINUX_AMD64}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -L{{.Env.SYSROOT_LINUX_AMD64}}/crosscompile/clang/lib -L{{.Env.SYSROOT_LINUX_AMD64}}/lib/x86_64-linux-gnu -lLLVM-19 -lz
- CGO_LDFLAGS_ALLOW=--sysroot.*
targets:
- linux_amd64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-linux-arm64
main: ./cmd/llgo
binary: bin/llgo
flags:
- -tags=linux,arm64,byollvm
ldflags:
- -X github.com/goplus/llgo/x/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/x/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-18/bin/llvm-config
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-18 -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-c-18 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -L{{.Env.SYSROOT_LINUX_ARM64}}/usr/lib/llvm-18/lib -lLLVM-18
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -I{{.Env.SYSROOT_LINUX_ARM64}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -L{{.Env.SYSROOT_LINUX_ARM64}}/crosscompile/clang/lib -L{{.Env.SYSROOT_LINUX_ARM64}}/lib/aarch64-linux-gnu -lLLVM-19 -lz
- CGO_LDFLAGS_ALLOW=--sysroot.*
targets:
- linux_arm64
mod_timestamp: "{{.CommitTimestamp}}"
@@ -88,7 +92,12 @@ archives:
files:
- LICENSE
- README.md
- runtime
- targets
- src: ".sysroot/{{.Os}}/{{.Arch}}/crosscompile/clang"
dst: crosscompile/clang
info:
mode: 0755
checksum:
name_template: "{{.ProjectName}}{{.Version}}.checksums.txt"
@@ -99,9 +108,9 @@ nfpms:
maintainer: Aofei Sheng <aofei@aofeisheng.com>
description: |
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a
subproject of the Go+ project.
subproject of the XGo project.
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
LLGo aims to expand the boundaries of Go/XGo, providing limitless possibilities such as:
- Game development
- AI and data science
@@ -123,9 +132,9 @@ snapcrafts:
summary: A Go compiler based on LLVM
description: |
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a
subproject of the Go+ project.
subproject of the XGo project.
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
LLGo aims to expand the boundaries of Go/XGo, providing limitless possibilities such as:
- Game development
- AI and data science

132
CLAUDE.md Normal file
View File

@@ -0,0 +1,132 @@
# LLGo Project AI Assistant Guide
This document provides essential information for AI assistants to help fix bugs and implement features in the LLGo project.
## About LLGo
LLGo is a Go compiler based on LLVM designed to better integrate Go with the C ecosystem, including Python and JavaScript. It's a subproject of the XGo project that aims to expand the boundaries of Go/XGo for game development, AI and data science, WebAssembly, and embedded development.
## Project Structure
- `cmd/llgo` - Main llgo compiler command (usage similar to `go` command)
- `cl/` - Core compiler logic that converts Go packages to LLVM IR
- `ssa/` - LLVM IR file generation using Go SSA semantics
- `internal/build/` - Build process orchestration
- `runtime/` - LLGo runtime library
- `chore/` - Development tools (llgen, llpyg, ssadump, etc.)
- `_demo/` - Example programs demonstrating C/C++ interop (`c/hello`, `c/qsort`) and Python integration (`py/callpy`, `py/numpy`)
- `_cmptest/` - Comparison tests to verify the same program gets the same output with Go and LLGo
## Development Environment
For detailed dependency requirements and installation instructions, see the [Dependencies](README.md#dependencies) and [How to install](README.md#how-to-install) sections in the README.
## Testing & Validation
The following commands and workflows are essential when fixing bugs or implementing features in the LLGo project:
### Run all tests
```bash
go test ./...
```
**Note:** Some tests may fail if optional dependencies (like Python) are not properly configured. The test suite includes comprehensive tests for:
- Compiler functionality
- SSA generation
- C interop
- Python integration (requires Python development headers)
### Write and run tests for your changes
When adding new functionality or fixing bugs, create appropriate test cases:
```bash
# Add your test to the relevant package's *_test.go file
# Then run tests for that package
go test ./path/to/package
# Or run all tests
go test ./...
```
**Important:** The `LLGO_ROOT` environment variable must be set to the repository root when running llgo commands during development.
## Code Quality
Before submitting any code updates, you must run the following formatting and validation commands:
### Format code
```bash
go fmt ./...
```
**Important:** Always run `go fmt ./...` before committing code changes. This ensures consistent code formatting across the project.
### Run static analysis
```bash
go vet ./...
```
**Note:** Currently reports some issues related to lock passing by value in `ssa/type_cvt.go` and a possible unsafe.Pointer misuse in `cl/builtin_test.go`. These are known issues.
## Common Development Tasks
### Build the entire project
```bash
go build -v ./...
```
### Build llgo command specifically
```bash
go build -o llgo ./cmd/llgo
```
### Check llgo version
```bash
llgo version
```
### Install llgo for system-wide use
```bash
./install.sh
```
### Build development tools
```bash
go install -v ./cmd/...
go install -v ./chore/...
```
## Key Modules for Understanding
- `ssa` - Generates LLVM IR using Go SSA semantics
- `cl` - Core compiler converting Go to LLVM IR
- `internal/build` - Orchestrates the compilation process
## Debugging
### Disable Garbage Collection
For testing purposes, you can disable GC:
```bash
LLGO_ROOT=/path/to/llgo llgo run -tags nogc .
```
## LLGO_ROOT Environment Variable
**CRITICAL:** Always set `LLGO_ROOT` to the repository root when running llgo during development:
```bash
export LLGO_ROOT=/path/to/llgo
# or
LLGO_ROOT=/path/to/llgo llgo run .
```
## Important Notes
1. **Testing Requirement:** All bug fixes and features MUST include tests
2. **Demo Directory:** Examples in `_demo` are prefixed with `_` to prevent standard `go` command from trying to compile them
3. **Defer in Loops:** LLGo intentionally does not support `defer` in loops (considered bad practice)
4. **C Ecosystem Integration:** LLGo uses `go:linkname` directive to link external symbols through ABI
5. **Python Integration:** Third-party Python libraries require separate installation of library files

201
README.md
View File

@@ -6,11 +6,11 @@ llgo - A Go compiler based on LLVM
[![GitHub release](https://img.shields.io/github/v/tag/goplus/llgo.svg?label=release)](https://github.com/goplus/llgo/releases)
[![Coverage Status](https://codecov.io/gh/goplus/llgo/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/llgo)
[![GoDoc](https://pkg.go.dev/badge/github.com/goplus/llgo.svg)](https://pkg.go.dev/github.com/goplus/llgo)
[![Language](https://img.shields.io/badge/language-Go+-blue.svg)](https://github.com/goplus/gop)
[![Language](https://img.shields.io/badge/language-XGo-blue.svg)](https://github.com/goplus/gop)
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python. It's a subproject of [the Go+ project](https://github.com/goplus/gop).
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python and JavaScript. It's a subproject of [the XGo project](https://github.com/goplus/gop).
LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities such as:
LLGo aims to expand the boundaries of Go/XGo, providing limitless possibilities such as:
* Game development
* AI and data science
@@ -21,29 +21,29 @@ LLGo aims to expand the boundaries of Go/Go+, providing limitless possibilities
How can these be achieved?
```
LLGo := Go + C + Python
LLGo := Go * C ecosystem
```
LLGo is compatible with C and Python through the language's **Application Binary Interface (ABI)**, while LLGo is compatible with Go through its **syntax (source code)**.
LLGo is compatible with C ecosystem through the language's **Application Binary Interface (ABI)**, while LLGo is compatible with Go through its **syntax (source code)**. C ecosystem includes all languages that are ABI compatible with C (eg. C/C++, Python, JavaScript, Objective-C, Swift, etc).
## C/C++ standard libary support
You can import a C/C++ standard library in LLGo!
* [c](https://pkg.go.dev/github.com/goplus/llgo/c)
* [c/syscall](https://pkg.go.dev/github.com/goplus/llgo/c/syscall)
* [c/sys](https://pkg.go.dev/github.com/goplus/llgo/c/sys)
* [c/os](https://pkg.go.dev/github.com/goplus/llgo/c/os)
* [c/math](https://pkg.go.dev/github.com/goplus/llgo/c/math)
* [c/math/cmplx](https://pkg.go.dev/github.com/goplus/llgo/c/math/cmplx)
* [c/math/rand](https://pkg.go.dev/github.com/goplus/llgo/c/math/rand)
* [c/pthread](https://pkg.go.dev/github.com/goplus/llgo/c/pthread)
* [c/pthread/sync](https://pkg.go.dev/github.com/goplus/llgo/c/pthread/sync)
* [c/sync/atomic](https://pkg.go.dev/github.com/goplus/llgo/c/sync/atomic)
* [c/time](https://pkg.go.dev/github.com/goplus/llgo/c/time)
* [c/net](https://pkg.go.dev/github.com/goplus/llgo/c/net)
* [cpp/std](https://pkg.go.dev/github.com/goplus/llgo/cpp/std)
* [c](https://pkg.go.dev/github.com/goplus/lib/c)
* [c/syscall](https://pkg.go.dev/github.com/goplus/lib/c/syscall)
* [c/sys](https://pkg.go.dev/github.com/goplus/lib/c/sys)
* [c/os](https://pkg.go.dev/github.com/goplus/lib/c/os)
* [c/math](https://pkg.go.dev/github.com/goplus/lib/c/math)
* [c/math/cmplx](https://pkg.go.dev/github.com/goplus/lib/c/math/cmplx)
* [c/math/rand](https://pkg.go.dev/github.com/goplus/lib/c/math/rand)
* [c/pthread](https://pkg.go.dev/github.com/goplus/lib/c/pthread)
* [c/pthread/sync](https://pkg.go.dev/github.com/goplus/lib/c/pthread/sync)
* [c/sync/atomic](https://pkg.go.dev/github.com/goplus/lib/c/sync/atomic)
* [c/time](https://pkg.go.dev/github.com/goplus/lib/c/time)
* [c/net](https://pkg.go.dev/github.com/goplus/lib/c/net)
* [cpp/std](https://pkg.go.dev/github.com/goplus/lib/cpp/std)
Here is a simple example:
@@ -52,7 +52,7 @@ Here is a simple example:
```go
package main
import "github.com/goplus/llgo/c"
import "github.com/goplus/lib/c"
func main() {
c.Printf(c.Str("Hello world\n"))
@@ -63,19 +63,19 @@ This is a simple example of calling the C `printf` function to print `Hello worl
The `_demo` directory contains some C standard libary related demos (it start with `_` to prevent the `go` command from compiling it):
* [hello](_demo/hello/hello.go): call C `printf` to print `Hello world`
* [concat](_demo/concat/concat.go): call C `fprintf` with `stderr`
* [qsort](_demo/qsort/qsort.go): call C function with a callback (eg. `qsort`)
* [hello](_demo/c/hello/hello.go): call C `printf` to print `Hello world`
* [concat](_demo/c/concat/concat.go): call C `fprintf` with `stderr`
* [qsort](_demo/c/qsort/qsort.go): call C function with a callback (eg. `qsort`)
To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)):
```sh
cd <demo-directory> # eg. cd _demo/hello
cd <demo-directory> # eg. cd _demo/c/hello
llgo run .
```
## How support C/C++ and Python
## How to support C/C++ and Python
LLGo use `go:linkname` to link an extern symbol througth its ABI:
@@ -88,7 +88,7 @@ import _ "unsafe" // for go:linkname
func Sqrt(x float64) float64
```
You can directly integrate it into [your own code](_demo/linkname/linkname.go):
You can directly integrate it into [your own code](_demo/c/linkname/linkname.go):
<!-- embedme doc/_readme/llgo_call_c/call_c.go -->
@@ -105,14 +105,14 @@ func main() {
}
```
Or put it into a package (see [c/math](c/math/math.go)):
Or put it into a package (see [c/math](https://github.com/goplus/lib/tree/main/c/math/math.go)):
<!-- embedme doc/_readme/llgo_call_cmath/call_cmath.go -->
```go
package main
import "github.com/goplus/llgo/c/math"
import "github.com/goplus/lib/c/math"
func main() {
println("sqrt(2) =", math.Sqrt(2))
@@ -126,18 +126,18 @@ You can import a Python library in LLGo!
And you can import any Python library into `llgo` through a program called `llpyg` (see [Development tools](#development-tools)). The following libraries have been included in `llgo`:
* [py](https://pkg.go.dev/github.com/goplus/llgo/py) (abi)
* [py/std](https://pkg.go.dev/github.com/goplus/llgo/py/std) (builtins)
* [py/sys](https://pkg.go.dev/github.com/goplus/llgo/py/sys)
* [py/os](https://pkg.go.dev/github.com/goplus/llgo/py/os)
* [py/math](https://pkg.go.dev/github.com/goplus/llgo/py/math)
* [py/json](https://pkg.go.dev/github.com/goplus/llgo/py/json)
* [py/inspect](https://pkg.go.dev/github.com/goplus/llgo/py/inspect)
* [py/statistics](https://pkg.go.dev/github.com/goplus/llgo/py/statistics)
* [py/numpy](https://pkg.go.dev/github.com/goplus/llgo/py/numpy)
* [py/pandas](https://pkg.go.dev/github.com/goplus/llgo/py/pandas)
* [py/torch](https://pkg.go.dev/github.com/goplus/llgo/py/torch)
* [py/matplotlib](https://pkg.go.dev/github.com/goplus/llgo/py/matplotlib)
* [py](https://pkg.go.dev/github.com/goplus/lib/py) (abi)
* [py/std](https://pkg.go.dev/github.com/goplus/lib/py/std) (builtins)
* [py/sys](https://pkg.go.dev/github.com/goplus/lib/py/sys)
* [py/os](https://pkg.go.dev/github.com/goplus/lib/py/os)
* [py/math](https://pkg.go.dev/github.com/goplus/lib/py/math)
* [py/json](https://pkg.go.dev/github.com/goplus/lib/py/json)
* [py/inspect](https://pkg.go.dev/github.com/goplus/lib/py/inspect)
* [py/statistics](https://pkg.go.dev/github.com/goplus/lib/py/statistics)
* [py/numpy](https://pkg.go.dev/github.com/goplus/lib/py/numpy)
* [py/pandas](https://pkg.go.dev/github.com/goplus/lib/py/pandas)
* [py/torch](https://pkg.go.dev/github.com/goplus/lib/py/torch)
* [py/matplotlib](https://pkg.go.dev/github.com/goplus/lib/py/matplotlib)
Note: For third-party libraries (such as pandas and pytorch), you still need to install the library files.
@@ -149,9 +149,9 @@ Here is an example:
package main
import (
"github.com/goplus/llgo/py"
"github.com/goplus/llgo/py/math"
"github.com/goplus/llgo/py/std"
"github.com/goplus/lib/py"
"github.com/goplus/lib/py/math"
"github.com/goplus/lib/py/std"
)
func main() {
@@ -181,9 +181,9 @@ Let's look at a slightly more complex example. For example, we use `numpy` to ca
package main
import (
"github.com/goplus/llgo/py"
"github.com/goplus/llgo/py/numpy"
"github.com/goplus/llgo/py/std"
"github.com/goplus/lib/py"
"github.com/goplus/lib/py/numpy"
"github.com/goplus/lib/py/std"
)
func main() {
@@ -204,17 +204,17 @@ func main() {
Here we define two 3x3 matrices a and b, add them to get x, and then print the result.
The `_pydemo` directory contains some python related demos:
The `_demo/py/` directory contains some python related demos:
* [callpy](_pydemo/callpy/callpy.go): call Python standard library function `math.sqrt`
* [pi](_pydemo/pi/pi.go): print python constants `math.pi`
* [statistics](_pydemo/statistics/statistics.go): define a python list and call `statistics.mean` to get the mean
* [matrix](_pydemo/matrix/matrix.go): a basic `numpy` demo
* [callpy](_demo/py/callpy/callpy.go): call Python standard library function `math.sqrt`
* [pi](_demo/py/pi/pi.go): print python constants `math.pi`
* [statistics](_demo/py/statistics/statistics.go): define a python list and call `statistics.mean` to get the mean
* [matrix](_demo/py/matrix/matrix.go): a basic `numpy` demo
To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)):
```sh
cd <demo-directory> # eg. cd _pydemo/callpy
cd <demo-directory> # eg. cd _demo/py/callpy
llgo run .
```
@@ -225,38 +225,38 @@ LLGo can easily import any libraries from the C ecosystem. Currently, this impor
The currently supported libraries include:
* [c/bdwgc](https://pkg.go.dev/github.com/goplus/llgo/c/bdwgc)
* [c/cjson](https://pkg.go.dev/github.com/goplus/llgo/c/cjson)
* [c/clang](https://pkg.go.dev/github.com/goplus/llgo/c/clang)
* [c/ffi](https://pkg.go.dev/github.com/goplus/llgo/c/ffi)
* [c/libuv](https://pkg.go.dev/github.com/goplus/llgo/c/libuv)
* [c/llama2](https://pkg.go.dev/github.com/goplus/llgo/c/llama2)
* [c/lua](https://pkg.go.dev/github.com/goplus/llgo/c/lua)
* [c/neco](https://pkg.go.dev/github.com/goplus/llgo/c/neco)
* [c/openssl](https://pkg.go.dev/github.com/goplus/llgo/c/openssl)
* [c/raylib](https://pkg.go.dev/github.com/goplus/llgo/c/raylib)
* [c/sqlite](https://pkg.go.dev/github.com/goplus/llgo/c/sqlite)
* [c/zlib](https://pkg.go.dev/github.com/goplus/llgo/c/zlib)
* [cpp/inih](https://pkg.go.dev/github.com/goplus/llgo/cpp/inih)
* [cpp/llvm](https://pkg.go.dev/github.com/goplus/llgo/cpp/llvm)
* [c/bdwgc](https://pkg.go.dev/github.com/goplus/lib/c/bdwgc)
* [c/cjson](https://pkg.go.dev/github.com/goplus/lib/c/cjson)
* [c/clang](https://pkg.go.dev/github.com/goplus/lib/c/clang)
* [c/ffi](https://pkg.go.dev/github.com/goplus/lib/c/ffi)
* [c/libuv](https://pkg.go.dev/github.com/goplus/lib/c/libuv)
* [c/llama2](https://pkg.go.dev/github.com/goplus/lib/c/llama2)
* [c/lua](https://pkg.go.dev/github.com/goplus/lib/c/lua)
* [c/neco](https://pkg.go.dev/github.com/goplus/lib/c/neco)
* [c/openssl](https://pkg.go.dev/github.com/goplus/lib/c/openssl)
* [c/raylib](https://pkg.go.dev/github.com/goplus/lib/c/raylib)
* [c/sqlite](https://pkg.go.dev/github.com/goplus/lib/c/sqlite)
* [c/zlib](https://pkg.go.dev/github.com/goplus/lib/c/zlib)
* [cpp/inih](https://pkg.go.dev/github.com/goplus/lib/cpp/inih)
* [cpp/llvm](https://pkg.go.dev/github.com/goplus/lib/cpp/llvm)
Here are some examples related to them:
* [llama2-c](_demo/llama2-c): inference Llama 2 (It's the first llgo AI example)
* [mkjson](c/cjson/_demo/mkjson/mkjson.go): create a json object and print it
* [sqlitedemo](c/sqlite/_demo/sqlitedemo/demo.go): a basic sqlite demo
* [tetris](c/raylib/_demo/tetris/tetris.go): a tetris game based on raylib
* [llama2-c](_demo/c/llama2-c): inference Llama 2 (It's the first llgo AI example)
* [mkjson](https://github.com/goplus/lib/tree/main/c/cjson/_demo/mkjson/mkjson.go): create a json object and print it
* [sqlitedemo](https://github.com/goplus/lib/tree/main/c/sqlite/_demo/sqlitedemo/demo.go): a basic sqlite demo
* [tetris](https://github.com/goplus/lib/tree/main/c/raylib/_demo/tetris/tetris.go): a tetris game based on raylib
## Go syntax support
All Go syntax (including `cgo`) is already supported. Here are some examples:
* [concat](_demo/concat/concat.go): define a variadic function
* [genints](_demo/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function)
* [concat](_demo/c/concat/concat.go): define a variadic function
* [genints](_demo/c/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function)
* [errors](_cmptest/errors/errors.go): demo to implement error interface
* [defer](_cmptest/defer/defer.go): defer demo
* [goroutine](_demo/goroutine/goroutine.go): goroutine demo
* [goroutine](_demo/go/goroutine/goroutine.go): goroutine demo
### Defer
@@ -323,6 +323,7 @@ Here are the Go packages that can be imported correctly:
* [hash/adler32](https://pkg.go.dev/hash/adler32)
* [hash/crc32](https://pkg.go.dev/hash/crc32) (partially)
* [hash/crc64](https://pkg.go.dev/hash/crc64)
* [hash/maphash](https://pkg.go.dev/hash/maphash) (partially)
* [crypto](https://pkg.go.dev/crypto)
* [crypto/md5](https://pkg.go.dev/crypto/md5)
* [crypto/sha1](https://pkg.go.dev/crypto/sha1)
@@ -335,11 +336,12 @@ Here are the Go packages that can be imported correctly:
* [regexp/syntax](https://pkg.go.dev/regexp/syntax)
* [go/token](https://pkg.go.dev/go/token)
* [go/scanner](https://pkg.go.dev/go/scanner)
* [go/parser](https://pkg.go.dev/go/parser)
## Dependencies
- [Go 1.20+](https://go.dev)
- [Go 1.21+](https://go.dev)
- [LLVM 18](https://llvm.org)
- [Clang 18](https://clang.llvm.org)
- [LLD 18](https://lld.llvm.org)
@@ -347,7 +349,7 @@ Here are the Go packages that can be imported correctly:
- [bdwgc/libgc 8.0+](https://www.hboehm.info/gc/)
- [OpenSSL 3.0+](https://www.openssl.org/)
- [zlib 1.2+](https://www.zlib.net)
- [Python 3.12+](https://www.python.org) (optional, for [github.com/goplus/llgo/py](https://pkg.go.dev/github.com/goplus/llgo/py))
- [Python 3.12+](https://www.python.org) (optional, for [github.com/goplus/lib/py](https://pkg.go.dev/github.com/goplus/lib/py))
## How to install
@@ -359,11 +361,11 @@ Follow these steps to generate the `llgo` command (its usage is the same as the
```sh
brew update
brew install llvm@18 bdw-gc openssl cjson libffi
brew install llvm@19 lld@19 bdw-gc openssl cjson libffi libuv pkg-config
brew install python@3.12 # optional
brew link --force libffi
go install -v github.com/goplus/llgo/cmd/llgo@latest
brew link --overwrite llvm@19 lld@19 libffi
# curl https://raw.githubusercontent.com/goplus/llgo/refs/heads/main/install.sh | bash
./install.sh
```
### on Linux
@@ -373,35 +375,52 @@ go install -v github.com/goplus/llgo/cmd/llgo@latest
<!-- embedme doc/_readme/scripts/install_ubuntu.sh#L2-L1000 -->
```sh
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-18 main" | sudo tee /etc/apt/sources.list.d/llvm.list
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-19 main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y llvm-18-dev clang-18 libclang-18-dev lld-18 pkg-config libgc-dev libssl-dev zlib1g-dev libcjson-dev libsqlite3-dev
sudo apt-get install -y llvm-19-dev clang-19 libclang-19-dev lld-19 libunwind-19-dev libc++-19-dev pkg-config libgc-dev libssl-dev zlib1g-dev libcjson-dev libsqlite3-dev libuv1-dev
sudo apt-get install -y python3.12-dev # optional
go install -v github.com/goplus/llgo/cmd/llgo@latest
#curl https://raw.githubusercontent.com/goplus/llgo/refs/heads/main/install.sh | bash
./install.sh
```
#### Alpine Linux
```sh
apk add go llvm18-dev clang18-dev lld18 pkgconf gc-dev openssl-dev zlib-dev
apk add go llvm19-dev clang19-dev lld19 pkgconf gc-dev libunwind-dev openssl-dev zlib-dev
apk add python3-dev # optional
apk add g++ # build only
export LLVM_CONFIG=/usr/lib/llvm18/bin/llvm-config
export LLVM_CONFIG=/usr/lib/llvm19/bin/llvm-config
export CGO_CPPFLAGS="$($LLVM_CONFIG --cppflags)"
export CGO_CXXFLAGS=-std=c++17
export CGO_LDFLAGS="$($LLVM_CONFIG --ldflags) $($LLVM_CONFIG --libs all)"
go install -v -tags=byollvm -ldflags="-X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=$LLVM_CONFIG" github.com/goplus/llgo/cmd/llgo@latest
curl https://raw.githubusercontent.com/goplus/llgo/refs/heads/main/install.sh | bash
```
docker alpine 386 llgo environment
```
export GCC_ROOT_DIR=$(gcc -print-search-dirs | grep 'install:' | awk -F': ' '{print $2}')
export LDFLAGS="-L$GCC_ROOT_DIR -B$GCC_ROOT_DIR -Wl,-dynamic-linker,/lib/ld-musl-i386.so.1"
llgo run .
```
### on Windows
TODO
### Install from source
<!-- embedme doc/_readme/scripts/install_llgo.sh#L2-L1000 -->
```sh
git clone https://github.com/goplus/llgo.git
cd llgo
./install.sh
```
## Development tools
* [pydump](chore/_xtool/pydump): It's the first program compiled by `llgo` (NOT `go`) in a production environment. It outputs symbol information (functions, variables, and constants) from a Python library in JSON format, preparing for the generation of corresponding packages in `llgo`.
* [pydump](_xtool/pydump): It's the first program compiled by `llgo` (NOT `go`) in a production environment. It outputs symbol information (functions, variables, and constants) from a Python library in JSON format, preparing for the generation of corresponding packages in `llgo`.
* [pysigfetch](https://github.com/goplus/hdq/tree/main/chore/pysigfetch): It generates symbol information by extracting information from Python's documentation site. This tool is not part of the `llgo` project, but we depend on it.
* [llpyg](chore/llpyg): It is used to automatically convert Python libraries into Go packages that `llgo` can import. It depends on `pydump` and `pysigfetch` to accomplish the task.
* [llgen](chore/llgen): It is used to compile Go packages into LLVM IR files (*.ll).
@@ -409,22 +428,24 @@ TODO
How do I generate these tools?
<!-- embedme doc/_readme/scripts/install_llgo.sh#L2-L1000 -->
<!-- embedme doc/_readme/scripts/install_full.sh#L2-L1000 -->
```sh
git clone https://github.com/goplus/llgo.git
cd llgo
go install -v ./cmd/...
go install -v ./chore/... # compile all tools except pydump
cd chore/_xtool
export LLGO_ROOT=$PWD
cd _xtool
llgo install ./... # compile pydump
go install github.com/goplus/hdq/chore/pysigfetch@v0.8.1 # compile pysigfetch
```
## Key modules
Below are the key modules for understanding the implementation principles of `llgo`:
* [llgo/ssa](https://pkg.go.dev/github.com/goplus/llgo/ssa): It generates LLVM IR files (LLVM SSA) using the semantics (interfaces) of Go SSA. Although `LLVM SSA` and `Go SSA` are both IR languages, they work at completely different levels. `LLVM SSA` is closer to machine code, which abstracts different instruction sets. While `Go SSA` is closer to a high-level language. We can think of it as the instruction set of the `Go computer`. `llgo/ssa` is not just limited to the `llgo` compiler. If we view it as the high-level expressive power of `LLVM`, you'll find it very useful. Prior to `llgo/ssa`, you had to operate `LLVM` using machine code semantics. But now, with the advanced SSA form (in the semantics of Go SSA), you can conveniently utilize `LLVM`.
* [llgo/cl](https://pkg.go.dev/github.com/goplus/llgo/cl): It is the core of the llgo compiler. It converts a Go package into LLVM IR files. It depends on `llgo/ssa`.
* [llgo/internal/build](https://pkg.go.dev/github.com/goplus/llgo/internal/build): It strings together the entire compilation process of `llgo`. It depends on `llgo/ssa` and `llgo/cl`.
* [ssa](https://pkg.go.dev/github.com/goplus/llgo/ssa): It generates LLVM IR files (LLVM SSA) using the semantics (interfaces) of Go SSA. Although `LLVM SSA` and `Go SSA` are both IR languages, they work at completely different levels. `LLVM SSA` is closer to machine code, which abstracts different instruction sets. While `Go SSA` is closer to a high-level language. We can think of it as the instruction set of the `Go computer`. `llgo/ssa` is not just limited to the `llgo` compiler. If we view it as the high-level expressive power of `LLVM`, you'll find it very useful. Prior to `llgo/ssa`, you had to operate `LLVM` using machine code semantics. But now, with the advanced SSA form (in the semantics of Go SSA), you can conveniently utilize `LLVM`.
* [cl](https://pkg.go.dev/github.com/goplus/llgo/cl): It is the core of the llgo compiler. It converts a Go package into LLVM IR files. It depends on `llgo/ssa`.
* [internal/build](https://pkg.go.dev/github.com/goplus/llgo/internal/build): It strings together the entire compilation process of `llgo`. It depends on `llgo/ssa` and `llgo/cl`.

View File

@@ -0,0 +1,33 @@
package main
import (
"fmt"
"go/constant"
"go/token"
)
func main() {
// Create the complex number 2.3 + 5i.
ar := constant.MakeFloat64(2.3)
ai := constant.MakeImag(constant.MakeInt64(5))
a := constant.BinaryOp(ar, token.ADD, ai)
// Compute (2.3 + 5i) * 11.
b := constant.MakeUint64(11)
c := constant.BinaryOp(a, token.MUL, b)
// Convert c into a complex128.
Ar, exact := constant.Float64Val(constant.Real(c))
if !exact {
fmt.Printf("Could not represent real part %s exactly as float64\n", constant.Real(c))
}
Ai, exact := constant.Float64Val(constant.Imag(c))
if !exact {
fmt.Printf("Could not represent imaginary part %s as exactly as float64\n", constant.Imag(c))
}
C := complex(Ar, Ai)
fmt.Println("literal", 25.3+55i)
fmt.Println("go/constant", c)
fmt.Println("complex128", C)
}

View File

@@ -0,0 +1,25 @@
package main
import (
"fmt"
"math/big"
)
func main() {
// Initialize two big ints with the first two numbers in the sequence.
a := big.NewInt(0)
b := big.NewInt(1)
// Initialize limit as 10^99, the smallest integer with 100 digits.
var limit big.Int
limit.Exp(big.NewInt(10), big.NewInt(99), nil)
// Loop while a is smaller than 1e100.
for a.Cmp(&limit) < 0 {
// Compute the next Fibonacci number, storing it in a.
a.Add(a, b)
// Swap a and b so that b is the next number in the sequence.
a, b = b, a
}
fmt.Println(a) // 100-digit Fibonacci number
}

View File

@@ -0,0 +1,18 @@
package main
import (
"fmt"
"time"
)
//llgo:link asm llgo.asm
func asm(instruction string) {}
func main() {
start := time.Now()
for i := 0; i < 100000; i++ {
asm("nop")
}
duration := time.Since(start)
fmt.Println("Duration:", duration)
}

View File

@@ -0,0 +1,21 @@
package main
import (
"fmt"
)
//llgo:link asmFull llgo.asm
func asmFull(instruction string, regs map[string]any) uintptr { return 0 }
var testVar = 0
func main() {
verify()
}
func check(expected, actual int) {
if expected != actual {
panic(fmt.Sprintf("Expected: %d, Got: %d\n", expected, actual))
}
fmt.Println("asm check passed:", actual)
}

View File

@@ -0,0 +1,31 @@
//go:build darwin && arm64
package main
import "unsafe"
func verify() {
// 0 output & 0 input
asmFull("nop", nil)
// 0 output & 1 input with memory address
addr := uintptr(unsafe.Pointer(&testVar))
asmFull("str {value}, [{addr}]", map[string]any{
"addr": addr,
"value": 43,
})
check(43, testVar)
// 1 output & 1 input
res1 := asmFull("mov {}, {value}", map[string]any{
"value": 41,
})
check(41, int(res1))
// 1 output & 2 inputs
res2 := asmFull("add {}, {a}, {b}", map[string]any{
"a": 25,
"b": 17,
})
check(42, int(res2))
}

View File

@@ -0,0 +1,30 @@
//go:build linux && amd64
package main
import "unsafe"
func verify() {
// 0 output & 0 input
asmFull("nop", nil)
// 0 output & 1 input with memory address
addr := uintptr(unsafe.Pointer(&testVar))
asmFull("movq {value}, ({addr})", map[string]any{
"addr": addr,
"value": 43,
})
check(43, testVar)
// 1 output & 1 input
res1 := asmFull("movq {value}, {}", map[string]any{
"value": 41,
})
check(41, int(res1))
res2 := asmFull("leaq ({a},{b}), {}", map[string]any{
"a": 25,
"b": 17,
})
check(42, int(res2))
}

395
_demo/c/cabi/main.go Normal file
View File

@@ -0,0 +1,395 @@
package main
import (
_ "unsafe"
)
const (
LLGoFiles = "wrap/wrap.c"
)
type point struct {
x int32
y int32
}
//go:linkname pt C.pt
func pt(pt point) point
type point1 struct {
x int32
y int32
z int32
}
//go:linkname pt1 C.pt1
func pt1(pt point1) point1
type point2 struct {
x int8
y int32
z int32
}
//go:linkname pt2 C.pt2
func pt2(pt point2) point2
type point3 struct {
x int8
y int8
z int8
}
//go:linkname pt3 C.pt3
func pt3(pt point3) point3
type point4 struct {
x int8
y int8
z int8
m int32
}
//go:linkname pt4 C.pt4
func pt4(pt point4) point4
type point5 struct {
x int8
y int8
z int8
m int8
n int8
}
//go:linkname pt5 C.pt5
func pt5(pt point5) point5
type point6 struct {
x int8
y int8
z int8
m int8
n int8
k int32
}
//go:linkname pt6 C.pt6
func pt6(pt point6) point6
type point7 struct {
x int8
y int8
z int8
m int8
n int8
k int32
o int8
}
//go:linkname pt7 C.pt7
func pt7(pt point7) point7
type data1 struct {
x int8
y int64
}
//go:linkname fn1 C.fn1
func fn1(data1) data1
type data2 struct {
x int32
y int64
}
//go:linkname fn2 C.fn2
func fn2(data2) data2
type data3 struct {
x int64
y int8
}
//go:linkname fn3 C.fn3
func fn3(data3) data3
type fdata1 struct {
x float32
}
//go:linkname ff1 C.ff1
func ff1(fdata1) fdata1
type fdata2 struct {
x float32
y float32
}
//go:linkname ff2 C.ff2
func ff2(fdata2) fdata2
type fdata2i struct {
x float32
y int32
}
//go:linkname ff2i C.ff2i
func ff2i(fdata2i) fdata2i
type fdata3 struct {
x float32
y float32
z float32
}
//go:linkname ff3 C.ff3
func ff3(fdata3) fdata3
type fdata4 struct {
x float32
y float32
z float32
m float32
}
//go:linkname ff4 C.ff4
func ff4(fdata4) fdata4
type fdata5 struct {
x float32
y float32
z float32
m float32
n float32
}
//go:linkname ff5 C.ff5
func ff5(fdata5) fdata5
type fdata2id struct {
x int8
y int8
z float64
}
//go:linkname ff2id C.ff2id
func ff2id(fdata2id) fdata2id
type fdata7if struct {
x [7]int8
y float32
}
//go:linkname ff7if C.ff7if
func ff7if(fdata7if) fdata7if
type fdata4if struct {
x float32
y int8
z float32
m float32
}
//go:linkname ff4if C.ff4if
func ff4if(fdata4if) fdata4if
type array struct {
x [8]int32
}
//go:linkname demo64 C.demo64
func demo64(n int64) int64
//go:linkname demo32 C.demo32
func demo32(n int32) int32
type struct32 struct {
v int32
}
//go:linkname demo32s C.demo32s
func demo32s(v struct32) struct32
type point64 struct {
x int64
y int64
}
//go:linkname pt64 C.pt64
func pt64(pt point64) point64
//go:linkname demo C.demo
func demo(a array) array
//go:linkname demo2 C.demo2
func demo2(x int32) array
type ddata1 struct {
x float64
}
//go:linkname dd1 C.dd1
func dd1(d ddata1) ddata1
type ddata2 struct {
x float64
y float64
}
//go:linkname dd2 C.dd2
func dd2(d ddata2) ddata2
type ddata3 struct {
x float64
y float64
z float64
}
//go:linkname dd3 C.dd3
func dd3(d ddata3) ddata3
//llgo:type C
type Callback func(array, point, point1) array
//go:linkname callback C.callback
func callback(fn Callback, ar array)
//llgo:type C
type Callback1 func(array, point, point1) point
//go:linkname callback1 C.callback1
func callback1(fn Callback1, ar array)
//go:linkname mycallback C.mycallback
func mycallback(ar array, pt point, pt1 point1) point
func myfn1(ar array, pt point, pt1 point1) point {
println("=>", ar.x[0], ar.x[1], ar.x[7], pt.x, pt.y, pt1.x, pt1.y, pt1.z)
return point{100, 200}
}
//export export_demo
func export_demo(ar array) array {
println("=> export", ar.x[0], ar.x[1], ar.x[7])
return ar
}
func main() {
cabi_demo()
callback_demo()
}
func callback_demo() {
export_demo(array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}})
callback(func(ar array, pt point, pt1 point1) array {
println("=> callback", ar.x[0], ar.x[1], ar.x[7], pt.x, pt.y, pt1.x, pt1.y, pt1.z)
return array{x: [8]int32{8, 7, 6, 5, 4, 3, 2, 1}}
}, array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}})
callback1(func(ar array, pt point, pt1 point1) point {
println("=> callback1", ar.x[0], ar.x[1], ar.x[7], pt.x, pt.y, pt1.x, pt1.y, pt1.z)
return point{100, 200}
}, array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}})
ret := mycallback(array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}}, point{1, 2}, point1{1, 2, 3})
println("=> mycallback", ret.x, ret.y)
callback1(myfn1, array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}})
callback1(myfn1, array{x: [8]int32{8, 7, 6, 5, 4, 3, 2, 1}})
callback1(mycallback, array{x: [8]int32{10, 20, 30, 40, 50, 60, 70, 80}})
}
func cabi_demo() {
i32 := demo32(1024)
println("=> demo32", i32)
s32 := demo32s(struct32{100})
println("=> demo32s", s32.v)
i64 := demo64(1024)
println("=> demo64", i64)
p64 := pt64(point64{1024, -1024})
println("=> pt64", p64.x, p64.y)
r := demo(array{x: [8]int32{1, 2, 3, 4, 5, 6, 7, 8}})
println("=> demo", r.x[0], r.x[1])
r2 := demo2(100)
println("=> demo2", r2.x[0], r2.x[1], r2.x[7])
p0 := pt(point{1, 2})
println("=> pt0", p0.x, p0.y)
p1 := pt1(point1{1, 2, 3})
println("=> pt1", p1.x, p1.y, p1.z)
p2 := pt2(point2{1, 2, 3})
println("=> pt2", p2.x, p2.y, p2.z)
p3 := pt3(point3{1, 2, 3})
println("=> pt3", p3.x, p3.y, p3.z)
p4 := pt4(point4{1, 2, 3, 4})
println("=> pt4", p4.x, p4.y, p4.z, p4.m)
p5 := pt5(point5{1, 2, 3, 4, 5})
println("=> pt5", p5.x, p5.y, p5.z, p5.m, p5.n)
p6 := pt6(point6{1, 2, 3, 4, 5, 6})
println("=> pt6", p6.x, p6.y, p6.z, p6.m, p6.n, p6.k)
p7 := pt7(point7{1, 2, 3, 4, 5, 6, 7})
println("=> pt7", p7.x, p7.y, p7.z, p7.m, p7.n, p7.k, p7.o)
// skip wrap
fd1 := fn1(data1{1, 2})
println("=> fd1", fd1.x, fd1.y)
fd2 := fn2(data2{1, 2})
println("=> fd2", fd2.x, fd2.y)
fd3 := fn3(data3{1, 2})
println("=> fd3", fd3.x, fd3.y)
// float
f1 := ff1(fdata1{1.1})
println("=> f1", f1.x)
// float
f2 := ff2(fdata2{1.1, 2.1})
println("=> f2", f2.x, f2.y)
// float
f2i := ff2i(fdata2i{1.1, 2})
println("=> f2i", f2i.x, f2i.y)
// float
f3 := ff3(fdata3{1.1, 2.1, 3.1})
println("=> f3", f3.x, f3.y, f3.z)
// float
f4 := ff4(fdata4{1.1, 2.1, 3.1, 4.1})
println("=> f4", f4.x, f4.y, f4.z, f4.m)
// float
f5 := ff5(fdata5{1.1, 2.1, 3.1, 4.1, 5.1})
println("=> f5", f5.x, f5.y, f5.z, f5.m, f5.n)
f2id := ff2id(fdata2id{1, 2, 3.1})
println("=> f2id", f2id.x, f2id.y, f2id.z)
f7if := ff7if(fdata7if{[7]int8{1, 2, 3, 4, 5, 6, 7}, 3.1})
println("=> f7if", f7if.x[0], f7if.x[1], f7if.y)
f4if := ff4if(fdata4if{1.1, 2, 3.1, 4.1})
println("=> f4if", f4if.x, f4if.y, f4if.z, f4if.m)
d1 := dd1(ddata1{1.1})
println("=> dd1", d1.x)
d2 := dd2(ddata2{1.1, 2.1})
println("=> dd2", d2.x, d2.y)
d3 := dd3(ddata3{1.1, 2.1, 3.1})
println("=> dd3", d3.x, d3.y, d3.z)
}

325
_demo/c/cabi/wrap/wrap.c Normal file
View File

@@ -0,0 +1,325 @@
extern int printf(const char *format, ...);
int demo32(int v) {
return v+100;
}
long long demo64(long long v) {
return v+100;
}
struct struct32 {
int v;
};
struct point64 {
long long x;
long long y;
};
struct point64 pt64(struct point64 pt) {
printf("point64: %lld %lld\n",pt.x,pt.y);
return pt;
}
struct struct32 demo32s(struct struct32 v) {
printf("struct32: %d\n",v.v);
struct struct32 v2 = {v.v+100};
return v2;
}
struct point {
int x;
int y;
};
struct point pt(struct point pt) {
printf("point: %d %d\n",pt.x,pt.y);
return pt;
}
struct point1 {
int x;
int y;
int z;
};
struct point1 pt1(struct point1 pt) {
printf("point1: %d %d %d\n",pt.x,pt.y,pt.z);
return pt;
}
struct point2 {
char x;
int y;
int z;
};
struct point2 pt2(struct point2 pt) {
printf("point2: %d %d %d\n",pt.x,pt.y,pt.z);
return pt;
}
struct point3 {
char x;
char y;
char z;
};
struct point3 pt3(struct point3 pt) {
printf("point3: %d %d %d\n",pt.x,pt.y,pt.z);
return pt;
}
struct point4 {
char x;
char y;
char z;
int m;
};
struct point4 pt4(struct point4 pt) {
printf("point4: %d %d %d %d\n",pt.x,pt.y,pt.z,pt.m);
return pt;
}
struct point5 {
char x;
char y;
char z;
char m;
char n;
};
struct point5 pt5(struct point5 pt) {
printf("point5: %d %d %d %d %d\n",pt.x,pt.y,pt.z,pt.m,pt.n);
return pt;
}
struct point6 {
char x;
char y;
char z;
char m;
char n;
int k;
};
struct point6 pt6(struct point6 pt) {
printf("point6: %d %d %d %d %d %d\n",pt.x,pt.y,pt.z,pt.m,pt.n,pt.k);
return pt;
}
struct point7 {
char x;
char y;
char z;
char m;
char n;
int k;
char o;
};
struct point7 pt7(struct point7 pt) {
printf("point7: %d %d %d %d %d %d %d\n",pt.x,pt.y,pt.z,pt.m,pt.n,pt.k,pt.o);
return pt;
}
struct data1 {
char x;
long long y;
};
struct data1 fn1(struct data1 pt) {
printf("data1: %d %lld\n",pt.x,pt.y);
return pt;
}
struct data2 {
int x;
long long y;
};
struct data2 fn2(struct data2 pt) {
printf("data2: %d %lld\n",pt.x,pt.y);
return pt;
}
struct data3 {
long long x;
char y;
};
struct data3 fn3(struct data3 pt) {
printf("data3: %lld %d\n",pt.x,pt.y);
return pt;
}
struct fdata1 {
float x;
};
struct fdata1 ff1(struct fdata1 pt) {
printf("ff1: %f\n",pt.x);
return pt;
}
struct ddata1 {
double x;
};
struct ddata1 dd1(struct ddata1 pt) {
printf("dd1: %f\n",pt.x);
return pt;
}
struct ddata2 {
double x;
double y;
};
struct ddata2 dd2(struct ddata2 pt) {
printf("dd2: %f %f\n",pt.x,pt.y);
return pt;
}
struct ddata3 {
double x;
double y;
double z;
};
struct ddata3 dd3(struct ddata3 pt) {
printf("dd3: %f %f %f\n",pt.x,pt.y,pt.z);
return pt;
}
struct fdata2i {
float x;
int y;
};
struct fdata2i ff2i(struct fdata2i pt) {
printf("ff2i: %f %d\n",pt.x,pt.y);
return pt;
}
struct fdata2 {
float x;
float y;
};
struct fdata2 ff2(struct fdata2 pt) {
printf("ff2: %f %f\n",pt.x,pt.y);
return pt;
}
struct fdata3 {
float x;
float y;
float z;
};
struct fdata3 ff3(struct fdata3 pt) {
printf("ff3: %f %f %f\n",pt.x,pt.y,pt.z);
return pt;
}
struct fdata4 {
float x;
float y;
float z;
float m;
};
struct fdata4 ff4(struct fdata4 pt) {
printf("ff4: %f %f %f %f\n",pt.x,pt.y,pt.z,pt.m);
return pt;
}
struct fdata5 {
float x;
float y;
float z;
float m;
float n;
};
struct fdata5 ff5(struct fdata5 pt) {
printf("ff5: %f %f %f %f %f\n",pt.x,pt.y,pt.z,pt.m,pt.n);
return pt;
}
struct fdata2id {
char x;
char y;
double z;
};
struct fdata2id ff2id(struct fdata2id pt) {
printf("ff6: %d %d %f\n",pt.x,pt.y,pt.z);
return pt;
}
struct fdata7if {
char x[7];
float z;
};
struct fdata7if ff7if(struct fdata7if pt) {
printf("ff7if: %d %d %f\n",pt.x[0],pt.x[1],pt.z);
return pt;
}
struct fdata4if {
float x;
char y;
float z;
float m;
};
struct fdata4if ff4if(struct fdata4if pt) {
printf("ff4if: %f %d %f %f\n",pt.x,pt.y,pt.z,pt.m);
return pt;
}
struct array {
int x[8];
};
struct array demo(struct array a) {
printf("demo: %d %d %d\n",a.x[0],a.x[1],a.x[2]);
return a;
}
struct array demo2(int a1){
struct array x;
for (int i = 0; i < 8; i++) {
x.x[i] = i+a1;
}
return x;
}
void callback(struct array (*fn)(struct array ar, struct point pt, struct point1 pt1), struct array ar) {
demo(ar);
struct point pt = {1,2};
struct point1 pt1 = {1,2,3};
struct array ret = fn(ar,pt,pt1);
demo(ret);
}
void callback1(struct point (*fn)(struct array ar, struct point pt, struct point1 pt1), struct array ar) {
printf("callback1 array: %d %d %d\n",ar.x[0],ar.x[1],ar.x[7]);
struct point pt = {1,2};
struct point1 pt1 = {1,2,3};
struct point ret = fn(ar,pt,pt1);
printf("callback1 ret: %d,%d\n",ret.x,ret.y);
}
struct point mycallback(struct array ar, struct point pt, struct point1 pt1) {
printf("mycallback array: %d %d %d\n",ar.x[0],ar.x[1],ar.x[7]);
printf("mycallback pt: %d %d\n",pt.x,pt.y);
printf("mycallback pt1: %d %d %d\n",pt1.x,pt1.y,pt1.z);
struct point ret = {pt.x+pt1.x, pt.y+pt1.y};
return ret;
}

39
_demo/c/cabisret/main.go Normal file
View File

@@ -0,0 +1,39 @@
package main
type array9 struct {
x [9]float32
}
func demo1(a array9) array9 {
a.x[0] += 1
return a
}
func demo2(a array9) array9 {
for i := 0; i < 1024*128; i++ {
a = demo1(a)
}
return a
}
func testDemo() {
ar := array9{x: [9]float32{1, 2, 3, 4, 5, 6, 7, 8, 9}}
for i := 0; i < 1024*128; i++ {
ar = demo1(ar)
}
ar = demo2(ar)
println(ar.x[0], ar.x[1])
}
func testSlice() {
var b []byte
for i := 0; i < 1024*128; i++ {
b = append(b, byte(i))
}
_ = b
}
func main() {
testDemo()
testSlice()
}

144
_demo/c/cargs/demo.go Normal file
View File

@@ -0,0 +1,144 @@
package main
import (
"fmt"
"os"
_ "unsafe"
"github.com/goplus/lib/c"
)
const LLGoPackage string = "link: $(pkg-config --libs cargs);"
type Option struct {
Identifier c.Char
AccessLetters *c.Char
AccessName *c.Char
ValueName *c.Char
Description *c.Char
}
type OptionContext struct {
Options *Option
OptionCount c.SizeT
Argc c.Int
Argv **c.Char
Index c.Int
InnerIndex c.Int
ErrorIndex c.Int
ErrorLetter c.Char
ForcedEnd bool
Identifier c.Char
Value *c.Char
}
// llgo:type C
type Printer func(__llgo_arg_0 c.Pointer, __llgo_arg_1 *c.Char, __llgo_va_list ...interface{}) c.Int
// llgo:link (*OptionContext).OptionInit C.cag_option_init
func (recv_ *OptionContext) OptionInit(options *Option, option_count c.SizeT, argc c.Int, argv **c.Char) {
}
// llgo:link (*OptionContext).OptionFetch C.cag_option_fetch
func (recv_ *OptionContext) OptionFetch() bool {
return false
}
// llgo:link (*OptionContext).OptionGetIdentifier C.cag_option_get_identifier
func (recv_ *OptionContext) OptionGetIdentifier() c.Char {
return 0
}
// llgo:link (*OptionContext).OptionGetValue C.cag_option_get_value
func (recv_ *OptionContext) OptionGetValue() *c.Char {
return nil
}
// llgo:link (*OptionContext).OptionGetIndex C.cag_option_get_index
func (recv_ *OptionContext) OptionGetIndex() c.Int {
return 0
}
// llgo:link (*OptionContext).OptionGetErrorIndex C.cag_option_get_error_index
func (recv_ *OptionContext) OptionGetErrorIndex() c.Int {
return 0
}
// llgo:link (*OptionContext).OptionGetErrorLetter C.cag_option_get_error_letter
func (recv_ *OptionContext) OptionGetErrorLetter() c.Char {
return 0
}
// llgo:link (*OptionContext).OptionPrintError C.cag_option_print_error
func (recv_ *OptionContext) OptionPrintError(destination *c.FILE) {
}
// llgo:link (*OptionContext).OptionPrinterError C.cag_option_printer_error
func (recv_ *OptionContext) OptionPrinterError(printer Printer, printer_ctx c.Pointer) {
}
// llgo:link (*Option).OptionPrint C.cag_option_print
func (recv_ *Option) OptionPrint(option_count c.SizeT, destination *c.FILE) {
}
// llgo:link (*Option).OptionPrinter C.cag_option_printer
func (recv_ *Option) OptionPrinter(option_count c.SizeT, printer Printer, printer_ctx c.Pointer) {
}
// llgo:link (*OptionContext).OptionPrepare C.cag_option_prepare
func (recv_ *OptionContext) OptionPrepare(options *Option, option_count c.SizeT, argc c.Int, argv **c.Char) {
}
// llgo:link (*OptionContext).OptionGet C.cag_option_get
func (recv_ *OptionContext) OptionGet() c.Char {
return 0
}
func main() {
options := []Option{
{
Identifier: 'h',
AccessLetters: c.Str("h"),
AccessName: c.Str("help"),
ValueName: nil,
Description: c.Str("Show help information"),
},
{
Identifier: 'v',
AccessLetters: c.Str("v"),
AccessName: c.Str("version"),
ValueName: nil,
Description: c.Str("Show version information"),
},
}
args := os.Args
// Convert Go string array to C-style argv
argv := make([]*int8, len(args))
for i, arg := range args {
argv[i] = c.AllocaCStr(arg)
}
// Initialize option context
var context OptionContext
context.OptionInit(&options[0], uintptr(len(options)), c.Int(len(args)), &argv[0])
// Process all options
identifierFound := false
for context.OptionFetch() {
identifierFound = true
identifier := context.OptionGetIdentifier()
switch identifier {
case 'h':
fmt.Println("Help: This is a simple command-line parser demo")
case 'v':
fmt.Println("Version: 1.0.0")
}
}
// Default output if no identifier is found
if !identifierFound {
fmt.Println("Demo Command-line Tool\nIdentifier:\n\t-h: Help\n\t-v: Version")
}
}

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/c/sync/atomic"
"github.com/goplus/lib/c/sync/atomic"
)
func main() {

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/os"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/os"
)
func main() {

16
_demo/c/cgofull/bar.go Normal file
View File

@@ -0,0 +1,16 @@
package main
/*
#cgo CFLAGS: -DBAR
#include <stdio.h>
#include "foo.h"
static void foo(Foo* f) {
printf("foo in bar: %d\n", f->a);
}
*/
import "C"
func Bar(f *C.Foo) {
C.print_foo(f)
C.foo(f)
}

157
_demo/c/cgofull/cgofull.go Normal file
View File

@@ -0,0 +1,157 @@
package main
/*
#cgo windows,!amd64 CFLAGS: -D_WIN32
#cgo !windows CFLAGS: -D_POSIX
#cgo windows,amd64 CFLAGS: -D_WIN64
#cgo linux,amd64 CFLAGS: -D_LINUX64
#cgo !windows,amd64 CFLAGS: -D_UNIX64
#cgo pkg-config: python3-embed
#include <stdio.h>
#include <Python.h>
#include "foo.h"
typedef struct {
int a;
} s4;
typedef struct {
int a;
int b;
} s8;
typedef struct {
int a;
int b;
int c;
} s12;
typedef struct {
int a;
int b;
int c;
int d;
} s16;
typedef struct {
int a;
int b;
int c;
int d;
int e;
} s20;
static int test_structs(s4* s4, s8* s8, s12* s12, s16* s16, s20* s20) {
printf("s4.a: %d\n", s4->a);
printf("s8.a: %d, s8.b: %d\n", s8->a, s8->b);
printf("s12.a: %d, s12.b: %d, s12.c: %d\n", s12->a, s12->b, s12->c);
printf("s16.a: %d, s16.b: %d, s16.c: %d, s16.d: %d\n", s16->a, s16->b, s16->c, s16->d);
printf("s20.a: %d, s20.b: %d, s20.c: %d, s20.d: %d, s20.e: %d\n", s20->a, s20->b, s20->c, s20->d, s20->e);
return s4->a + s8->a + s8->b + s12->a + s12->b + s12->c + s16->a + s16->b + s16->c + s16->d + s20->a + s20->b + s20->c + s20->d + s20->e;
}
static void test_macros() {
#ifdef FOO
printf("FOO is defined\n");
#endif
#ifdef BAR
printf("BAR is defined\n");
#endif
#ifdef _WIN32
printf("WIN32 is defined\n");
#endif
#ifdef _POSIX
printf("POSIX is defined\n");
#endif
#ifdef _WIN64
printf("WIN64 is defined\n");
#endif
#ifdef _LINUX64
printf("LINUX64 is defined\n");
#endif
#ifdef _UNIX64
printf("UNIX64 is defined\n");
#endif
}
#define MY_VERSION "1.0.0"
#define MY_CODE 0x12345678
static void test_void() {
printf("test_void\n");
}
typedef int (*Cb)(int);
extern int go_callback(int);
extern int c_callback(int i);
static void test_callback(Cb cb) {
printf("test_callback, cb: %p, go_callback: %p, c_callback: %p\n", cb, go_callback, c_callback);
printf("test_callback, *cb: %p, *go_callback: %p, *c_callback: %p\n", *(void**)cb, *(void**)(go_callback), *(void**)(c_callback));
printf("cb result: %d\n", cb(123));
printf("done\n");
}
extern int go_callback_not_use_in_go(int);
static void run_callback() {
test_callback(c_callback);
test_callback(go_callback_not_use_in_go);
}
*/
import "C"
import (
"fmt"
"unsafe"
"github.com/goplus/llgo/_demo/c/cgofull/pymod1"
"github.com/goplus/llgo/_demo/c/cgofull/pymod2"
)
//export go_callback_not_use_in_go
func go_callback_not_use_in_go(i C.int) C.int {
return i + 1
}
//export go_callback
func go_callback(i C.int) C.int {
return i + 1
}
func main() {
runPy()
f := &C.Foo{a: 1}
Foo(f)
Bar(f)
C.test_macros()
r := C.test_structs(&C.s4{a: 1}, &C.s8{a: 1, b: 2}, &C.s12{a: 1, b: 2, c: 3}, &C.s16{a: 1, b: 2, c: 3, d: 4}, &C.s20{a: 1, b: 2, c: 3, d: 4, e: 5})
fmt.Println(r)
if r != 35 {
panic("test_structs failed")
}
fmt.Println(C.MY_VERSION)
fmt.Println(int(C.MY_CODE))
C.test_void()
println("call run_callback")
C.run_callback()
// test _Cgo_ptr and _cgoCheckResult
println("call with go_callback")
C.test_callback((C.Cb)(C.go_callback))
println("call with c_callback")
C.test_callback((C.Cb)(C.c_callback))
}
func runPy() {
Initialize()
defer Finalize()
Run("print('Hello, Python!')")
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(pymod1.Float(1.23))), C.stderr, 0)
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(pymod2.Long(123))), C.stdout, 0)
// test _Cgo_use
C.PyObject_Print((*C.PyObject)(unsafe.Pointer(C.PyComplex_FromDoubles(C.double(1.23), C.double(4.56)))), C.stdout, 0)
}

12
_demo/c/cgofull/foo.c Normal file
View File

@@ -0,0 +1,12 @@
#include <stdio.h>
#include "foo.h"
void print_foo(Foo *f)
{
printf("print_foo: %d\n", f->a);
}
int c_callback(int i)
{
return i + 1;
}

16
_demo/c/cgofull/foo.go Normal file
View File

@@ -0,0 +1,16 @@
package main
/*
#cgo CFLAGS: -DFOO
#include <stdio.h>
#include "foo.h"
static void foo(Foo* f) {
printf("foo in bar: %d\n", f->a);
}
*/
import "C"
func Foo(f *C.Foo) {
C.print_foo(f)
C.foo(f)
}

7
_demo/c/cgofull/foo.h Normal file
View File

@@ -0,0 +1,7 @@
#pragma once
typedef struct {
int a;
} Foo;
extern void print_foo(Foo* f);

24
_demo/c/cgofull/py.go Normal file
View File

@@ -0,0 +1,24 @@
package main
/*
#cgo pkg-config: python3-embed
#include <Python.h>
*/
import "C"
import "fmt"
func Initialize() {
C.Py_Initialize()
}
func Finalize() {
C.Py_Finalize()
}
func Run(code string) error {
if C.PyRun_SimpleString(C.CString(code)) != 0 {
C.PyErr_Print()
return fmt.Errorf("failed to run code")
}
return nil
}

View File

@@ -0,0 +1,11 @@
package pymod1
/*
#cgo pkg-config: python3-embed
#include <Python.h>
*/
import "C"
func Float(f float64) *C.PyObject {
return C.PyFloat_FromDouble(C.double(f))
}

View File

@@ -0,0 +1,11 @@
package pymod2
/*
#cgo pkg-config: python3-embed
#include <Python.h>
*/
import "C"
func Long(l int64) *C.PyObject {
return C.PyLong_FromLongLong(C.longlong(l))
}

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/lib/c"
)
func concat(args ...string) (ret string) {

View File

@@ -1,9 +1,9 @@
package main
import (
"github.com/goplus/llgo/_demo/cppintf/foo"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/math"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/math"
"github.com/goplus/llgo/_demo/c/cppintf/foo"
)
type Bar struct {

View File

@@ -3,9 +3,9 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/_demo/cppmintf/foo"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/math"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/math"
"github.com/goplus/llgo/_demo/c/cppmintf/foo"
)
type Bar struct {

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/cpp/std"
"github.com/goplus/lib/c"
"github.com/goplus/lib/cpp/std"
)
func main() {

View File

@@ -3,9 +3,9 @@ package main
import (
"fmt"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/math/rand"
"github.com/goplus/llgo/c/time"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/math/rand"
"github.com/goplus/lib/c/time"
)
func fastrand64() uint64 {

View File

@@ -1,6 +1,6 @@
package main
import "github.com/goplus/llgo/c/time"
import "github.com/goplus/lib/c/time"
func main() {
var tv time.Timespec

View File

@@ -1,9 +1,10 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/os"
"unsafe"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/os"
)
func main() {
@@ -45,8 +46,6 @@ func main() {
}
c.Printf(c.Str("set file status successfully\n"))
c.Printf(c.Str("111"))
// Close file
os.Close(fd)

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/lib/c"
)
type generator struct {

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/os"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/os"
)
func main() {

5
_demo/c/go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/goplus/llgo/_demo/c
go 1.20
require github.com/goplus/lib v0.3.0

2
_demo/c/go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/goplus/lib v0.3.0 h1:y0ZGb5Q/RikW1oMMB4Di7XIZIpuzh/7mlrR8HNbxXCA=
github.com/goplus/lib v0.3.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=

13
_demo/c/hello/hello.go Normal file
View File

@@ -0,0 +1,13 @@
package main
import (
"fmt"
"github.com/goplus/lib/c"
)
func main() {
println("hello world by println")
fmt.Println("hello world by fmt.Println")
c.Printf(c.Str("Hello world by c.Printf\n"))
}

15
_demo/c/helloc/helloc.go Normal file
View File

@@ -0,0 +1,15 @@
package main
import (
"unsafe"
"github.com/goplus/lib/c"
)
func main() {
c.Printf(c.Str("Hello world by c.Printf\n"))
c.Printf(c.Str("%ld\n"), unsafe.Sizeof(int(0)))
c.Printf(c.Str("%ld\n"), unsafe.Sizeof(uintptr(0)))
// var v any = int(0)
// c.Printf(c.Str("%ld\n"), unsafe.Sizeof(v))
}

View File

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 183 KiB

View File

@@ -1,9 +1,9 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/llama2"
"github.com/goplus/llgo/c/time"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/llama2"
"github.com/goplus/lib/c/time"
)
func main() {
@@ -36,7 +36,6 @@ loop: // parse command line arguments
// build the Tokenizer via the tokenizer .bin file
var tokenizer llama2.Tokenizer
llama2.BuildTokenizer(&tokenizer, tokenizerPath, transformer.Config.VocabSize)
// build the Sampler
var sampler llama2.Sampler
llama2.BuildSampler(&sampler, transformer.Config.VocabSize, temperature, topp, rngSeed)

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/net"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/net"
)
func main() {

View File

@@ -3,7 +3,7 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/lib/c"
)
func main() {

View File

@@ -1,7 +1,7 @@
package main
import (
"github.com/goplus/llgo/c/setjmp"
"github.com/goplus/lib/c/setjmp"
)
func main() {

View File

@@ -3,9 +3,9 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/net"
"github.com/goplus/llgo/c/os"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/net"
"github.com/goplus/lib/c/os"
)
func main() {

View File

@@ -3,9 +3,9 @@ package main
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/net"
"github.com/goplus/llgo/c/os"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/net"
"github.com/goplus/lib/c/os"
)
func main() {

View File

@@ -6,7 +6,7 @@ import (
"sync"
"unsafe"
llsync "github.com/goplus/llgo/c/pthread/sync"
llsync "github.com/goplus/lib/c/pthread/sync"
)
type L struct {

View File

@@ -1,8 +1,8 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/pthread"
"github.com/goplus/lib/c"
"github.com/goplus/lib/c/pthread"
)
var key pthread.Key

View File

@@ -1 +0,0 @@
../cl/_testgo/cgobasic

View File

@@ -1 +0,0 @@
../cl/_testgo/cgocfiles

View File

@@ -1 +0,0 @@
../cl/_testgo/cgodefer

View File

@@ -1 +0,0 @@
../cl/_testgo/cgofull

View File

@@ -1 +0,0 @@
../cl/_testgo/cgomacro

View File

@@ -1 +0,0 @@
../cl/_testgo/cgopython

View File

@@ -0,0 +1,16 @@
package main
import "github.com/goplus/lib/c"
func myprint(s *c.Char) {
for i := 0; i < int(c.Strlen(s)); i++ {
WriteByte(byte(c.Index(s, i)))
}
}
func main() {
for {
myprint(c.Str("hello world"))
sleep(1)
}
}

View File

@@ -0,0 +1,13 @@
package main
import (
_ "unsafe"
"github.com/goplus/lib/c"
)
//go:linkname WriteByte C.board_uart_write_char
func WriteByte(b byte)
//go:linkname sleep sleep
func sleep(c c.Int)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,385 @@
package main
import (
_ "unsafe"
"github.com/goplus/llgo/_demo/embed/esp32/watchdog"
)
//
//go:linkname absvdi2 __absvdi2
func absvdi2(a int64) int64
//go:linkname absvsi2 __absvsi2
func absvsi2(a int32) int32
//go:linkname adddf3 __adddf3
func adddf3(a, b float64) float64
//go:linkname addsf3 __addsf3
func addsf3(a, b float32) float32
//go:linkname addvdi3 __addvdi3
func addvdi3(a, b int64) int64
//go:linkname addvsi3 __addvsi3
func addvsi3(a, b int32) int32
//go:linkname udivdi3 __udivdi3
func udivdi3(a, b uint64) uint64
//go:linkname clzdi2 __clzdi2
func clzdi2(a uint64) int32
//go:linkname clzsi2 __clzsi2
func clzsi2(a uint32) int32
//go:linkname ctzdi2 __ctzdi2
func ctzdi2(a uint64) int32
//go:linkname ctzsi2 __ctzsi2
func ctzsi2(a uint32) int32
//go:linkname popcountdi2 __popcountdi2
func popcountdi2(a uint64) int32
//go:linkname popcountsi2 __popcountsi2
func popcountsi2(a uint32) int32
//go:linkname divdf3 __divdf3
func divdf3(a, b float64) float64
//go:linkname divsf3 __divsf3
func divsf3(a, b float32) float32
//go:linkname mulsf3 __mulsf3
func mulsf3(a, b float32) float32
//go:linkname divdi3 __divdi3
func divdi3(a, b int64) int64
//go:linkname muldf3 __muldf3
func muldf3(a, b float64) float64
//go:linkname muldi3 __muldi3
func muldi3(a, b int64) int64
//go:linkname subdf3 __subdf3
func subdf3(a, b float64) float64
//go:linkname subsf3 __subsf3
func subsf3(a, b float32) float32
//go:linkname extendsfdf2 __extendsfdf2
func extendsfdf2(a float32) float64
//go:linkname fixdfdi __fixdfdi
func fixdfdi(a float64) int64
//go:linkname fixdfsi __fixdfsi
func fixdfsi(a float64) int32
//go:linkname fixsfdi __fixsfdi
func fixsfdi(a float32) int64
//go:linkname fixsfsi __fixsfsi
func fixsfsi(a float32) int32
//go:linkname floatdidf __floatdidf
func floatdidf(a int64) float64
//go:linkname floatsidf __floatsidf
func floatsidf(a int32) float64
//go:linkname ashldi3 __ashldi3
func ashldi3(a int64, b int32) int64
//go:linkname ashrdi3 __ashrdi3
func ashrdi3(a int64, b int32) int64
//go:linkname lshrdi3 __lshrdi3
func lshrdi3(a uint64, b int32) uint64
//go:linkname bswapdi2 __bswapdi2
func bswapdi2(a uint64) uint64
//go:linkname bswapsi2 __bswapsi2
func bswapsi2(a uint32) uint32
var totalTests = 0
var passedTests = 0
var failedTests = 0
func assertEqualInt32(name string, actual, expected int32) {
totalTests++
if actual != expected {
println("FAIL: %s: expected %d, got %d\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func assertEqualInt64(name string, actual, expected int64) {
totalTests++
if actual != expected {
println("FAIL: %s: expected %d, got %d\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func assertEqualUint32(name string, actual, expected uint32) {
totalTests++
if actual != expected {
println("FAIL: %s: expected %d, got %d\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func assertEqualUint64(name string, actual, expected uint64) {
totalTests++
if actual != expected {
println("FAIL: %s: expected %d, got %d\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func assertEqualFloat32(name string, actual, expected float32, epsilon float32) {
totalTests++
diff := actual - expected
if diff < 0 {
diff = -diff
}
if diff > epsilon {
println("FAIL: %s: expected %f, got %f\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func assertEqualFloat64(name string, actual, expected float64, epsilon float64) {
totalTests++
diff := actual - expected
if diff < 0 {
diff = -diff
}
if diff > epsilon {
println("FAIL: %s: expected %f, got %f\n", name, expected, actual)
failedTests++
} else {
passedTests++
}
}
func testAbsFunctions() {
println("Testing absolute value functions...")
// Test absvsi2
assertEqualInt32("absvsi2", absvsi2(12345), 12345)
assertEqualInt32("absvsi2", absvsi2(-12345), 12345)
assertEqualInt32("absvsi2", absvsi2(0), 0)
// Test absvdi2
assertEqualInt64("absvdi2", absvdi2(1234567890123456789), 1234567890123456789)
assertEqualInt64("absvdi2", absvdi2(-1234567890123456789), 1234567890123456789)
assertEqualInt64("absvdi2", absvdi2(0), 0)
}
func testAddFunctions() {
println("Testing addition functions...")
// Test addvsi3
assertEqualInt32("addvsi3", addvsi3(1000, 2000), 3000)
assertEqualInt32("addvsi3", addvsi3(-1000, -2000), -3000)
assertEqualInt32("addvsi3", addvsi3(0, 0), 0)
// Test addvdi3
assertEqualInt64("addvdi3", addvdi3(1000000000, 2000000000), 3000000000)
assertEqualInt64("addvdi3", addvdi3(-1000000000, -2000000000), -3000000000)
assertEqualInt64("addvdi3", addvdi3(0, 0), 0)
// Test adddf3
assertEqualFloat64("adddf3", adddf3(3.14, 2.71), 5.85, 1e-10)
assertEqualFloat64("adddf3", adddf3(-3.14, -2.71), -5.85, 1e-10)
assertEqualFloat64("adddf3", adddf3(0.0, 0.0), 0.0, 1e-10)
// Test addsf3
assertEqualFloat32("addsf3", addsf3(3.14, 2.71), 5.85, 1e-6)
assertEqualFloat32("addsf3", addsf3(-3.14, -2.71), -5.85, 1e-6)
assertEqualFloat32("addsf3", addsf3(0.0, 0.0), 0.0, 1e-6)
}
func testCountFunctions() {
println("Testing count functions...")
// Test clzsi2 - count leading zeros in 32-bit integer
assertEqualInt32("clzsi2", clzsi2(1), 31) // 0x00000001 has 31 leading zeros
assertEqualInt32("clzsi2", clzsi2(0x80000000), 0) // 0x80000000 has 0 leading zeros
assertEqualInt32("clzsi2", clzsi2(0), 32) // 0 has 32 leading zeros
// FIXME
// // Test clzdi2 - count leading zeros in 64-bit integer
// assertEqualInt32("clzdi2", clzdi2(1), 63) // 0x0000000000000001 has 63 leading zeros
// assertEqualInt32("clzdi2", clzdi2(0x8000000000000000), 0) // 0x8000000000000000 has 0 leading zeros
// assertEqualInt32("clzdi2", clzdi2(0), 64) // 0 has 64 leading zeros
// Test ctzsi2 - count trailing zeros in 32-bit integer
assertEqualInt32("ctzsi2", ctzsi2(1<<5), 5) // 0x00000020 has 5 trailing zeros
assertEqualInt32("ctzsi2", ctzsi2(0x80000000), 31) // 0x80000000 has 31 trailing zeros
assertEqualInt32("ctzsi2", ctzsi2(0), 32) // 0 has 32 trailing zeros
// Test ctzdi2 - count trailing zeros in 64-bit integer
assertEqualInt32("ctzdi2", ctzdi2(1<<10), 10) // 0x0000000000000400 has 10 trailing zeros
assertEqualInt32("ctzdi2", ctzdi2(0x8000000000000000), 63) // 0x8000000000000000 has 63 trailing zeros
assertEqualInt32("ctzdi2", ctzdi2(0), 64) // 0 has 64 trailing zeros
// Test popcountsi2 - population count of 32-bit integer
assertEqualInt32("popcountsi2", popcountsi2(0xF0F0F0F0), 16) // 0xF0F0F0F0 has 16 ones
assertEqualInt32("popcountsi2", popcountsi2(0), 0) // 0 has 0 ones
assertEqualInt32("popcountsi2", popcountsi2(0xFFFFFFFF), 32) // 0xFFFFFFFF has 32 ones
// Test popcountdi2 - population count of 64-bit integer
assertEqualInt32("popcountdi2", popcountdi2(0xFFFF0000FFFF0000), 32) // 0xFFFF0000FFFF0000 has 32 ones
assertEqualInt32("popcountdi2", popcountdi2(0), 0) // 0 has 0 ones
assertEqualInt32("popcountdi2", popcountdi2(0xFFFFFFFFFFFFFFFF), 64) // 0xFFFFFFFFFFFFFFFF has 64 ones
}
func testDivisionFunctions() {
println("Testing division functions...")
// Test udivdi3 - unsigned 64-bit division
assertEqualUint64("udivdi3", udivdi3(100, 5), 20)
assertEqualUint64("udivdi3", udivdi3(18446744073709551615, 3), 6148914691236517205)
assertEqualUint64("udivdi3", udivdi3(0, 123456789), 0)
// Test divdi3 - signed 64-bit division
assertEqualInt64("divdi3", divdi3(20, 3), 6)
assertEqualInt64("divdi3", divdi3(-20, 3), -6)
assertEqualInt64("divdi3", divdi3(20, -3), -6)
// Test divdf3 - double precision division
assertEqualFloat64("divdf3", divdf3(20.0, 3.0), 6.666666666666667, 1e-10)
assertEqualFloat64("divdf3", divdf3(-20.0, 3.0), -6.666666666666667, 1e-10)
// Test divsf3 - single precision division
assertEqualFloat32("divsf3", divsf3(20.0, 3.0), 6.6666665, 1e-6)
assertEqualFloat32("divsf3", divsf3(-20.0, 3.0), -6.6666665, 1e-6)
}
func testMultiplicationFunctions() {
println("Testing multiplication functions...")
// Test muldi3 - signed 64-bit multiplication
assertEqualInt64("muldi3", muldi3(5, 4), 20)
assertEqualInt64("muldi3", muldi3(-5, 4), -20)
assertEqualInt64("muldi3", muldi3(5, -4), -20)
// Test muldf3 - double precision multiplication
assertEqualFloat64("muldf3", muldf3(3.0, 4.0), 12.0, 1e-10)
assertEqualFloat64("muldf3", muldf3(-3.0, 4.0), -12.0, 1e-10)
// Test mulsf3 - single precision multiplication
assertEqualFloat32("mulsf3", mulsf3(3.0, 4.0), 12.0, 1e-6)
assertEqualFloat32("mulsf3", mulsf3(-3.0, 4.0), -12.0, 1e-6)
}
func testSubtractionFunctions() {
println("Testing subtraction functions...")
// Test subdf3 - double precision subtraction
assertEqualFloat64("subdf3", subdf3(5.0, 3.0), 2.0, 1e-10)
assertEqualFloat64("subdf3", subdf3(3.0, 5.0), -2.0, 1e-10)
// Test subsf3 - single precision subtraction
assertEqualFloat32("subsf3", subsf3(5.0, 3.0), 2.0, 1e-6)
assertEqualFloat32("subsf3", subsf3(3.0, 5.0), -2.0, 1e-6)
}
func testConversionFunctions() {
println("Testing conversion functions...")
// Test extendsfdf2 - single to double precision conversion
// FIXME
// assertEqualFloat64("extendsfdf2", extendsfdf2(3.14), 3.14, 1e-10)
// Test fixdfsi - double precision to int32 conversion
assertEqualInt32("fixdfsi", fixdfsi(123.45), 123)
assertEqualInt32("fixdfsi", fixdfsi(-123.45), -123)
// Test fixsfsi - single precision to int32 conversion
assertEqualInt32("fixsfsi", fixsfsi(123.45), 123)
assertEqualInt32("fixsfsi", fixsfsi(-123.45), -123)
// Test fixdfdi - double precision to int64 conversion
assertEqualInt64("fixdfdi", fixdfdi(123456789.123), 123456789)
assertEqualInt64("fixdfdi", fixdfdi(-123456789.123), -123456789)
// Test fixsfdi - single precision to int64 conversion
// FIXME
// assertEqualInt64("fixsfdi", fixsfdi(123456789.123), 123456789)
// assertEqualInt64("fixsfdi", fixsfdi(-123456789.123), -123456789)
// Test floatsidf - int32 to double precision conversion
assertEqualFloat64("floatsidf", floatsidf(42), 42.0, 1e-10)
assertEqualFloat64("floatsidf", floatsidf(-100), -100.0, 1e-10)
// Test floatdidf - int64 to double precision conversion
assertEqualFloat64("floatdidf", floatdidf(123456789), 123456789.0, 1e-10)
assertEqualFloat64("floatdidf", floatdidf(-123456789), -123456789.0, 1e-10)
}
func testShiftFunctions() {
println("Testing shift functions...")
// Test ashldi3 - arithmetic shift left
assertEqualInt64("ashldi3", ashldi3(1, 10), 1024)
// Test ashrdi3 - arithmetic shift right
assertEqualInt64("ashrdi3", ashrdi3(1024, 10), 1)
// Test lshrdi3 - logical shift right
assertEqualUint64("lshrdi3", lshrdi3(1024, 10), 1)
assertEqualUint64("lshrdi3", lshrdi3(0x8000000000000000, 63), 1)
}
func testBitManipulationFunctions() {
println("Testing bit manipulation functions...")
// Test bswapsi2 - byte swap 32-bit integer
assertEqualUint32("bswapsi2", bswapsi2(0x12345678), 0x78563412)
// Test bswapdi2 - byte swap 64-bit integer
assertEqualUint64("bswapdi2", bswapdi2(0x1234567890ABCDEF), 0xEFCDAB9078563412)
}
func main() {
watchdog.Disable()
println("Testing Compiler-RT Builtins Functions")
println("=====================================")
testAbsFunctions()
testAddFunctions()
testCountFunctions()
testDivisionFunctions()
testMultiplicationFunctions()
testSubtractionFunctions()
testConversionFunctions()
testShiftFunctions()
testBitManipulationFunctions()
println("\n=====================================")
println("Test Results: %d total, %d passed, %d failed\n", totalTests, passedTests, failedTests)
println("=====================================")
if failedTests == 0 {
println("All tests PASSED!")
} else {
println("Some tests FAILED!")
}
}

View File

@@ -0,0 +1,16 @@
package watchdog
import (
"unsafe"
_ "unsafe"
)
//go:linkname StoreUint32 llgo.atomicStore
func StoreUint32(addr *uint32, val uint32)
func Disable() {
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff480A4))), 0x50D83AA1)
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff4808C))), 0)
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff5f048))), 0)
}

View File

@@ -0,0 +1,31 @@
package main
import (
_ "unsafe"
"github.com/goplus/lib/c"
)
//go:linkname write C.write
func write(c.Int, *c.Char, c.SizeT) int
func main() {
buf := c.Malloc(6)
c.Memset(buf, 0, 6)
c.Strncpy((*c.Char)(buf), c.Str("abcde"), 5)
if c.Strcmp((*c.Char)(buf), c.Str("abcde")) == 0 {
write(1, c.Str("pass strcmp"), 11)
}
if byte(c.Index((*c.Char)(buf), 0)) == 'a' {
write(1, c.Str("pass index"), 10)
}
c.Memset(buf, c.Int('A'), 5)
if c.Strcmp((*c.Char)(buf), c.Str("AAAAA")) == 0 {
write(1, c.Str("pass memeset"), 11)
}
write(1, (*c.Char)(buf), 5)
}

5
_demo/embed/go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/goplus/llgo/_demo/embed
go 1.20
require github.com/goplus/lib v0.3.0

2
_demo/embed/go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/goplus/lib v0.3.0 h1:y0ZGb5Q/RikW1oMMB4Di7XIZIpuzh/7mlrR8HNbxXCA=
github.com/goplus/lib v0.3.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=

View File

@@ -0,0 +1,21 @@
package C
func XhandleHardFault() {
}
func Reset_Handler() {
}
func XhandleInterrupt() {
}
type dyn64 struct {
// Fields for dynamic loader
}
// For nintendo switch
func X__dynamic_loader(base uintptr, dyn *dyn64) {
}

View File

@@ -0,0 +1,180 @@
#!/bin/bash
# Function to display usage information
show_usage() {
cat << EOF
Usage: $(basename "$0") [OPTIONS] [TARGET_FILE]
Build targets for llgo across multiple platforms.
OPTIONS:
-h, --help Show this help message and exit
ARGUMENTS:
TARGET_FILE Optional. A text file containing target names, one per line.
Lines starting with # are treated as comments and ignored.
Empty lines are also ignored.
BEHAVIOR:
Without TARGET_FILE:
- Automatically discovers all targets from ../../targets/*.json files
- Extracts target names from JSON filenames
With TARGET_FILE:
- Reads target names from the specified file
- Supports comments (lines starting with #)
- Ignores empty lines and whitespace
IGNORED TARGETS:
The following targets are automatically ignored and not built:
atmega1280, atmega2560, atmega328p, atmega32u4, attiny85,
fe310, k210, riscv32, riscv64, rp2040
RESULT CATEGORIES:
✅ Successful: Build completed successfully
🔕 Ignored: Target is in the ignore list
⚠️ Warned: Build failed with configuration warnings
❌ Failed: Build failed with errors
EXIT CODES:
0 All builds successful, ignored, or warned only
1 One or more builds failed with errors
EXAMPLES:
$(basename "$0") # Build all targets from JSON files
$(basename "$0") my-targets.txt # Build targets from file
$(basename "$0") --help # Show this help
TARGET FILE FORMAT:
# This is a comment
esp32
cortex-m4
# Another comment
riscv64
EOF
}
# Check for help flag
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
show_usage
exit 0
fi
# Check for invalid number of arguments
if [ $# -gt 1 ]; then
echo "Error: Too many arguments."
echo "Use '$(basename "$0") --help' for usage information."
exit 1
fi
# Initialize arrays to store results
successful_targets=()
ignored_targets=()
warned_targets=()
failed_targets=()
targets_to_build=()
# Define ignore list
ignore_list=(
"atmega1280"
"atmega2560"
"atmega328p"
"atmega32u4"
"attiny85"
"fe310"
"k210"
"riscv32"
"riscv64"
"rp2040"
)
# Build the targets list based on input method
if [ $# -eq 1 ]; then
# Read targets from file
target_file="$1"
if [ ! -f "$target_file" ]; then
echo "Error: Target file '$target_file' not found."
echo "Use '$(basename "$0") --help' for usage information."
exit 1
fi
while IFS= read -r target || [[ -n "$target" ]]; do
# Skip empty lines and comments
if [[ -z "$target" || "$target" =~ ^[[:space:]]*# ]]; then
continue
fi
# Trim whitespace
target=$(echo "$target" | xargs)
targets_to_build+=("$target")
done < "$target_file"
else
# Use targets from *.json files
for target_file in ../../../targets/*.json; do
# Extract target name from filename (remove path and .json extension)
target=$(basename "$target_file" .json)
targets_to_build+=("$target")
done
fi
# Process each target
for target in "${targets_to_build[@]}"; do
# Check if target is in ignore list
if [[ " ${ignore_list[@]} " =~ " ${target} " ]]; then
echo 🔕 $target "(ignored)"
ignored_targets+=("$target")
continue
fi
output=$(../../../llgo.sh build -target $target -o hello.elf . 2>&1)
if [ $? -eq 0 ]; then
echo$target `file hello.elf`
successful_targets+=("$target")
else
# Check if output contains warning messages
if echo "$output" | grep -q "does not have a valid LLVM target triple\|does not have a valid CPU configuration"; then
echo ⚠️ $target
echo "$output"
warned_targets+=("$target")
else
echo$target
echo "$output"
failed_targets+=("$target")
fi
fi
done
echo ""
echo "----------------------------------------"
# Output successful targets
echo "Successful targets (${#successful_targets[@]} total):"
for target in "${successful_targets[@]}"; do
echo "$target"
done
echo ""
echo "Ignored targets (${#ignored_targets[@]} total):"
for target in "${ignored_targets[@]}"; do
echo "$target"
done
echo ""
echo "Warned targets (${#warned_targets[@]} total):"
for target in "${warned_targets[@]}"; do
echo "$target"
done
echo ""
echo "Failed targets (${#failed_targets[@]} total):"
for target in "${failed_targets[@]}"; do
echo "$target"
done
# Exit with error code if there are any failed targets
if [ ${#failed_targets[@]} -gt 0 ]; then
echo ""
echo "Build failed with ${#failed_targets[@]} failed targets."
exit 1
fi

View File

@@ -0,0 +1,6 @@
package main
import _ "github.com/goplus/llgo/_demo/embed/targetsbuild/C"
func main() {
}

View File

@@ -3,8 +3,8 @@ package main
import (
"time"
"github.com/goplus/llgo/_demo/async/async"
"github.com/goplus/llgo/_demo/async/timeout"
"github.com/goplus/llgo/_demo/go/async/async"
"github.com/goplus/llgo/_demo/go/async/timeout"
)
func Sleep(i int, d time.Duration) async.Future[int] {

View File

@@ -3,7 +3,7 @@ package timeout
import (
"time"
"github.com/goplus/llgo/_demo/async/async"
"github.com/goplus/llgo/_demo/go/async/async"
)
func Timeout(d time.Duration) async.Future[async.Void] {

View File

@@ -0,0 +1,20 @@
package main
import (
"bytes"
"os/exec"
"path/filepath"
)
func main() {
var data bytes.Buffer
cmd := exec.Command("echo", "hello llgo")
cmd.Dir = filepath.Dir("./")
cmd.Stdout = &data
err := cmd.Run()
if err != nil {
panic(err)
}
println("len:", len(data.Bytes()))
println("data:", data.String())
}

18
_demo/go/defer/main.go Normal file
View File

@@ -0,0 +1,18 @@
package main
func main() {
var a int = 5
defer println(a)
defer func() {
println(a)
}()
defer func() {
println(recover().(string))
}()
a = 10
panic("error")
//Output:
// error
// 10
// 5
}

1
_demo/go/export/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
libexport.h

29
_demo/go/export/c/c.go Normal file
View File

@@ -0,0 +1,29 @@
package C
// XType - struct for export.go to use
type XType struct {
ID int32 `json:"id"`
Name string `json:"name"`
Value float64 `json:"value"`
Flag bool `json:"flag"`
}
func XAdd(a, b int) int {
return a + b
}
func Sub(a, b int64) int64 {
return a - b
}
func sub(a, b uint32) uint32 {
return a - b
}
func Xmul(a, b float32) float32 {
return a * b
}
func Concat(a, b string) string {
return a + b
}

674
_demo/go/export/export.go Normal file
View File

@@ -0,0 +1,674 @@
package main
import (
"unsafe"
C "github.com/goplus/llgo/_demo/go/export/c"
)
// assert helper function for testing
func assert[T comparable](got, expected T, message string) {
if got != expected {
println("ASSERTION FAILED:", message)
println(" Expected:", expected)
println(" Got: ", got)
panic("assertion failed: " + message)
}
println("✓", message)
}
// Small struct
type SmallStruct struct {
ID int8 `json:"id"`
Flag bool `json:"flag"`
}
// Large struct
type LargeStruct struct {
ID int64 `json:"id"`
Name string `json:"name"`
Values [10]float64 `json:"values"`
Metadata map[string]int `json:"metadata"`
Children []SmallStruct `json:"children"`
Extra1 int32 `json:"extra1"`
Extra2 uint64 `json:"extra2"`
Extra3 float32 `json:"extra3"`
Extra4 bool `json:"extra4"`
Extra5 uintptr `json:"extra5"`
}
// Self-referential struct
type Node struct {
Data int `json:"data"`
Next *Node `json:"next"`
}
// Named types
type MyInt int
type MyString string
// Function types for callbacks
//
//llgo:type C
type IntCallback func(int) int
//llgo:type C
type StringCallback func(string) string
//llgo:type C
type VoidCallback func()
// Complex struct with mixed arrays and slices
type ComplexData struct {
Matrix [3][4]int32 `json:"matrix"` // 2D array
Slices [][]string `json:"slices"` // slice of slices - commented out
IntArray [5]int `json:"int_array"` // 1D array
DataList []float64 `json:"data_list"` // slice - commented out
}
//export HelloWorld
func HelloWorld() {
println("Hello, World!")
}
// Functions with small struct parameters and return values
//export CreateSmallStruct
func CreateSmallStruct(id int8, flag bool) SmallStruct {
return SmallStruct{ID: id, Flag: flag}
}
//export ProcessSmallStruct
func ProcessSmallStruct(s SmallStruct) SmallStruct {
s.ID += 1
s.Flag = !s.Flag
return s
}
//export ProcessSmallStructPtr
func ProcessSmallStructPtr(s *SmallStruct) *SmallStruct {
if s != nil {
s.ID *= 2
s.Flag = !s.Flag
}
return s
}
// Functions with large struct parameters and return values
//export CreateLargeStruct
func CreateLargeStruct(id int64, name string) LargeStruct {
return LargeStruct{
ID: id,
Name: name,
Values: [10]float64{1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0},
Metadata: map[string]int{"count": 42, "size": 100},
Children: []SmallStruct{{ID: 1, Flag: true}, {ID: 2, Flag: false}},
Extra1: 12345,
Extra2: 67890,
Extra3: 3.14,
Extra4: true,
Extra5: 0x1000,
}
}
//export ProcessLargeStruct
func ProcessLargeStruct(ls LargeStruct) int64 {
total := ls.ID + int64(len(ls.Name))
for _, v := range ls.Values {
total += int64(v)
}
total += int64(len(ls.Children))
total += int64(ls.Extra1) + int64(ls.Extra2) + int64(ls.Extra3)
if ls.Extra4 {
total += 1000
}
total += int64(ls.Extra5)
return total
}
//export ProcessLargeStructPtr
func ProcessLargeStructPtr(ls *LargeStruct) *LargeStruct {
if ls != nil {
ls.ID += 100
ls.Name = "processed_" + ls.Name
ls.Extra1 *= 2
ls.Extra4 = !ls.Extra4
}
return ls
}
// Functions with self-referential struct
//export CreateNode
func CreateNode(data int) *Node {
return &Node{Data: data, Next: nil}
}
//export LinkNodes
func LinkNodes(first, second *Node) int {
if first != nil && second != nil {
first.Next = second
return first.Data + second.Data // Return sum for verification
}
if first != nil {
return first.Data + 1000 // Return data + offset if only first exists
}
return 2000 // Return fixed value if both are nil
}
//export TraverseNodes
func TraverseNodes(head *Node) int {
count := 0
current := head
for current != nil {
count++
current = current.Next
if count > 100 { // Safety check
break
}
}
return count
}
// Functions covering all basic types
//export ProcessBool
func ProcessBool(b bool) bool {
return !b
}
//export ProcessInt8
func ProcessInt8(x int8) int8 {
return x + 1
}
//export ProcessUint8
func ProcessUint8(x uint8) uint8 {
return x + 1
}
//export ProcessInt16
func ProcessInt16(x int16) int16 {
return x * 2
}
//export ProcessUint16
func ProcessUint16(x uint16) uint16 {
return x * 2
}
//export ProcessInt32
func ProcessInt32(x int32) int32 {
return x * 3
}
//export ProcessUint32
func ProcessUint32(x uint32) uint32 {
return x * 3
}
//export ProcessInt64
func ProcessInt64(x int64) int64 {
return x * 4
}
//export ProcessUint64
func ProcessUint64(x uint64) uint64 {
return x * 4
}
//export ProcessInt
func ProcessInt(x int) int {
return x * 11
}
//export ProcessUint
func ProcessUint(x uint) uint {
return x * 21
}
//export ProcessUintptr
func ProcessUintptr(x uintptr) uintptr {
return x + 300
}
//export ProcessFloat32
func ProcessFloat32(x float32) float32 {
return x * 1.5
}
//export ProcessFloat64
func ProcessFloat64(x float64) float64 {
return x * 2.5
}
//export ProcessString
func ProcessString(s string) string {
return "processed_" + s
}
//export ProcessUnsafePointer
func ProcessUnsafePointer(p unsafe.Pointer) unsafe.Pointer {
return p
}
// Functions with named types
//export ProcessMyInt
func ProcessMyInt(x MyInt) MyInt {
return x * 10
}
//export ProcessMyString
func ProcessMyString(s MyString) MyString {
return MyString("modified_" + string(s))
}
// Functions with arrays, slices, maps, channels
//export ProcessIntArray
func ProcessIntArray(arr [5]int) int {
total := 0
for _, v := range arr {
total += v
}
return total
}
//export CreateComplexData
func CreateComplexData() ComplexData {
return ComplexData{
Matrix: [3][4]int32{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}},
Slices: [][]string{{"helo"}},
IntArray: [5]int{10, 20, 30, 40, 50},
DataList: []float64{1.0},
}
}
//export ProcessComplexData
func ProcessComplexData(data ComplexData) int32 {
// Sum all matrix elements
var sum int32
for i := 0; i < 3; i++ {
for j := 0; j < 4; j++ {
sum += data.Matrix[i][j]
}
}
return sum
}
// Functions with multidimensional arrays as parameters and return values
//export ProcessMatrix2D
func ProcessMatrix2D(matrix [3][4]int32) int32 {
var sum int32
for i := 0; i < 3; i++ {
for j := 0; j < 4; j++ {
sum += matrix[i][j]
}
}
return sum
}
//export CreateMatrix1D
func CreateMatrix1D() [4]int32 {
return [4]int32{1, 2, 3, 4}
}
//export CreateMatrix2D
func CreateMatrix2D() [3][4]int32 {
return [3][4]int32{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}
}
//export ProcessMatrix3D
func ProcessMatrix3D(cube [2][3][4]uint8) uint32 {
var sum uint32
for i := 0; i < 2; i++ {
for j := 0; j < 3; j++ {
for k := 0; k < 4; k++ {
sum += uint32(cube[i][j][k])
}
}
}
return sum
}
//export CreateMatrix3D
func CreateMatrix3D() [2][3][4]uint8 {
var cube [2][3][4]uint8
val := uint8(1)
for i := 0; i < 2; i++ {
for j := 0; j < 3; j++ {
for k := 0; k < 4; k++ {
cube[i][j][k] = val
val++
}
}
}
return cube
}
//export ProcessGrid5x4
func ProcessGrid5x4(grid [5][4]float64) float64 {
var sum float64
for i := 0; i < 5; i++ {
for j := 0; j < 4; j++ {
sum += grid[i][j]
}
}
return sum
}
//export CreateGrid5x4
func CreateGrid5x4() [5][4]float64 {
var grid [5][4]float64
val := 1.0
for i := 0; i < 5; i++ {
for j := 0; j < 4; j++ {
grid[i][j] = val
val += 0.5
}
}
return grid
}
//export ProcessIntSlice
func ProcessIntSlice(slice []int) int {
total := 0
for _, v := range slice {
total += v
}
return total
}
//export ProcessStringMap
func ProcessStringMap(m map[string]int) int {
total := 0
for _, v := range m {
total += v
}
return total
}
//export ProcessIntChannel
func ProcessIntChannel(ch chan int) int {
select {
case val := <-ch:
return val
default:
return -1
}
}
// Functions with function callbacks
//export ProcessWithIntCallback
func ProcessWithIntCallback(x int, callback IntCallback) int {
if callback != nil {
return callback(x)
}
return x
}
//export ProcessWithStringCallback
func ProcessWithStringCallback(s string, callback StringCallback) string {
if callback != nil {
return callback(s)
}
return s
}
//export ProcessWithVoidCallback
func ProcessWithVoidCallback(callback VoidCallback) int {
if callback != nil {
callback()
return 123 // Return non-zero to indicate callback was called
}
return 456 // Return different value if callback is nil
}
//export ProcessThreeUnnamedParams
func ProcessThreeUnnamedParams(a int, s string, b bool) float64 {
result := float64(a) + float64(len(s))
if b {
result *= 1.5
}
return result
}
// Functions with interface
//export ProcessInterface
func ProcessInterface(i interface{}) int {
switch v := i.(type) {
case int:
return v + 100
case string:
return len(v) * 10
default:
return 999 // Non-zero default to avoid false positives
}
}
// Functions with various parameter counts
//export NoParams
func NoParams() int {
return 42
}
//export OneParam
func OneParam(x int) int {
return x * 2
}
//export TwoParams
func TwoParams(a int, b string) string {
return string(rune(a)) + b
}
//export ThreeParams
func ThreeParams(a int32, b float64, c bool) float64 {
result := float64(a) + b
if c {
result *= 2
}
return result
}
//export MultipleParams
func MultipleParams(a int8, b uint16, c int32, d uint64, e float32, f float64, g string, h bool) string {
result := g + "_" + string(rune('A'+a)) + string(rune('0'+b%10)) + string(rune('0'+c%10))
if h {
result += "_true"
}
return result + "_" + string(rune('0'+int(d%10))) + "_" + string(rune('0'+int(e)%10)) + "_" + string(rune('0'+int(f)%10))
}
//export NoParamNames
func NoParamNames(int8, int16, bool) int32 {
return 789 // Return non-zero value for testing, params are unnamed by design
}
// Functions returning no value
//export NoReturn
func NoReturn(message string) {
println("Message:", message)
}
// Functions using XType from c package
//export CreateXType
func CreateXType(id int32, name string, value float64, flag bool) C.XType {
return C.XType{
ID: id,
Name: name,
Value: value,
Flag: flag,
}
}
//export ProcessXType
func ProcessXType(x C.XType) C.XType {
x.ID += 100
x.Name = "processed_" + x.Name
x.Value *= 2.0
x.Flag = !x.Flag
return x
}
//export ProcessXTypePtr
func ProcessXTypePtr(x *C.XType) *C.XType {
if x != nil {
x.ID *= 2
x.Name = "ptr_" + x.Name
x.Value += 10.0
x.Flag = !x.Flag
}
return x
}
func main() {
println("=== Export Demo ===")
// Test small struct
small := CreateSmallStruct(5, true)
assert(small.ID, int8(5), "CreateSmallStruct ID should be 5")
assert(small.Flag, true, "CreateSmallStruct Flag should be true")
println("Small struct:", small.ID, small.Flag)
processed := ProcessSmallStruct(small)
assert(processed.ID, int8(6), "ProcessSmallStruct should increment ID to 6")
assert(processed.Flag, false, "ProcessSmallStruct should flip Flag to false")
println("Processed small:", processed.ID, processed.Flag)
// Test large struct
large := CreateLargeStruct(12345, "test")
assert(large.ID, int64(12345), "CreateLargeStruct ID should be 12345")
assert(large.Name, "test", "CreateLargeStruct Name should be 'test'")
println("Large struct ID:", large.ID, "Name:", large.Name)
total := ProcessLargeStruct(large)
// Expected calculation:
// ID: 12345, Name len: 4, Values: 1+2+3+4+5+6+7+8+9+10=55, Children len: 2
// Extra1: 12345, Extra2: 67890, Extra3: 3, Extra4: +1000, Extra5: 4096
expectedTotal := int64(12345 + 4 + 55 + 2 + 12345 + 67890 + 3 + 1000 + 4096)
assert(total, expectedTotal, "ProcessLargeStruct total should match expected calculation")
println("Large struct total:", total)
// Test self-referential struct
node1 := CreateNode(100)
node2 := CreateNode(200)
linkResult := LinkNodes(node1, node2)
assert(linkResult, 300, "LinkNodes should return sum of node data (100 + 200)")
count := TraverseNodes(node1)
assert(count, 2, "TraverseNodes should count 2 linked nodes")
println("Node count:", count)
// Test basic types with assertions
assert(ProcessBool(true), false, "ProcessBool(true) should return false")
assert(ProcessInt8(10), int8(11), "ProcessInt8(10) should return 11")
f32Result := ProcessFloat32(3.14)
// Float comparison with tolerance
if f32Result < 4.7 || f32Result > 4.72 {
println("ASSERTION FAILED: ProcessFloat32(3.14) should return ~4.71, got:", f32Result)
panic("float assertion failed")
}
println("✓ ProcessFloat32(3.14) returns ~4.71")
assert(ProcessString("hello"), "processed_hello", "ProcessString should prepend 'processed_'")
println("Bool:", ProcessBool(true))
println("Int8:", ProcessInt8(10))
println("Float32:", ProcessFloat32(3.14))
println("String:", ProcessString("hello"))
// Test named types
myInt := ProcessMyInt(MyInt(42))
assert(myInt, MyInt(420), "ProcessMyInt(42) should return 420")
println("MyInt:", int(myInt))
myStr := ProcessMyString(MyString("world"))
assert(myStr, MyString("modified_world"), "ProcessMyString should prepend 'modified_'")
println("MyString:", string(myStr))
// Test collections
arr := [5]int{1, 2, 3, 4, 5}
arrSum := ProcessIntArray(arr)
assert(arrSum, 15, "ProcessIntArray([1,2,3,4,5]) should return 15")
println("Array sum:", arrSum)
slice := []int{10, 20, 30}
sliceSum := ProcessIntSlice(slice)
assert(sliceSum, 60, "ProcessIntSlice([10,20,30]) should return 60")
println("Slice sum:", sliceSum)
m := make(map[string]int)
m["a"] = 100
m["b"] = 200
mapSum := ProcessStringMap(m)
assert(mapSum, 300, "ProcessStringMap({'a':100,'b':200}) should return 300")
println("Map sum:", mapSum)
// Test multidimensional arrays
matrix2d := CreateMatrix2D()
matrix2dSum := ProcessMatrix2D(matrix2d)
assert(matrix2dSum, int32(78), "ProcessMatrix2D should return 78 (sum of 1+2+...+12)")
println("Matrix2D sum:", matrix2dSum)
matrix3d := CreateMatrix3D()
matrix3dSum := ProcessMatrix3D(matrix3d)
assert(matrix3dSum, uint32(300), "ProcessMatrix3D should return 300")
println("Matrix3D sum:", matrix3dSum)
grid5x4 := CreateGrid5x4()
gridSum := ProcessGrid5x4(grid5x4)
assert(gridSum, 115.0, "ProcessGrid5x4 should return 115.0")
println("Grid5x4 sum:", gridSum)
// Test complex data with multidimensional arrays
complexData := CreateComplexData()
complexSum := ProcessComplexData(complexData)
assert(complexSum, int32(78), "ProcessComplexData should return 78")
println("ComplexData matrix sum:", complexSum)
// Test various parameter counts
assert(NoParams(), 42, "NoParams should return 42")
assert(OneParam(5), 10, "OneParam(5) should return 10")
assert(TwoParams(65, "_test"), "A_test", "TwoParams should return 'A_test'")
assert(ThreeParams(10, 2.5, true), 25.0, "ThreeParams should return 25.0")
assert(NoParamNames(1, 2, false), int32(789), "NoParamNames should return 789")
println("NoParams:", NoParams())
println("OneParam:", OneParam(5))
println("TwoParams:", TwoParams(65, "_test"))
println("ThreeParams:", ThreeParams(10, 2.5, true))
println("MultipleParams:", MultipleParams(1, 2, 3, 4, 5.0, 6.0, "result", true))
println("NoParamNames:", NoParamNames(1, 2, false))
// Test XType from c package
xtype := CreateXType(42, "test", 3.14, true)
println("XType:", xtype.ID, xtype.Name, xtype.Value, xtype.Flag)
processedX := ProcessXType(xtype)
println("Processed XType:", processedX.ID, processedX.Name, processedX.Value, processedX.Flag)
ptrX := ProcessXTypePtr(&xtype)
if ptrX != nil {
println("Ptr XType:", ptrX.ID, ptrX.Name, ptrX.Value, ptrX.Flag)
}
// Test callback functions
intResult := ProcessWithIntCallback(10, func(x int) int { return x * 3 })
println("IntCallback result:", intResult)
stringResult := ProcessWithStringCallback("hello", func(s string) string { return s + "_callback" })
println("StringCallback result:", stringResult)
ProcessWithVoidCallback(func() { println("VoidCallback executed") })
NoReturn("demo completed")
}

View File

@@ -0,0 +1,315 @@
/* Code generated by llgo; DO NOT EDIT. */
#ifndef __LIBEXPORT_H_
#define __LIBEXPORT_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
// Platform-specific symbol renaming macro
#ifdef __APPLE__
#define GO_SYMBOL_RENAME(go_name) __asm("_" go_name);
#else
#define GO_SYMBOL_RENAME(go_name) __asm(go_name);
#endif
// Go runtime types
typedef struct { const char *p; intptr_t n; } GoString;
typedef struct { void *data; intptr_t len; intptr_t cap; } GoSlice;
typedef struct { void *data; } GoMap;
typedef struct { void *data; } GoChan;
typedef struct { void *data; void *type; } GoInterface;
typedef struct { float real; float imag; } GoComplex64;
typedef struct { double real; double imag; } GoComplex128;
typedef struct {
int32_t Matrix[3][4];
GoSlice Slices;
intptr_t IntArray[5];
GoSlice DataList;
} main_ComplexData;
typedef struct {
double data[5][4];
} Array_double_5_4;
typedef struct {
int8_t ID;
_Bool Flag;
} main_SmallStruct;
typedef struct {
int64_t ID;
GoString Name;
double Values[10];
GoMap Metadata;
GoSlice Children;
int32_t Extra1;
uint64_t Extra2;
float Extra3;
_Bool Extra4;
uintptr_t Extra5;
} main_LargeStruct;
typedef struct {
int32_t data[4];
} Array_int32_t_4;
typedef struct {
int32_t data[3][4];
} Array_int32_t_3_4;
typedef struct {
uint8_t data[2][3][4];
} Array_uint8_t_2_3_4;
typedef struct main_Node main_Node;
struct main_Node {
intptr_t Data;
main_Node* Next;
};
typedef struct {
int32_t ID;
GoString Name;
double Value;
_Bool Flag;
} C_XType;
typedef intptr_t main_MyInt;
typedef GoString main_MyString;
typedef intptr_t (*main_IntCallback)(intptr_t);
typedef GoString (*main_StringCallback)(GoString);
typedef void (*main_VoidCallback)(void);
GoString
Concat(GoString a, GoString b);
int64_t
Sub(int64_t a, int64_t b);
intptr_t
Add(intptr_t a, intptr_t b);
float
mul(float a, float b);
void
github_com_goplus_llgo__demo_go_export_c_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/_demo/go/export/c.init")
main_ComplexData
CreateComplexData(void);
Array_double_5_4
CreateGrid5x4(void);
main_LargeStruct
CreateLargeStruct(int64_t id, GoString name);
Array_int32_t_4
CreateMatrix1D(void);
Array_int32_t_3_4
CreateMatrix2D(void);
Array_uint8_t_2_3_4
CreateMatrix3D(void);
main_Node*
CreateNode(intptr_t data);
main_SmallStruct
CreateSmallStruct(int8_t id, _Bool flag);
C_XType
CreateXType(int32_t id, GoString name, double value, _Bool flag);
void
HelloWorld(void);
intptr_t
LinkNodes(main_Node* first, main_Node* second);
GoString
MultipleParams(int8_t a, uint16_t b, int32_t c, uint64_t d, float e, double f, GoString g, _Bool h);
int32_t
NoParamNames(int8_t, int16_t, _Bool);
intptr_t
NoParams(void);
void
NoReturn(GoString message);
intptr_t
OneParam(intptr_t x);
_Bool
ProcessBool(_Bool b);
int32_t
ProcessComplexData(main_ComplexData data);
float
ProcessFloat32(float x);
double
ProcessFloat64(double x);
double
ProcessGrid5x4(double grid[5][4]);
intptr_t
ProcessInt(intptr_t x);
int16_t
ProcessInt16(int16_t x);
int32_t
ProcessInt32(int32_t x);
int64_t
ProcessInt64(int64_t x);
int8_t
ProcessInt8(int8_t x);
intptr_t
ProcessIntArray(intptr_t* arr);
intptr_t
ProcessIntChannel(GoChan ch);
intptr_t
ProcessIntSlice(GoSlice slice);
intptr_t
ProcessInterface(GoInterface i);
int64_t
ProcessLargeStruct(main_LargeStruct ls);
main_LargeStruct*
ProcessLargeStructPtr(main_LargeStruct* ls);
int32_t
ProcessMatrix2D(int32_t matrix[3][4]);
uint32_t
ProcessMatrix3D(uint8_t cube[2][3][4]);
main_MyInt
ProcessMyInt(main_MyInt x);
main_MyString
ProcessMyString(main_MyString s);
main_SmallStruct
ProcessSmallStruct(main_SmallStruct s);
main_SmallStruct*
ProcessSmallStructPtr(main_SmallStruct* s);
GoString
ProcessString(GoString s);
intptr_t
ProcessStringMap(GoMap m);
double
ProcessThreeUnnamedParams(intptr_t a, GoString s, _Bool b);
uintptr_t
ProcessUint(uintptr_t x);
uint16_t
ProcessUint16(uint16_t x);
uint32_t
ProcessUint32(uint32_t x);
uint64_t
ProcessUint64(uint64_t x);
uint8_t
ProcessUint8(uint8_t x);
uintptr_t
ProcessUintptr(uintptr_t x);
void*
ProcessUnsafePointer(void* p);
intptr_t
ProcessWithIntCallback(intptr_t x, main_IntCallback callback);
GoString
ProcessWithStringCallback(GoString s, main_StringCallback callback);
intptr_t
ProcessWithVoidCallback(main_VoidCallback callback);
C_XType
ProcessXType(C_XType x);
C_XType*
ProcessXTypePtr(C_XType* x);
double
ThreeParams(int32_t a, double b, _Bool c);
intptr_t
TraverseNodes(main_Node* head);
GoString
TwoParams(intptr_t a, GoString b);
void
github_com_goplus_llgo__demo_go_export_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/_demo/go/export.init")
void
github_com_goplus_llgo_runtime_abi_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/abi.init")
void
github_com_goplus_llgo_runtime_internal_clite_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite.init")
void
github_com_goplus_llgo_runtime_internal_clite_bdwgc_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite/bdwgc.init")
void
github_com_goplus_llgo_runtime_internal_clite_bitcast_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite/bitcast.init")
void
github_com_goplus_llgo_runtime_internal_clite_debug_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite/debug.init")
void
github_com_goplus_llgo_runtime_internal_clite_pthread_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite/pthread.init")
void
github_com_goplus_llgo_runtime_internal_clite_pthread_sync_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/clite/pthread/sync.init")
void
github_com_goplus_llgo_runtime_internal_runtime_goarch_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/runtime/goarch.init")
void
github_com_goplus_llgo_runtime_internal_runtime_math_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/runtime/math.init")
void
github_com_goplus_llgo_runtime_internal_runtime_init(void) GO_SYMBOL_RENAME("github.com/goplus/llgo/runtime/internal/runtime.init")
#ifdef __cplusplus
}
#endif
#endif /* __LIBEXPORT_H_ */

278
_demo/go/export/test.sh Executable file
View File

@@ -0,0 +1,278 @@
#!/bin/bash
# Test script for C header generation in different build modes
# This script tests the header generation functionality with various buildmode options
set -e # Exit on any error
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Function to check if file exists and is not empty
check_file() {
local file="$1"
local description="$2"
if [[ -f "$file" ]]; then
if [[ -s "$file" ]]; then
print_status "$description exists and is not empty"
return 0
else
print_error "$description exists but is empty"
return 1
fi
else
print_error "$description does not exist"
return 1
fi
}
# Function to compare header with expected content
compare_header() {
local header_file="$1"
local expected_file="$2"
local test_name="$3"
if [[ -f "$expected_file" ]]; then
if diff -q "$header_file" "$expected_file" >/dev/null 2>&1; then
print_status "$test_name: Header content matches expected"
return 0
else
print_warning "$test_name: Header content differs from expected"
print_warning "Run 'diff $header_file $expected_file' to see differences"
return 1
fi
else
print_warning "$test_name: No expected file found at $expected_file"
print_status "Generated header content:"
echo "--- START OF HEADER ---"
cat "$header_file"
echo "--- END OF HEADER ---"
return 0
fi
}
# Function to cleanup generated files
cleanup() {
local files=("$@")
for file in "${files[@]}"; do
if [[ -f "$file" ]]; then
rm -f "$file"
print_status "Cleaned up $file"
fi
done
}
# Check if llgo.sh exists
LLGO_SCRIPT="../../../llgo.sh"
if [[ ! -f "$LLGO_SCRIPT" ]]; then
print_error "llgo.sh not found at $LLGO_SCRIPT"
exit 1
fi
print_status "Starting C header generation tests..."
print_status "Working directory: $SCRIPT_DIR"
echo ""
# Test 1: c-shared mode
print_status "=== Test 2: Building with -buildmode c-shared ==="
if $LLGO_SCRIPT build -buildmode c-shared -o export .; then
print_status "Build succeeded"
# Check generated files (different extensions on different platforms)
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
check_file "libexport.dylib" "Dynamic library (libexport.dylib)"
SHARED_LIB="libexport.dylib"
else
# Linux and others
check_file "libexport.so" "Dynamic library (libexport.so)"
SHARED_LIB="libexport.so"
fi
check_file "libexport.h" "C header (libexport.h)"
# Compare with expected header if it exists
if [[ -f "libexport.h" ]]; then
compare_header "libexport.h" "libexport.h.want" "c-shared"
fi
# Test C demo with shared library
print_status "=== Testing C demo with shared library ==="
if cd use; then
if LINK_TYPE=shared make clean && LINK_TYPE=shared make; then
print_status "C demo build succeeded with shared library"
if LINK_TYPE=shared make run; then
print_status "C demo execution succeeded with shared library"
else
print_warning "C demo execution failed with shared library"
fi
else
print_warning "C demo build failed with shared library"
fi
cd ..
else
print_error "Failed to enter use directory"
fi
# Cleanup
cleanup "$SHARED_LIB" "libexport.h"
else
print_error "Build failed for c-shared mode"
fi
# Test 2: c-archive mode
print_status "=== Test 1: Building with -buildmode c-archive ==="
if $LLGO_SCRIPT build -buildmode c-archive -o export .; then
print_status "Build succeeded"
# Check generated files
check_file "libexport.a" "Static library (libexport.a)"
check_file "libexport.h" "C header (libexport.h)"
# Compare with expected header if it exists
if [[ -f "libexport.h" ]]; then
compare_header "libexport.h" "libexport.h.want" "c-archive"
fi
# Test C demo with static library
print_status "=== Testing C demo with static library ==="
if cd use; then
if make clean && make; then
print_status "C demo build succeeded with static library"
if make run; then
print_status "C demo execution succeeded with static library"
else
print_warning "C demo execution failed with static library"
fi
else
print_warning "C demo build failed with static library"
fi
cd ..
else
print_error "Failed to enter use directory"
fi
# # Cleanup
# cleanup "libexport.a" "libexport.h"
else
print_error "Build failed for c-archive mode"
fi
echo ""
# TODO(lijie): Uncomment if https://github.com/goplus/llgo/pull/1268 merged
# # Test 3: ESP32 target with c-archive mode
# print_status "=== Test 3: Building with -target esp32 -buildmode c-archive ==="
# if $LLGO_SCRIPT build -target esp32 -buildmode c-archive -o export .; then
# print_status "Build succeeded"
# # Check generated files
# check_file "libexport.a" "Static library for ESP32 (libexport.a)"
# check_file "libexport.h" "C header for ESP32 (libexport.h)"
# # Compare with expected header if it exists
# if [[ -f "libexport.h" ]]; then
# compare_header "libexport.h" "libexport.h.want" "esp32-c-archive"
# fi
# # Don't cleanup ESP32 files - keep them for inspection
# print_status "ESP32 build files kept for inspection"
# else
# print_error "Build failed for ESP32 target"
# fi
# echo ""
# Test 3: Go export demo execution
print_status "=== Test 3: Running Go export demo ==="
if go run export.go > /tmp/go_export_output.log 2>&1; then
print_status "Go export demo execution succeeded"
# Check if output contains expected success indicators
if grep -q "✓" /tmp/go_export_output.log; then
SUCCESS_COUNT=$(grep -c "✓" /tmp/go_export_output.log)
print_status "All $SUCCESS_COUNT assertions passed in Go export demo"
else
print_warning "No assertion markers found in Go export demo output"
fi
# Show key output lines
print_status "Go export demo output summary:"
if grep -q "ASSERTION FAILED" /tmp/go_export_output.log; then
print_error "Found assertion failures in Go export demo"
grep "ASSERTION FAILED" /tmp/go_export_output.log
else
print_status " ✅ No assertion failures detected"
echo " 📊 First few lines of output:"
head -5 /tmp/go_export_output.log | sed 's/^/ /'
echo " 📊 Last few lines of output:"
tail -5 /tmp/go_export_output.log | sed 's/^/ /'
fi
else
print_error "Go export demo execution failed"
print_error "Error output:"
cat /tmp/go_export_output.log | sed 's/^/ /'
fi
# Cleanup temporary file
rm -f /tmp/go_export_output.log
echo ""
# Final summary
print_status "=== Test Summary ==="
if [[ -f "libexport.a" ]] && [[ -f "libexport.h" ]]; then
print_status "All tests completed successfully:"
print_status " ✅ Go export demo execution with assertions"
print_status " ✅ C header generation (c-archive and c-shared modes)"
print_status " ✅ C demo compilation and execution"
print_status " ✅ Cross-platform symbol renaming"
print_status " ✅ Init function export and calling"
print_status " ✅ Function callback types with proper typedef syntax"
print_status " ✅ Multidimensional array parameter handling"
print_status ""
print_status "Final files available:"
print_status " - libexport.a (static library)"
print_status " - libexport.h (C header file)"
print_status " - use/main.out (C demo executable)"
echo ""
echo "==================="
else
print_error "Some tests may have failed. Check the output above."
fi
# Show file sizes for reference
if [[ -f "libexport.a" ]]; then
SIZE=$(wc -c < libexport.a)
print_status "Static library size: $SIZE bytes"
fi
if [[ -f "libexport.h" ]]; then
LINES=$(wc -l < libexport.h)
print_status "Header file lines: $LINES"
fi
print_status "C header generation and demo tests completed!"

Some files were not shown because too many files have changed in this diff Show More