[PR #2042] [MERGED] fix(build): resolve Rust-to-C linking issues on Linux #2849

Closed
opened 2026-01-29 17:24:14 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/2042
Author: @cfsmp3
Created: 1/19/2026
Status: Merged
Merged: 1/19/2026
Merged by: @cfsmp3

Base: masterHead: fix/cmake-rust-linking


📝 Commits (2)

  • 2352ea2 fix(build): resolve Rust-to-C linking issues on Linux
  • df90009 ci: add CMakeLists.txt to workflow path filters

📊 Changes

6 files changed (+27 additions, -2 deletions)

View changed files

📝 .github/workflows/build_docker.yml (+4 -0)
📝 .github/workflows/build_linux.yml (+4 -0)
📝 .github/workflows/build_mac.yml (+4 -0)
📝 .github/workflows/build_windows.yml (+4 -0)
📝 src/CMakeLists.txt (+9 -0)
📝 src/lib_ccx/CMakeLists.txt (+2 -2)

📄 Description

Summary

  • Preserve CMAKE_C_FLAGS in lib_ccx/CMakeLists.txt instead of overwriting
  • Add linker options to force C symbols needed by Rust code to be pulled in

Problem

On Linux, the build fails with undefined reference errors:

undefined reference to `decode_vbi'
undefined reference to `do_cb'
undefined reference to `store_hdcc'

These C functions are defined in libccx.a but called from ccx_rust (Rust library). With static libraries, the linker processes them in order and only pulls symbols that are currently unresolved. Since ccx is processed before ccx_rust, these symbols weren't being included.

Solution

  1. CMAKE_C_FLAGS preservation: Change set(CMAKE_C_FLAGS "...") to set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ...") so build systems can pass additional flags.

  2. Force undefined symbols: Add target_link_options with -Wl,--undefined=<symbol> to force the linker to mark these symbols as needed before processing libccx.a.

Test plan

  • Build completes successfully on Linux
  • ccextractor --version runs without errors

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/2042 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 1/19/2026 **Status:** ✅ Merged **Merged:** 1/19/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/cmake-rust-linking` --- ### 📝 Commits (2) - [`2352ea2`](https://github.com/CCExtractor/ccextractor/commit/2352ea21e3ab0a403efe38ddbe6e2b5cf32f9e83) fix(build): resolve Rust-to-C linking issues on Linux - [`df90009`](https://github.com/CCExtractor/ccextractor/commit/df90009f73492abebb6a6445e8061a096b6e1cf8) ci: add CMakeLists.txt to workflow path filters ### 📊 Changes **6 files changed** (+27 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/build_docker.yml` (+4 -0) 📝 `.github/workflows/build_linux.yml` (+4 -0) 📝 `.github/workflows/build_mac.yml` (+4 -0) 📝 `.github/workflows/build_windows.yml` (+4 -0) 📝 `src/CMakeLists.txt` (+9 -0) 📝 `src/lib_ccx/CMakeLists.txt` (+2 -2) </details> ### 📄 Description ## Summary - Preserve CMAKE_C_FLAGS in lib_ccx/CMakeLists.txt instead of overwriting - Add linker options to force C symbols needed by Rust code to be pulled in ## Problem On Linux, the build fails with undefined reference errors: ``` undefined reference to `decode_vbi' undefined reference to `do_cb' undefined reference to `store_hdcc' ``` These C functions are defined in `libccx.a` but called from `ccx_rust` (Rust library). With static libraries, the linker processes them in order and only pulls symbols that are currently unresolved. Since `ccx` is processed before `ccx_rust`, these symbols weren't being included. ## Solution 1. **CMAKE_C_FLAGS preservation**: Change `set(CMAKE_C_FLAGS "...")` to `set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ...")` so build systems can pass additional flags. 2. **Force undefined symbols**: Add `target_link_options` with `-Wl,--undefined=<symbol>` to force the linker to mark these symbols as needed before processing `libccx.a`. ## Test plan - [x] Build completes successfully on Linux - [x] `ccextractor --version` runs without errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:24:14 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2849