Skip to content

build: do not embed the build directory in the binary#12077

Open
commodo wants to merge 1 commit into
fluent:masterfrom
commodo:no-build-path-in-binary
Open

build: do not embed the build directory in the binary#12077
commodo wants to merge 1 commit into
fluent:masterfrom
commodo:no-build-path-in-binary

Conversation

@commodo

@commodo commodo commented Jul 9, 2026

Copy link
Copy Markdown

monkey, cfl, ctraces and cmetrics define FILENAME/CMT_FILENAME via a GNU Make expression that only the Make generator expands; under Ninja the literal string, including the absolute ${CMAKE_SOURCE_DIR}, is baked into every object file. Use plain FILE as the Windows branch already does, and drop the then-identical conditional.

Summary by CodeRabbit

  • Refactor
    • Simplified how file name information is passed during builds across multiple components.
    • Standardized file name macros to use a consistent value on all platforms.
    • Removed platform-specific filename normalization logic, reducing build complexity.

monkey, cfl, ctraces and cmetrics define __FILENAME__/__CMT_FILENAME__ via a
GNU Make expression that only the Make generator expands; under Ninja the
literal string, including the absolute ${CMAKE_SOURCE_DIR}, is baked into every
object file. Use plain __FILE__ as the Windows branch already does, and drop
the then-identical conditional.

Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d93e4e0b-689d-4256-94ff-925d27cc1a6d

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd6b28 and 11305c8.

📒 Files selected for processing (4)
  • lib/cfl/CMakeLists.txt
  • lib/cmetrics/CMakeLists.txt
  • lib/ctraces/CMakeLists.txt
  • lib/monkey/CMakeLists.txt

📝 Walkthrough

Walkthrough

Four CMakeLists.txt build files (lib/cfl, lib/cmetrics, lib/ctraces, lib/monkey) are updated to remove OS-conditional logic for defining filename macros (FILENAME, CMT_FILENAME). Each now unconditionally defines the macro as FILE via CMAKE_C_FLAGS, replacing the previous non-Windows path-stripping expressions.

Changes

CMake filename macro simplification

Layer / File(s) Summary
Unconditional FILENAME macro definitions
lib/cfl/CMakeLists.txt, lib/cmetrics/CMakeLists.txt, lib/ctraces/CMakeLists.txt, lib/monkey/CMakeLists.txt
Each file replaces its OS-conditional filename macro definition (path-stripped on non-Windows, FILE on Windows) with a single unconditional definition using FILE appended to CMAKE_C_FLAGS.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing build-directory paths from compiled binaries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@commodo

commodo commented Jul 9, 2026

Copy link
Copy Markdown
Author

The CI in OpenWrt discovered that we're getting hard-coded paths.

Related
openwrt/packages#29914

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11305c8d17

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/cfl/CMakeLists.txt
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Map FILE before using it as FILENAME

When building with CMake's Ninja/Make generators, the compile rule passes absolute source paths, so this definition makes every cfl_report_runtime_error() expansion store and print paths like /workspace/fluent-bit/lib/cfl/src/cfl_kv.c in release objects. That leaves the absolute-path leakage this change is trying to remove, and the same replacement pattern appears in cmetrics/ctraces/monkey; use a generator-independent prefix map or relative per-source definition instead.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant