Repository navigation
Fix: use .a to replace .so for pdfium/pdf_oxide/office_oxide - #16496
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesStatic Native Library Migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@build.sh`:
- Around line 188-230: The check_pdfium_deps function currently reports success
once libpdfium.a exists, but on Linux setup_cgo_env also requires libc++.a and
libc++abi.a, so a partial extraction can slip through and fail later. Update
check_pdfium_deps to validate the Linux-specific archive set before returning
success by checking the extra required libraries after _download_and_extract and
only printing the installed message when all expected files are present; use the
existing check_pdfium_deps and setup_cgo_env symbols to keep the behavior
aligned across the install and link paths.
In `@internal/deepdoc/parser/pdf/pdfium/pdfium.go`:
- Around line 7-8: The CGO linker flags in pdfium.go are applied
unconditionally, which causes unsupported flags like -ldl to be used on Darwin
builds. Update the cgo directives near the package header to make the LDFLAGS
OS-specific, separating the Linux and macOS cases so each platform only receives
compatible linker flags.
In `@internal/development.md`:
- Line 30: The guidance in the development docs incorrectly tells new users to
start with build.sh --go, but that path still fails when
build/librag_tokenizer_c_api.a has not been generated yet. Update the note near
the run/debug instructions to direct fresh checkouts to run a build that creates
the native library first, such as build.sh --cpp or build.sh --all, and only
then use build.sh --go for Go-based run/debug workflows.
- Around line 33-43: The CGO linker example in the development docs mixes
Linux-only flags with macOS PLATFORM values, so update the setup around the
CGO_LDFLAGS example to be OS-specific. Split the manual export snippet into
separate Linux and darwin variants, and align the listed libraries/flags with
what setup_cgo_env() uses for each target so the example matches the correct
linker line for linux_amd64, linux_arm64, darwin_amd64, and darwin_arm64.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b1776b48-ffb3-4303-a099-a995a913efe4
📒 Files selected for processing (3)
build.shinternal/deepdoc/parser/pdf/pdfium/pdfium.gointernal/development.md
GNU ld 2.42 cannot merge .eh_frame sections produced by Chromium's Clang toolchain, causing linker errors for all kognitos/pdfium-static archives (libpdfium.a, libc++.a, libc++abi.a). Use -fuse-ld=lld to invoke LLVM's linker which handles these sections correctly. This requires lld to be installed (apt install lld). Co-Authored-By: Claude <[email protected]>
Both pdf_oxide and office_oxide are Rust staticlibs that embed the Rust runtime (rust_eh_personality). When statically linked together into the same binary, ld reports duplicate symbol errors. Co-Authored-By: Claude <[email protected]>
a8baadc to
cf3712f
Compare
These tests were excluded by PR infiniflow#16505 because the old .so-based build required system-native libraries at test-compile time. With the switch to static linking (.a + -fuse-ld=lld), these packages compile and pass correctly. Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
build.sh (2)
157-172: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd an unsupported-OS branch before building the office_oxide URL.
If
uname -sis neitherLinuxnorDarwin,asset_nameis never assigned before Line 174, producing an invalid release URL or an unbound-variable failure.Proposed fix
case "$(uname -s)" in Linux) case "$(uname -m)" in x86_64) asset_name="native-linux-x86_64" ;; aarch64|arm64) asset_name="native-linux-aarch64" ;; *) echo -e "${RED}Unsupported arch: $(uname -m)${NC}"; exit 1 ;; esac ;; Darwin) case "$(uname -m)" in x86_64) asset_name="native-macos-x86_64" ;; aarch64|arm64) asset_name="native-macos-aarch64" ;; *) echo -e "${RED}Unsupported arch: $(uname -m)${NC}"; exit 1 ;; esac ;; + *) echo -e "${RED}Unsupported OS: $(uname -s)${NC}"; exit 1 ;; esac🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@build.sh` around lines 157 - 172, The OS selection logic in the shell script only handles Linux and Darwin, so `asset_name` can remain unset before the office_oxide download URL is built. Update the `uname -s` switch in `build.sh` to include an explicit unsupported-OS branch alongside the existing `asset_name` assignments, and fail fast with a clear error before any URL construction happens. Use the same pattern as the current architecture checks so the `asset_name` variable is always defined or the script exits cleanly.
179-183: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRe-validate the office_oxide header after extraction.
The first check requires both the static archive and
office_oxide.h, but the install path reports success when onlyliboffice_oxide.aexists. A partial extract can fail later at CGO compile time.Proposed fix
- if [ ! -f "$lib_path" ]; then - echo -e "${RED}Error: Failed to install office_oxide native library (missing ${lib_path})${NC}" + if [ ! -f "$lib_path" ] || [ ! -f "$header_path" ]; then + echo -e "${RED}Error: Failed to install office_oxide native library (missing ${lib_path} or ${header_path})${NC}" echo " Try: curl -fsSL ${release_url} | tar xzf - -C ${OFFICE_OXIDE_PREFIX}" exit 1 fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@build.sh` around lines 179 - 183, The office_oxide install check only verifies the static archive after extraction, so update the install flow to also re-validate that office_oxide.h exists before reporting success. In the build.sh extraction path around the lib_path check, add a second presence check for the header alongside the existing archive validation, and fail with the same error/exit behavior if either artifact is missing so partial extracts are caught before CGO compilation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@build.sh`:
- Around line 410-414: The Linux linker flags in build.sh are always adding
-fuse-ld=lld, which breaks builds on hosts without LLVM’s linker. Update the
Linux branch that exports CGO_LDFLAGS to first check for ld.lld with command -v
before appending the lld-specific flag, and keep the rest of the PDFium linker
flags unchanged. Use the existing uname -s Linux guard and the CGO_LDFLAGS
export block to place this check.
---
Outside diff comments:
In `@build.sh`:
- Around line 157-172: The OS selection logic in the shell script only handles
Linux and Darwin, so `asset_name` can remain unset before the office_oxide
download URL is built. Update the `uname -s` switch in `build.sh` to include an
explicit unsupported-OS branch alongside the existing `asset_name` assignments,
and fail fast with a clear error before any URL construction happens. Use the
same pattern as the current architecture checks so the `asset_name` variable is
always defined or the script exits cleanly.
- Around line 179-183: The office_oxide install check only verifies the static
archive after extraction, so update the install flow to also re-validate that
office_oxide.h exists before reporting success. In the build.sh extraction path
around the lib_path check, add a second presence check for the header alongside
the existing archive validation, and fail with the same error/exit behavior if
either artifact is missing so partial extracts are caught before CGO
compilation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e4776399-eed1-42a9-a1aa-1c8d37d452e2
📒 Files selected for processing (3)
build.shinternal/deepdoc/parser/pdf/pdfium/pdfium.gointernal/development.md
🚧 Files skipped from review as they are similar to previous changes (2)
- internal/deepdoc/parser/pdf/pdfium/pdfium.go
- internal/development.md
Add _seed_from_system() to copy pre-installed native static libs from /opt/ragflow-deps/ to ~/ragflow-deps/ before attempting download. CI runner images that pre-bake these files will skip network access. Co-Authored-By: Claude <[email protected]>
build.sh now only checks /opt/ragflow-deps/ (system) and ~/ragflow-deps/ (local cache). If libraries are missing, it prints a clear error pointing to download_deps.py. Download is handled by download_deps.py (CI images) or manually. Co-Authored-By: Claude <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16496 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Use .a to replace .so for pdfium/pdf_oxide/office_oxide