Skip to content

build: stop using Make automatic filename expression#92

Merged
edsiper merged 2 commits into
masterfrom
build/namespace-filename-macro
Jul 13, 2026
Merged

build: stop using Make automatic filename expression#92
edsiper merged 2 commits into
masterfrom
build/namespace-filename-macro

Conversation

@edsiper

@edsiper edsiper commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve the fix and authorship from CMakelists.txt: Stop using Make automatic variable #61 as the first commit
  • replace the Make automatic-variable expression with the compiler-provided __FILE__ value
  • namespace the definition as __CTR_FILENAME__, matching the library-specific approach used by Cmetrics
  • update all internal logging and errno macros to honor __CTR_FILENAME__

Why

CMake 3.20 changed generated Makefile handling in a way that can leave the literal $(subst ... $(abspath $<)) expression embedded in binaries. Besides leaking build paths and failing Yocto build-path QA, the generic __FILENAME__ name can collide with bundled libraries.

The first commit carries the original #61 correction. The second commit gives CTraces its own macro namespace while retaining the existing __FILE__ fallback for ctr_errno().

Validation

  • clean CMake development build
  • CTest: 4/4 passed
  • verified all internal log macros use __CTR_FILENAME__
  • verified generated compile commands define __CTR_FILENAME__=__FILE__
  • verified the obsolete Make expression is absent from generated compile commands
  • git diff --check

nikomauno and others added 2 commits July 12, 2026 19:10
CMake Makefile layout generation has changed since version 3.20, ref:
https://discourse.cmake.org/t/base-filename-gets-set-to-compiler-depend-ts-after-update-to-cmake-3-20/3075/4

For instance with Yocto framework this approach can lead to QA issue
stemming from build host path ending up in generated binary like

  ERROR: fluentbit-3.1.9-r0 do_package_qa: QA Issue: File /usr/bin/fluent-bit in package fluentbit contains reference to TMPDIR [buildpaths]
  ERROR: fluentbit-3.1.9-r0 do_package_qa: Fatal QA errors were found, failing task.

stemming from

  $ strings packages-split/fluentbit/usr/bin/fluent-bit
  ...
  $(subst /yocto/upstream/build/tmp/work/cortexa57-poky-linux/fluentbit/3.1.9/git/,,$(abspath $<))
  ...

Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@edsiper edsiper marked this pull request as ready for review July 13, 2026 01:13
@edsiper edsiper merged commit 5768584 into master Jul 13, 2026
41 checks passed
@edsiper edsiper deleted the build/namespace-filename-macro branch July 13, 2026 03:22
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.

2 participants