make: have preprocess2file fail on error

The preprocess2file helper is mainly used to preprocess
linker scripts, but piping the preprocessor output to
'grep' masks the exit code of gcc, so if it fails (eg.
due to an #error directive) then it does not cause the
build to fail like it should.

In this particular case the grep commands don't seem to
be doing anything, since the "-P" option suppresses line
markers, which "grep -v ^$(_hash)" is probably meant to
filter out. The intent behind "grep -v ^$$" is unclear
since the preprocessor doesn't seem to output any line
beginning with '$', but in any event it seems unnecessary.

Change-Id: Ie23f5de1fe1bfb5890c7b2f3c7fa05401931d89f
This commit is contained in:
Aidan MacDonald 2026-03-05 15:05:58 +00:00
parent 676d3b6432
commit 7bf1c79cb5

View file

@ -24,8 +24,7 @@ preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) |
grep -v "^$(_hash_)" | grep -v "^ *$$" | \
sed -e 's:^..*:$(dir $(1))&:')
preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \
grep -v '^$(_hash_)' | grep -v "^$$" > $(2))
preprocess2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) -o $(2)
asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \
perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2)