Compute $(STDLIB_MODULES)
with GNU make functions instead of runtime/sak
#12293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR follows on from #12287 (comment).
stdlib/StdlibModules
contains the macro$(STDLIB_MODULES)
which expands to the actual module list for the Standard Library (i.e. withStdlib__
prefixes). In #10169, this was computed using a series of shell calls which was hideously slow on Windows and which got changed in #10451 with the introduction of thesak
tool.Even ignoring questions of taste or otherwise about the use of C, this constitutes a slightly confusing state of affairs in the build system.
$(STDLIB_MODULES)
is evaluated, but it is the responsibility of the expansion site to ensure that thesak
tool is compiled before this happens. In other words, theSTDLIB_MODULES
variable has prerequisites!This isn't ideal, and means that
Makefile.common
contains some dark magic to ensure thatsak
is compiled beforeStdlibModules
is included (which can also causesak
to be (re-)built when not really necessary).This can be done fairly simply, if inelegantly, in GNU make itself. GNU make doesn't directly have a function to convert case, but it can efficiently evaluate 26 calls to
$(patsubst ...
- i.e. we can just do$(patsubst a%, A%, $(patsubst b%, B%, ...
. I'm not that keen on 27 right brackets in a row at the end of it, so instead the macroCAPITALIZE
here receives two space-separated alphabets, and is defined recursively. I like this not involving any auxiliary script.runtime/sak
remains only for the purpose of formatting the location of the Standard Library, but this is used in a much more normal way to generateruntime/build_config.h
(whereruntime/sak
is just a normal dependency). I think I have something in the freezer for that, too, but for another day.