-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MAKEFLAGS parsing with Make 4.4+ #395
Conversation
A good catch. Do you (and @anjohnson) think any of the other At a glance, I think not. With the possible exception of the change to |
Unless I'm misunderstanding something, this no longer does the same thing for older versions of make: If I run make with a mix of flags (say $(info ${MAKEFLAGS})
$(info $(filter-out --%,$(MAKEFLAGS)))
$(info $(firstword $(MAKEFLAGS))) yielding
as such the change you propose seems to break things for at least make 3.82 |
@simon-ess aahhh, there goes my simple fix... You're right, the NEWS file mention that the For a quick check I did:
yields for make 4.4.1:
and for make 3.82:
Is there any possibility of removing this parsing as a whole? |
There are discussions about testing MAKEFLAGS in the answers to this question on Stack Overflow, but they probably all pre-date 4.4; My answer describes the solution that's currently in Base and mentions the subtle difference between its in-recipe and outside values. Could someone please try using the test Makefile in my answer on Make 4.4 to confirm that it does get false results. @simon-ess The NEWS file recommends using If necessary we might be able to add a version check to continue to support older versions, note that Apple continues to ship GNU Make version 3.81 with MacOS and/or XCode. Later versions were released under the GPLv3 which they will not accept. I don't want to remove these checks, they are too useful. I didn't see anything obvious in the NEWS incompatibility descriptions, hopefully this is the only thing that we will have to resolve. |
@anjohnson checking your test Makefile: define checkflags
make-$1 = $(findstring $1,$(filter-out --%,$(MAKEFLAGS)))
endef
$(foreach flag,i r w s k n q, $(eval $(call checkflags,$(flag))))
$(info MAKEFLAGS = "$(MAKEFLAGS)")
$(foreach flag,i r w s k n q, \
$(info make-$(flag) = "$(make-$(flag))" $(if $(make-$(flag)),YES,NO)))
all:
@+echo 'all: MAKEFLAGS = "$(MAKEFLAGS)"'
@+echo 'all: $(foreach f,i r w s k n q,$(make-$f))'
@+echo '' And running with GNUMake 4.4.1:
With GNUMake 4.3:
GNUMake 3.82 has the same result as 4.3. |
This version of makeflags := $(firstword $(filter-out -,$(filter-out --%,$(MAKEFLAGS))))
define checkflags
make-$1 := $(findstring $1,$(makeflags))
endef 3.81 seems to insert the odd @minijackson Please adjust your PR and test this. |
✅ Build EPICS Base 7 base-7.0-948 completed (commit a0948ca2d9 by @minijackson) |
Since Make version 4.4, MAKEFLAGS also contains long options and overridden variables on the command-line[1]. [1]: https://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=4.4#n67 This means that parsing by filtering out '--%' doesn't work reliably anymore, since it doesn't remove overrides: Running 'make VAR=quacks' gives 'MAKEFLAGS=" -- VAR=quacks"', and 'checkflags' would understand that flags -q, -s, ... were set. This would get transmitted below into 'QUIET_FLAGS' and 'QUESTION_FLAG', then passed to the 'genVersionHeader.pl' as '-i' and '-q'. The result would be that 'genVersionHeader.pl' would never create the version header (only check for its up-to-date status), leading to confusing errors: ../misc/epicsRelease.c:25:32: error: expected ')' before 'EPICS_VCS_VERSION' 25 | printf ( "## %s\n", "Rev. " EPICS_VCS_VERSION ); | ~ ^~~~~~~~~~~~~~~~~~ The NEWS file[1] recommends using 'firstword', but unfortunately this is not compatible with GNUMake < 3.82.
2f00d15
to
fcbfa42
Compare
@anjohnson done, sorry for the delay. Tested by compiling EPICS with GNUMake 4.4 and 4.3. Compiling with Make 3.82 is a bit harder for me, I don't know if someone (@simon-ess?) can test it? |
❌ Build EPICS Base 7 base-7.0-963 failed (commit 0bca15d16b by @minijackson) |
✅ Build EPICS Base 7 base-7.0-963 completed (commit 0bca15d16b by @minijackson) |
The current version behaves as expected for GNUMake 3.82. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @simon-ess, this looks good now.
Applied as d87fd0d |
Since Make version 4.4,
MAKEFLAGS
also contains long options and overridden variables on the command-line (source).This means that parsing by filtering out
--%
doesn't work reliably anymore, since it doesn't remove overrides:Running
make VAR=quacks
givesMAKEFLAGS=" -- VAR=quacks"
, andcheckflags
would understand that flags-q
,-s
, ... were set.This would get transmitted below into
QUIET_FLAGS
andQUESTION_FLAG
, then passed to thegenVersionHeader.pl
as-i
and-q
.The result would be that
genVersionHeader.pl
would never create the version header (only check for its up-to-date status), leading to confusing errors:The NEWS file recommends using
firstword
, so we can use just that.