Re: [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 <CACtFPF1vyA0Pp2XuPBQg8+v+o0NrcxyAKk55Pt5wfgCxEF=VrA@mail.gmail.com>
Sorry but no

# These all start with e so 'make clean' can find them.
ALL_EMULATION_SOURCES = \
eaix5ppc.c \
eaix5rs6.c \
eaixppc.c \
eaixrs6.c \
ealpha.c \
eelf32simplecpu.c \

and in order to make it works for me I just added mkdir -p ldscripts in
genscripts.h

# Create scripts using different settings of the LD_FLAG variable
mkdir -p ldscripts
LD_FLAG=r

On Sun, Aug 16, 2026 at 5:05 AM Alan Modra <[email protected]> wrote:

> On Sat, Aug 15, 2026 at 12:51:26PM +0200, A B C wrote:
> > 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
>
> You neglected to add your new target to ALL_EMULATION_SOURCES, no
> other changes needed.
>
> > *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
>
> --
> Alan Modra
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.