Skip to content

Fix undefined Makefile variables#12022

Merged
xavierleroy merged 5 commits intoocaml:trunkfrom
dra27:make-warn
Feb 21, 2023
Merged

Fix undefined Makefile variables#12022
xavierleroy merged 5 commits intoocaml:trunkfrom
dra27:make-warn

Conversation

@dra27
Copy link
Copy Markdown
Member

@dra27 dra27 commented Feb 20, 2023

The majority of the warnings are coming from the V_ macros from #11844, which uses $ to allow indenting the commands by two spaces. This PR restores the CI check from #10270 for this which was accidentally lost in the multicore merge and also borrows the definition $(SPACE) := which was originally in that PR and silences the warning. The others:

@dra27 dra27 added this to the 5.0.1 milestone Feb 20, 2023
@dra27 dra27 linked an issue Feb 20, 2023 that may be closed by this pull request
@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Feb 20, 2023

The additional code this enables for libasmrund (see runtime/amd64.S) might mean this warrants a Changes entry.

@dra27 dra27 requested a review from shindere February 20, 2023 20:49
Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

# $(SPACE) contains a single space
SPACE := $(EMPTY) $(EMPTY)
# $( ) suppresses warning from the alignments in the V_ macros below
$(SPACE) :=
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wizard-level Makefile hacking :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also possible to do it by having, e.g.

V_CC         = @$(info $(SPACE) CC $@)

but that looks a little odd. More importantly, it's relatively easy to find $ recommended as a way of escaping a space, but rather harder to find the trick necessary to suppress the undefined variable warning, so it seems worth having the slightly strange trick above. Incidentally, that macro is principally used for escaping newlines without adding space (by writing $\ instead of \ at the end of the line.)

@shindere
Copy link
Copy Markdown
Contributor

shindere commented Feb 21, 2023 via email

Rather than just reporting un-prefixed symbol names, also report
undefined variables.
@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Feb 21, 2023

Thanks, @shindere! I’ve restructured that block slightly so both tests get done, with a failure in either halting the build only after both have been run (a little like the hygiene checks which try to test as much as possible)

@xavierleroy
Copy link
Copy Markdown
Contributor

xavierleroy commented Feb 21, 2023

Thanks @dra27 for your quick response and Makefile wizardry. We take Makefile hygiene seriously ! I'm going to merge in trunk and backport to 5.0 (as suggested by your milestone)

@xavierleroy xavierleroy merged commit 84fe059 into ocaml:trunk Feb 21, 2023
@xavierleroy
Copy link
Copy Markdown
Contributor

Actually, it doesn't backport cleanly to 5.0, because in 5.0 we did not have the nice elided printing of commands. I'm running a quick build of 5.0 to see how many warnings we get from make --warn-undefined-variables.

@xavierleroy
Copy link
Copy Markdown
Contributor

I'm running a quick build of 5.0 to see how many warnings we get from make --warn-undefined-variables.

Very few:

Makefile:44: warning: undefined variable 'FORCE_INSTRUMENTED_RUNTIME'
Makefile:956: warning: undefined variable 'OC_DEBUG_CPPFLAGS'
Makefile:959: warning: undefined variable 'OC_INSTR_CPPFLAGS'
dynlink_compilerlibs/Makefile:19: warning: undefined variable 'OCAMLDEPFLAGS'

I think we can live with this, esp. if we skip 5.0.1 to go straight to a 5.1.0 release.

@dra27
Copy link
Copy Markdown
Member Author

dra27 commented Feb 22, 2023

No problem to back-port it to 5.0, just to keep CI there clean too (5.1 I think already features some of the more usual incompatibilities in parsetree, etc. that we avoided between 4.14 and 5.0, so we might not be able to having a maintenance release of 5.0, even if we're fully expecting everyone who's on 5.0 to leap on 5.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make warns about undefined variable ' '

4 participants