This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 06/25] Generate c for feature instead of tdesc
On 06/22/2017 03:49 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> > On 06/12/2017 09:41 AM, Yao Qi wrote:
>>> >> +$(FEATURE_CFILES): %.c: %.xml.tmp
>>> >> + $(GDB) -nx -q -batch \
>>> >> + -ex 'maint print c-tdesc $<' > $@.tmp
>>> >> + sh ../../move-if-change $@.tmp $@
>>> >> + rm $<
>>> >> +
>>> >> +%.xml.tmp: %.xml
>>> >> + echo "<?xml version=\"1.0\"?>" > $@
>>> >> + echo "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" >> $@
>>> >> + echo "<target>" >> $@
>>> >> + echo " <architecture>" >> $@
>>> >> + if test $(findstring i386/32bit-,$@); then echo "i386" >> $@ ; fi;
>>> >> + echo " </architecture>" >> $@
>>> >> + echo " <xi:include href=\"$(notdir $<)\"/>" >> $@
>>> >> + echo "</target>" >> $@
>>> >> +
>> >
>> > Don't we need move-if-change here?
>> >
> move-if-change from what to what? *.xml.tmp is removed after *.c is
> generated.
"*.xml.tmp.tmp" to "*.xml.tmp". I.e., from $@.tmp to $@, just
like the rule further above.
I may be missing something, but AFAICS, the "%.xml.tmp: %.xml"
rule is writing to the target directly. If the build
is interrupted in the middle of that rule, we end up with an
incomplete "%.xml.tmp" file left over in the file system.
Then the next time you invoke make, make will think that
the "%.xml.tmp" file is already up to date and won't rebuild it.
As a result, you'll pass a broken xml.tmp file to
"maint print c-tdesc".
Avoiding these issues is the whole point of move-if-change,
by atomically creating the target file.
Thanks,
Pedro Alves