aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Reiser <jreiser@BitWagon.com>2018-04-29 11:57:38 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2018-04-29 11:57:38 -0400
commitcd8c76e410a5f16a170cc680be1ae2ecb5528821 (patch)
tree95a9d0533da724d2020b80c7929a1f6736070272 /gdb/Makefile.in
parentAutomatic date update in version.in (diff)
downloadbinutils-gdb-cd8c76e410a5f16a170cc680be1ae2ecb5528821.tar.gz
binutils-gdb-cd8c76e410a5f16a170cc680be1ae2ecb5528821.tar.bz2
binutils-gdb-cd8c76e410a5f16a170cc680be1ae2ecb5528821.zip
Fix race when building ada-lex.c
Prevent a race when building ada-lex.c, and any target of rules .c:.l or .c:.y. The target should be written only at the last step, else SIGINT (^C) can leave an inconsistent state. Being .PRECIOUS makes it even worse. gdb/ChangeLog: PR build/22873 * gdb/Makefile.in: (.c:.l, .c:.y): Write the target only in the last step, and do it atomically.
Diffstat (limited to 'gdb/Makefile.in')
-rw-r--r--gdb/Makefile.in18
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 648f66d31df..be769280a93 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2483,9 +2483,8 @@ po/$(PACKAGE).pot: force
# Makefile.in, but that was a pretty big annoyance.
%.c: %.y
- rm -f $@ $@.tmp
- $(SHELL) $(YLWRAP) $< y.tab.c $@ -- $(YACC) $(YFLAGS) && mv $@ $@.tmp \
- || (rm -f $@; false)
+ $(SHELL) $(YLWRAP) $< y.tab.c $@.tmp -- $(YACC) $(YFLAGS) \
+ || (rm -f $@.tmp; false)
sed -e '/extern.*malloc/d' \
-e '/extern.*realloc/d' \
-e '/extern.*free/d' \
@@ -2496,13 +2495,13 @@ po/$(PACKAGE).pot: force
-e 's/\([ \t;,(]\)free$$/\1xfree/g' \
-e '/^#line.*y.tab.c/d' \
-e 's/YY_NULL/YY_NULLPTR/g' \
- < $@.tmp > $@
- rm -f $@.tmp
+ < $@.tmp > $@.new && \
+ rm -f $@.tmp && \
+ mv $@.new $@
%.c: %.l
if [ "$(FLEX)" ] && $(FLEX) --version >/dev/null 2>&1; then \
- $(FLEX) -o$@ $< && \
- rm -f $@.new && \
- sed -e '/extern.*malloc/d' \
+ $(FLEX) --stdout $< \
+ | sed -e '/extern.*malloc/d' \
-e '/extern.*realloc/d' \
-e '/extern.*free/d' \
-e '/include.*malloc.h/d' \
@@ -2511,8 +2510,7 @@ po/$(PACKAGE).pot: force
-e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
-e 's/\([ \t;,(]\)free$$/\1xfree/g' \
-e 's/yy_flex_xrealloc/yyxrealloc/g' \
- < $@ > $@.new && \
- rm -f $@ && \
+ > $@.new && \
mv $@.new $@; \
elif [ -f $@ ]; then \
echo "Warning: $*.c older than $*.l and flex not available."; \