Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ on:
- "go/**"
- "include/**"
- "ts/**"
- ".github/workflows/ci.yml"
pull_request:
paths:
- "go/**"
- "include/**"
- "ts/**"
- ".github/workflows/ci.yml"
workflow_dispatch:

jobs:
Expand All @@ -22,6 +24,13 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Run regression tests
- name: Verify generated Go API without CGO
working-directory: go
run: CGO_ENABLED=1 go test -v ./...
env:
CGO_ENABLED: "0"
run: go test ./...
- name: Run native regression tests
working-directory: go
env:
CGO_ENABLED: "1"
run: go test -v ./...
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ CSTX (CyberSpace Topology eXchange) — 赛博空间拓扑表达协议。将安
go get github.com/chainreactors/libcstx/go
```

Build (requires CGO for static FFI linkage):
The native `Graph`, `CASStore`, `Parse`, and `Transform` APIs require CGO. Build
consumers of those APIs with:

```bash
CGO_ENABLED=1 go build ./...
```

With `CGO_ENABLED=0`, the package only exposes the generated SCO/SRO data types
and their JSON helpers. Native graph, CAS, parsing, and transform functionality
is intentionally unavailable rather than replaced by a no-op fallback.

Cross-compile or target older Linux (avoid glibc version issues):

```bash
Expand All @@ -32,6 +37,12 @@ CGO_ENABLED=1 CC="zig cc -target x86_64-linux-gnu.2.17" CXX="zig c++ -target x86

> Go + CGO 在编译时会绑定宿主系统的 glibc 版本(如 `pthread_create` 在 glibc 2.34 后从 `libpthread` 合并到 `libc.so`)。如果产物需要在较旧的 Linux 上运行,使用 [zig](https://ziglang.org/) 作为 CC 可以将 glibc 依赖锁定到指定版本。

The bundled `libcstx_ffi.a` archives statically package the Rust FFI library,
but they do not guarantee that the final Go executable is fully static. The C
toolchain may still add a dynamic loader or shared system libraries. Scratch or
other libc-free images must use explicit external static linking and verify the
resulting ELF has neither an interpreter nor `NEEDED` entries before release.

### Python

```bash
Expand Down
2 changes: 2 additions & 0 deletions go/graph_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build cgo

package cstx

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions go/transform.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build cgo

package cstx

import (
Expand Down
Loading