[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the purpose of parser-built?

From: Eric Blake
Subject: Re: What is the purpose of parser-built?
Date: Wed, 6 Feb 2019 16:49:34 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 2/6/19 4:18 PM, Peng Yu wrote:
> Hi,
> I deleted the file parser-built, and bash still compiles and an empty
> parser-built file will be generated upon compilation. What is the
> purpose of this file? Should it be deleted? Thanks.

Look at Makefile.in:

GRAM_H = parser-built
y.tab.o: y.tab.h y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
${GRAM_H}:      y.tab.h
        @-if test -f y.tab.h ; then \
                cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \

y.tab.c: parse.y
#       -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
        $(YACC) -d $(srcdir)/parse.y
        touch parser-built
#       -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h;
else cp -p y.tab.h ${GRAM_H}; fi

parser-built is a witness that $(YACC) was run, even if the timestamps
did not change (because the generated file did not change compared to
last time). It exists in the file system so as to let make compute
timestamp dependencies where we know the parser is up-to-date, even
though the actual file we depend on has a timestamp that does NOT change
(because we intentionally don't override it when there is no
difference), all in order to minimize the time spent rebuilding the
project when making a tweak to parse.y (for example, being able to tell
the difference between a minor edit that changes a comment but not the
generated parser, vs. a major edit that requires rebuilding other files
to pick up the changes implied by the changed parser).

You really ought to learn how to use things like 'git grep parser-built'
to try and discover where this file is mentioned, prior to asking your
questions.  Had you asked "I see that Makefile creates parser-built
during the y.tab.c: parse.y production, but didn't understand why", that
comes across much nicer than your generic question which reads more like
"I see an empty file and don't know why, but couldn't be bothered to
even explain what things I've tried in order to take a guess at why, but
would rather just have you do all the work for me".

http://www.catb.org/esr/faqs/smart-questions.html is a great read; it
will teach you how to come across as someone worth chatting to, rather
than an infinite time sink, if you would use the advice in that file to
ask smarter questions.

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]