-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cleaning up build system #662
Comments
wow! impressive that rather than just complain about the current build system, an experiment with an alternative build system was pursued and implemented. i have no comments on your two questions at this point ; still absorbing the newness and scope of this development. |
This is brilliant Vincent! Was especially amused/impressed to see this post after midnight in the middle of the summer school :) |
First, thanks for taking this on. I think your observations are sound and having a demonstration of what things could look like will hopefully kickstart the process of fixing things. I think it's worth tagging @rhdtownsend as the resident build system expert. I'm going to boldly chime in, having only looked around for about 20 min, because I maintain the
Yes, very yes. The module the old structure
is at first glance reduced to the new one.
I'll note that I see less obvious gain over the structure of the old
I personally think yes, with the caveat that I might be underestimating how much effort remains.
When I first start looking at this, I also wondered about cherry-picking some ideas, but I think everything you've implemented has clear benefits. If in each module, we consolidate
I'm personally a big fan of trying to accomplish as much as possible with the simplest tools that are available. More advanced build tools have a place but I don't think our requirements are complicated enough to warrant the nuisance that might be caused for someone trying to install somewhere like an HPC system, with an old OS and little room to install base packages. Regarding potential improvements, this stands out:
I like the sound of that! MESA's current build time is ~15-20 minutes. Just cutting that in half would feel like a big improvement on the CI turnaround. I have three points:
|
Jumping in here with a few remarks. I've recently done quite a bit of work in revamping the build system for GYRE (and other projects I maintain). The changes include
The most recent release of GYRE (7.2) has many of these improvements; I'm going to be making another release (7.2.1) very soon, which will complete the update. It's this newer release that will make it into MESA as the GYRE refresh. Within the GYRE distribution directory, the top-level Makefile defines user-settable flags and various targets (all, install, clean, test, etc). The building all happens in the build/ subdirectory. The system is pretty clean, and robust against crazy stuff happening. And, it parallelizes very well, thanks to separate passes for module (.mod/.smod) file generation and code compilation. ETA: oh, and not a single shell script apart from the SDK version checker! |
On the subject of GNU make 4.3, it would be possible to bundle make into the SDK (I've done that in the past with 'custom' SDKs). One of the big changes in 4.3 was the introduction of grouped targets, which can cut down on makefile verbosity (see https://www.gnu.org/software/make/manual/html_node/Multiple-Targets.html). But the new GYRE build system doesn't need this, as the automatic dependency generation obviates the need for grouped targets. |
A further note on the GYRE build system: all of the heavy lifting is done in the file build/Make.inc. This file handles all of the dependency generation, compilation rules, etc. build/Makefile just sets up the list of source files, libraries, executables. It would be possible to adapt this to MESA, with a single Make.inc for everything, and then a build/Makefile for each MESA module. |
Thanks for the positive feedback! I left some replies to the comments below
It is indeed the grouped targets, which I introduced at some point to make parallel building work. Also because I currently don't understand how make deals with non-grouped multiple outputs.
It depends on how custom the other modules are. If they fit within the parameters of the new system as it is now, then it is not too much work. Maybe it would be a good idea for one or more developers to try to port some of the modules to the new system to become more familiar with it. It would also be great to see some tests with other compilers. In principle this should only require swapping out make/compile-settings-gnu.mk.
Since MESA doesn't use a templating engine like fpx3 (as far as I could tell at least), do you think it still make senses to replace makedepf90?
I'll definitely read through that.
That would indeed simplify things and could indeed remove the need for grouped targets |
I made the following two changes in the meantime
|
@VincentVanlaer, I just made a first attempt to build with the new system. I cloned your fork, switched to the
Indeed,
but that might not be surprising. |
I guess that the version of makedepf90 is older than the one I have. I also had to patch makedepf90 to make include files cleaner to support, but that shoudn't cause the error. In any case, I have been cleaning up and documenting the new build system, and I have replaced makedepf90 by a simple script in the meantime, similar to what Rich has done for GYRE. I'll make at least a draft PR in the next few days (depending on how fast I go over the remaining modules I had ported already), which should work with the SDK as it currently is. |
FYI, the version of makedepf90 that ships with the SDK has also been patched, to add an ‘-X’ flag that adds dependencies on external modules. Patch file is attached.
cheers,
R
… On Jul 30, 2024, at 8:55 PM, Vincent Vanlaer ***@***.***> wrote:
I guess that the version of makedepf90 is older than the one I have. I also had to patch makedepf90 to make include files cleaner to support, but that shoudn't cause the error. In any case, I have been cleaning up and documenting the new build system, and I have replaced makedepf90 by a simple script in the meantime, similar to what Rich has done for GYRE. I'll make at least a draft PR in the next few days (depending on how fast I go over the remaining modules I had ported already), which should work with the SDK as it currently is.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
--
Rich Townsend • Professor of Astronomy
Astronomy Department • University of Wisconsin-Madison
Phone: 608-262-1752 • E-mail: ***@***.***
|
i don't see a patch file. |
Must have been stripped from the mail. Here it is: |
Context
I am experimenting with building and packaging MESA for nixos using nix. I did the same with GYRE recently. In order to do that properly, I wanted to understand how MESA actually gets build. I found the existing combination of bash scripts and makefiles difficult to understand and adapt, so I ended up re-implementing the build system mostly from scratch. This issue is for me to check if what I'm proposing below is considered a meaningful improvement.
What I found to be not ideal in the current build system
make
subfolders end up containing both the makefiles and build artifactsWhat I ended up implementing
The implementation, with a few modules (const, utils, math, mtx, chem) ported can be found on https://github.com/VincentVanlaer/mesa/tree/new-build. The main flow is as follows:
The system has the following benefits:
In terms of lines of code, the changes are
162 files changed, 563 insertions(+), 2888 deletions(-)
for the five modules ported.Caveats & remarks
Conclusions
I have two questions after all of this (which are difficult to answer for me given that I have written them):
It might also be worth considering alternatives such as only applying some of the concepts, or porting to another build system such as Meson.
If you want to play with the Makefiles I can also upload a patched version of the mesasdk that contains the necessary changes and a gnumake install with at least version 4.3.
The text was updated successfully, but these errors were encountered: