Compare commits

...

4 Commits

Author SHA1 Message Date
Jin Hai
cb93883f3f Go: fix cgo build (#16724)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-07 21:15:14 +08:00
Jin Hai
2b95fa2ba4 Go: remove cgo when build cli (#16723)
### Summary

Fix

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-07 21:05:07 +08:00
Jin Hai
fe835fd19c Go: fix release (#16722)
### Summary

Remove ragflow-cli building dependency

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-07 20:57:48 +08:00
Jin Hai
9e87fc6036 Go: fix ragflow-cli building (#16721) 2026-07-07 20:44:10 +08:00
2 changed files with 8 additions and 58 deletions

View File

@@ -424,27 +424,7 @@ jobs:
output="${DIST_DIR}/${CLI_NAME}-${RELEASE_TAG}-${{ matrix.goos }}-${{ matrix.goarch }}"
echo "Building ${{ matrix.goos }}/${{ matrix.goarch }} -> ${output}"
case "${{ matrix.goos }}" in
linux)
cgo_ldflags="${OFFICE_OXIDE_PREFIX}/lib/liboffice_oxide.a -lm -ldl -lpthread"
;;
darwin)
cgo_ldflags="${OFFICE_OXIDE_PREFIX}/lib/liboffice_oxide.a"
;;
*)
echo "::error::Unsupported Unix target: ${{ matrix.goos }}"
exit 1
;;
esac
cgo_cflags="-I${OFFICE_OXIDE_PREFIX}/include -I${OFFICE_OXIDE_PREFIX}/include/office_oxide_c"
echo "office_oxide prefix: ${OFFICE_OXIDE_PREFIX}"
echo "CGO_CFLAGS: ${cgo_cflags}"
echo "CGO_LDFLAGS: ${cgo_ldflags}"
CGO_ENABLED=1 \
CGO_CFLAGS="${cgo_cflags}" \
CGO_LDFLAGS="${cgo_ldflags}" \
CGO_ENABLED=0 \
GOOS="${{ matrix.goos }}" \
GOARCH="${{ matrix.goarch }}" \
go build \
@@ -455,15 +435,6 @@ jobs:
chmod +x "${output}"
if [[ "${{ matrix.goos }}" == "linux" ]] && command -v ldd >/dev/null 2>&1; then
if ldd "${output}" 2>&1 | grep -q "liboffice_oxide"; then
echo "::error::linux CLI unexpectedly links liboffice_oxide dynamically"
ldd "${output}" || true
exit 1
fi
echo "Verified linux CLI does not require liboffice_oxide.so at runtime"
fi
- name: Build Go CLI release binaries
if: runner.os == 'Windows'
shell: pwsh
@@ -478,7 +449,6 @@ jobs:
$output = Join-Path $env:DIST_DIR "${env:CLI_NAME}-${env:RELEASE_TAG}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.output_ext }}"
Write-Host "Building ${{ matrix.goos }}/${{ matrix.goarch }} -> $output"
$officeOxidePrefix = $env:OFFICE_OXIDE_PREFIX -replace "\\", "/"
$cc = $env:CC
if ([string]::IsNullOrWhiteSpace($cc)) {
Write-Error "CC is not set"
@@ -488,35 +458,14 @@ jobs:
Write-Error "C compiler does not exist: $cc"
exit 1
}
if (-not (Test-Path "${officeOxidePrefix}/lib/liboffice_oxide.a")) {
Write-Error "liboffice_oxide.a does not exist: ${officeOxidePrefix}/lib/liboffice_oxide.a"
exit 1
}
if (-not (Test-Path "internal/binding/cpp/cmake-build-release/librag_tokenizer_c_api.a")) {
Write-Error "librag_tokenizer_c_api.a does not exist"
exit 1
}
if ([string]::IsNullOrWhiteSpace($env:PCRE2_LIBDIR) -or -not (Test-Path $env:PCRE2_LIBDIR)) {
Write-Error "PCRE2_LIBDIR is not set or does not exist: $env:PCRE2_LIBDIR"
exit 1
}
$ragTokenizerLib = (Resolve-Path "internal/binding/cpp/cmake-build-release/librag_tokenizer_c_api.a").Path -replace '\\', '/'
$pcre2LibDir = $env:PCRE2_LIBDIR -replace '\\', '/'
$pcre2IncludeDir = $env:PCRE2_INCLUDEDIR -replace '\\', '/'
$env:CGO_ENABLED = "1"
$env:CGO_ENABLED = "0"
$env:CC = $cc
$env:CGO_CFLAGS = "-I${officeOxidePrefix}/include -I${officeOxidePrefix}/include/office_oxide_c -I${pcre2IncludeDir}"
$env:CGO_LDFLAGS = "${officeOxidePrefix}/lib/liboffice_oxide.a ${ragTokenizerLib} -L${pcre2LibDir} -lpcre2-8 -lc++ -static -static-libgcc -static-libstdc++ -lws2_32 -lbcrypt -lntdll -luserenv -ladvapi32"
$env:GOOS = "${{ matrix.goos }}"
$env:GOARCH = "${{ matrix.goarch }}"
Write-Host "CC: $env:CC"
& $env:CC --version
Write-Host "office_oxide prefix: $officeOxidePrefix"
Write-Host "CGO_CFLAGS: $env:CGO_CFLAGS"
Write-Host "CGO_LDFLAGS: $env:CGO_LDFLAGS"
go build `
-trimpath `

View File

@@ -301,21 +301,22 @@ build_go() {
local strip_flags=()
[ -n "$STRIP_SYMBOLS" ] && strip_flags=(-ldflags="-s -w")
echo "Building RAGFlow binary: $RAGFLOW_SERVER_BINARY, and $RAGFLOW_CLI_BINARY"
echo "Building RAGFlow binary: $RAGFLOW_CLI_BINARY and $RAGFLOW_SERVER_BINARY"
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct}
go build "${strip_flags[@]}" -o "$RAGFLOW_CLI_BINARY" cmd/ragflow-cli.go
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
go build "${strip_flags[@]}" -o "$RAGFLOW_SERVER_BINARY" cmd/ragflow_server.go
GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \
CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \
go build "${strip_flags[@]}" -o "$RAGFLOW_CLI_BINARY" cmd/ragflow-cli.go
if [ ! -f "$RAGFLOW_SERVER_BINARY" ]; then
echo -e "${RED}Error: Failed to build RAGFlow main binary${NC}"
exit 1
fi
echo -e "${GREEN}✓ Go ragflow_server built successfully: $RAGFLOW_SERVER_BINARY${NC}"
echo -e "${GREEN}✓ Go ragflow-cli built successfully: $RAGFLOW_CLI_BINARY${NC}"
echo -e "${GREEN}✓ Go ragflow_server built successfully: $RAGFLOW_SERVER_BINARY${NC}"
}
# Configure CGO flags for native libraries (office_oxide, pdfium, pdf_oxide).