libctf,libsframe: remove include of config.h
Removes redundant include of config.h in libsframe/sframe.c to fix duplicate definition warnings during recompilation.
This patch addresses a build issue where recompiling libsframe/sframe.c after the initial build results in duplicate definition warnings (e.g., ‘PACKAGE’ redefined). The problem occurs because sframe.c includes config.h twice: once from libsframe/config.h (which exists after the initial configure) and again via libctf/swap.h which includes libctf/config.h. By removing the direct include of config.h in libsframe/sframe.c, the patch resolves the warning without affecting functionality.
- contributor
Reported an issue where recompiling libsframe/sframe.c leads to duplicate definition warnings due to the include order of config.h files.
“What happens is that during the first build of GDB everything builds fine without any warnings. But if for any reason we need to recompile libsframe/sframe.c then we would see compiler warnings like this: CC libsframe_la-sframe.lo In file included from ./../libctf/swap.h:23, from sframe.c:27: ./../libctf/config.h:127: warning: "PACKAGE" redefined ”
- proposer
Submitted a patch to remove the direct include of config.h in sframe.c, resolving duplicate definition warnings that occur during recompilation.
“After investigation I discovered that this issue only occurs when building in the source tree. Here's what happens, starting from a clean source tree. From Makefile.def we see that the 'all-bfd' target depends on 'all-libsframe', and the 'configure-libctf' target depends on 'all-bfd'. The dependency chain then is: all-libsframe -> all-bfd -> configure-libctf This means that, when lib…”
Technical Tradeoffs
- Resolving duplicate definition warnings and simplifying includes vs. the clarity of having an explicit include for config.h.
In Details
This patch targets an issue in the build system dependencies between libctf and libsframe within binutils. When libsframe/sframe.c is recompiled after an initial build (common in in-source builds or during incremental development), it includes libsframe/config.h directly and also indirectly via libctf/swap.h which includes libctf/config.h. This leads to redefinition warnings for macros defined in config.h. The fix removes the direct #include <config.h> from libsframe/sframe.c, relying solely on the indirect include, thus resolving the warnings.
- libctf
- A library within binutils that provides support for Common Tagged Format (CTF) information, a compact way to represent type information.
- libsframe
- A library within binutils that provides support for frame unwind information, used for stack tracing and debugging.
- config.h
- A header file typically generated by the configure script, containing definitions and macros based on the system's configuration and build options.
- recompilation
- The process of compiling source code again, often after changes or for incremental builds.
- duplicate definition warnings
- Compiler warnings issued when the same macro, type, or variable is defined more than once in a compilation unit.