ld/Makefile.am: missing dependency for e%.c target
Fixes a build issue in ld/Makefile.am where genscripts.sh runs before the ldscripts/ directory is created, causing build failures.
A bug in ld/Makefile.am prevents the correct generation of emulation C sources (e%.c). The rule for creating these files runs genscripts.sh before the ldscripts/ directory and its stamp file are created, leading to build failures with missing file errors. This patch proposes adding $(GEN_DEPENDS) or ldscripts/stamp as a prerequisite to the e%.c target to ensure the directory exists before genscripts.sh is executed.
- proposer
Identified a build issue where `genscripts.sh` fails due to the `ldscripts/` directory not existing when the `e%.c` target is processed, and proposed adding a dependency to fix it.
“The failure happens because the ldscripts/ directory does not exist at the time genscripts.sh is executed. Because the output files cannot be created in ldscripts/, the resulting C variables in e${EMULATION_NAME}.c end up empty/corrupted (e.g. generating broken statements like return ; instead of returning the script string), which subsequently fails during C compilation. Proposed Fix: Adding $(…”
In Details
This patch addresses a build-time race condition in binutils' ld/Makefile.am. The e%.c target, which generates C source files for emulation scripts using genscripts.sh, lacks a dependency on the creation of the ldscripts/ directory. This can lead to genscripts.sh executing before its output directory is ready, causing build failures, especially with parallel builds (make -j). The fix adds a dependency on $(GEN_DEPENDS) or ldscripts/stamp to ensure the directory exists prior to script generation.
- ldscripts/
- A directory within the binutils source tree that contains linker script templates and related files used to configure the behavior of the GNU linker (ld).
- genscripts.sh
- A shell script used by GNU ld to generate C source files from linker script templates, embedding script logic into the linker executable.
- e%.c
- A pattern rule in Makefile.am for generating C source files (e.g., 'eelf32ppc.c') that define emulation-specific linker behavior.
- Makefile.am
- A file used by the Autotools build system (specifically Automake) to describe how to build the project's targets.
- make -j
- A command-line option for the
makeutility that allows parallel execution of build rules, potentially leading to race conditions if dependencies are not correctly specified.