[PATCH/BUG] ld/Makefile.am: missing dependency on ldscripts/stamp for e%.c target
A B C <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <CACtFPF0gq-TtGy1fAOQnZE=auqP-w3mn2uT=ebLBStV928ZCdg@mail.gmail.com> |
Hi everyone,
While working on adding a new target/architecture to GNU ld, I ran into a
build issue where genscripts.sh fails with errors like:
Plaintext
../../ld/genscripts.sh: line 322: ldscripts/elf32simplecpu.xr: No such
file or directory
cat: ldscripts/dyntmp.73640: No such file or directory
sed: can't read ldscripts/elf32simplecpu.x: No such file or directory
*Issue Description:* 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.
*Root Cause:* In ld/Makefile.am, the rule responsible for generating
emulation C sources:
Makefile
e%.c:
$(AM_V_GEN)${GENSCRIPTS} $* "$(tdir_$*)"
does not explicitly depend on ldscripts/stamp (or $(GEN_DEPENDS)).
Consequently, under certain conditions (such as parallel builds with make -j
or when adding a custom target before running a full re-configuration),
Make attempts to run genscripts.sh before the rule creating ldscripts/ has
been executed.
*Proposed Fix:* Adding $(GEN_DEPENDS) or ldscripts/stamp as a prerequisite
for e%.c ensures the destination directory is always created beforehand:
Makefile
e%.c: $(GEN_DEPENDS)
$(AM_V_GEN)${GENSCRIPTS} $* "$(tdir_$*)"
Alternatively, ensuring genscripts.sh implicitly creates ldscripts/ before
attempting file redirections could also prevent this failure.
Thanks for your time and for maintaining Binutils!
Best regards,
Daniel