Exclude -fplugin and -fplugin-arg from DW_AT_producer recording
RFC to prevent absolute plugin paths and arguments from being embedded in DWARF debug info, improving build reproducibility.
This RFC proposes excluding GCC plugin-related options (-fplugin=
- proposer
Noticed that absolute plugin paths are embedded in DW_AT_producer due to -fplugin and -fplugin-arg options, which harms reproducibility. Experimentally marked these options with NoDWARFRecord and observed no functional impact.
“-fplugin=<path> and -fplugin-arg-* options are currently recorded in DW_AT_producer when -grecord-gcc-switches is enabled. As a result, an absolute plugin path may become embedded in debug metadata. This introduces host-specific path information into the generated artifact and may negatively affect reproducibility. As an experiment, I modified: gcc/common.opt and marked: -fplugin= -fplugin-…”
- reviewer
Acknowledged the proposal to exclude plugin options from DW_AT_producer recording, which aligns with existing mechanisms for handling reproducibility concerns.
“The plugin is still loaded correctly, plugin arguments are still passed, and generated code/debug information remain unchanged. The only observed difference is that plugin-related command-line options are no longer recorded in DW_AT_producer.”
Technical Tradeoffs
- Improved build reproducibility vs. potentially losing detailed plugin invocation information in debug data.
In Details
This RFC addresses the embedding of absolute paths for GCC plugins (specified via -fplugin and -fplugin-arg-*) into the DW_AT_producer DWARF attribute when -grecord-gcc-switches is active. The proposal leverages the existing NoDWARFRecord mechanism in gcc/common.opt to prevent these host-specific paths from being recorded, thereby enhancing the reproducibility of builds.
- DW_AT_producer
- A DWARF debugging information attribute that stores a string identifying the toolchain that produced the compilation unit, including compiler version and command-line options.
- DWARF
- A standardized debugging data format used by many compilers and debuggers, containing information about variables, types, and code structure.
- -grecord-gcc-switches
- A GCC command-line option that instructs the compiler to record all command-line switches used for compilation in the DWARF debug information.
- NoDWARFRecord
- A mechanism within GCC's option handling that specifies certain command-line options should not be recorded in the DW_AT_producer string.
- Reproducibility
- The ability to reliably produce the exact same build output from the same source code and build environment, which is crucial for security auditing and debugging.