Skip to content

Remove logger dependency on libccf - #7977

Merged
achamayou merged 17 commits into
mainfrom
copilot/remove-logger-dependency-libccf
Jul 13, 2026
Merged

Remove logger dependency on libccf#7977
achamayou merged 17 commits into
mainfrom
copilot/remove-logger-dependency-libccf

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Closes #7596.

logger.h pulled in get_current_thread_id() from libccf.a, creating an implicit circular dependency for libraries such as ccfcrypto that are themselves dependencies of ccf.

  • Thread ID ownership

    • Moved thread ID state and helpers into src/threading/thread_ids.cpp, compiled into the new ccf_threading library, so logger users share a single implementation without linking libccf.
    • Preserved existing APIs: get_current_thread_id(), set_current_thread_id(), and reset_thread_id_generator().
  • Build graph cleanup

    • Removed src/enclave/thread_local.cpp.
    • Removed CMake references that explicitly compiled thread_local.cpp into tests, benchmarks, and tools.
    • Removed the app linker workaround forcing get_current_thread_id resolution from ccf.
  • Coverage

    • Added a focused logger unit test for thread ID assignment, reset, and per-thread initialization.

Library dependency graphs

The graphs show every CCF library that directly uses the logger or thread-ID APIs and the internal CMake edges that connect them. Logger-independent or vendored library targets (http_parser, quickjs, and evercbor) are omitted. Arrows point from a library to a library it depends on. Solid arrows are existing CMake links, dashed arrows are undeclared symbol dependencies, and thick arrows are the new public links.

In the Before graph, the thread-ID symbols are drawn separately from ccf / libccf.a even though they were defined in that archive. This keeps both sides of the circular dependency visible without routing every dashed edge back through the ccf node.

Before

flowchart TB
  ccf["ccf / libccf.a"]
  launcher["ccf_launcher"]
  pal["ccf_pal"]
  js["ccf_js"]
  endpoints["ccf_endpoints"]
  crypto["ccfcrypto"]
  kv["ccf_kv"]
  tasks["ccf_tasks"]
  thread_ids["thread-ID symbols<br/>defined in libccf.a"]

  launcher --> crypto
  pal --> crypto
  js --> crypto
  js --> pal
  endpoints --> crypto
  endpoints --> kv
  ccf --> js
  ccf --> endpoints
  ccf --> crypto
  ccf --> kv
  ccf --> tasks
  ccf --> pal

  launcher -.-> thread_ids
  pal -.-> thread_ids
  js -.-> thread_ids
  endpoints -.-> thread_ids
  crypto -.-> thread_ids
  kv -.-> thread_ids
  tasks -.-> thread_ids
Loading

For libraries that ccf links, the undeclared thread-ID symbol dependencies complete cycles back into libccf.a. ccf_launcher had the same undeclared dependency; CCF applications linked both libraries and required the linker workaround to force get_current_thread_id() out of libccf.a.

After

flowchart TB
  ccf["ccf / libccf.a"]
  launcher["ccf_launcher"]
  pal["ccf_pal"]
  js["ccf_js"]
  endpoints["ccf_endpoints"]
  crypto["ccfcrypto"]
  kv["ccf_kv"]
  tasks["ccf_tasks"]
  threading["ccf_threading<br/>owns thread_ids.cpp"]

  launcher --> crypto
  pal --> crypto
  js --> crypto
  js --> pal
  endpoints --> crypto
  endpoints --> kv
  ccf --> js
  ccf --> endpoints
  ccf --> crypto
  ccf --> kv
  ccf --> tasks
  ccf --> pal

  crypto ==> threading
  kv ==> threading
  tasks ==> threading
Loading

ccf_threading is now the leaf dependency that provides the thread-ID symbols. The three new public links give every other logger-using library a transitive path to it, so none depends back on ccf.

Copilot AI and others added 2 commits June 24, 2026 21:28
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove logger dependency on libccf.a to resolve circular issues Remove logger dependency on libccf Jun 24, 2026
Copilot AI requested a review from achamayou June 24, 2026 21:31
@achamayou

Copy link
Copy Markdown
Member

@copilot that feels like it's going to lead to duplicated symbols, especially if applications include logger.h too.

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot that feels like it's going to lead to duplicated symbols, especially if applications include logger.h too.

Moved the thread ID implementation back out of the header and into a single object compiled into ccfcrypto, so logger.h no longer owns inline state while still avoiding the libccf dependency. Addressed in aca4c8b.

Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
achamayou and others added 6 commits June 26, 2026 09:25
The logger headers (ccf/ds/logger.h) call
ccf::threading::get_current_thread_id, whose definition previously lived in
libccf. Low-level libraries such as ccfcrypto use the logger but are themselves
dependencies of ccf, creating an implicit circular dependency that was worked
around with a per-app linker flag and by compiling the thread-id source into
individual test/bench/tool binaries.

Move the implementation into a new ccf_threading static library
(cmake/threading.cmake), linked publicly by ccfcrypto so every logger user
resolves the symbol through it. Repoint ccf_tasks and ccf_kv - which use the
logger but not crypto - to depend on ccf_threading directly instead of
ccfcrypto.

Bump the version to 7.0.8 and add a CHANGELOG entry describing the build-graph
change for downstream consumers that link CCF component libraries directly.
…-dependency-libccf

# Conflicts:
#	CHANGELOG.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes an implicit circular dependency where the framework logger relied on get_current_thread_id() coming from libccf, by moving thread-id ownership into a new foundational ccf_threading library and updating the build graph so low-level libraries (eg ccfcrypto) can resolve the symbol without linking libccf.

Changes:

  • Introduces ccf_threading (owning src/threading/thread_ids.cpp) and links it into ccfcrypto, ccf_kv, and ccf_tasks.
  • Removes the previous src/enclave/thread_local.cpp compilation/linker workarounds from apps, tests, benchmarks, and tools.
  • Adds a logger unit test covering thread-id assignment/reset and per-thread initialization.

Custom instructions used:

  • .github/copilot-instructions.md
  • .github/instructions/reviewing.instructions.md

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/perf-system/submitter/CMakeLists.txt Drops explicit compilation of the removed thread_local.cpp from perf submitter sources.
src/threading/thread_ids.cpp Centralizes thread-id generator + per-thread storage in a standalone TU for reuse across libraries.
src/ds/test/logger.cpp Adds a focused unit test exercising the thread-id API used by logger headers.
include/ccf/threading/thread_ids.h Minor update (no API change) alongside the relocation of the implementation.
CMakeLists.txt Wires in cmake/threading.cmake, removes thread_local.cpp from build/test targets, and links ccf_threading where needed.
cmake/threading.cmake Adds the new minimal ccf_threading static library target.
cmake/crypto.cmake Links ccf_threading into ccfcrypto so logger users resolve thread-id symbols without libccf.
cmake/common.cmake Removes the previous blanket inclusion of thread_local.cpp in test/bench wrappers.
cmake/ccf_app.cmake Removes the app linker workaround that force-resolved get_current_thread_id from ccf.
CHANGELOG.md Documents the logger/build-graph change for downstream consumers.

Comment thread CHANGELOG.md Outdated
achamayou and others added 2 commits July 10, 2026 13:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@achamayou
achamayou marked this pull request as ready for review July 10, 2026 21:27
@achamayou
achamayou requested a review from a team as a code owner July 10, 2026 21:27
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread cmake/threading.cmake
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md
Comment thread cmake/threading.cmake Outdated
Comment thread CHANGELOG.md Outdated
Co-authored-by: Amaury Chamayou <amaury@xargs.fr>
@achamayou
achamayou enabled auto-merge (squash) July 13, 2026 17:14
@achamayou
achamayou merged commit 74cdc0a into main Jul 13, 2026
18 checks passed
@achamayou
achamayou deleted the copilot/remove-logger-dependency-libccf branch July 13, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove logger dependency on libccf.a

6 participants