Repository navigation
Conversation
Prefer compatible CMake package targets, report the selected provider, and retain bundled fallback and unit tests. Guard the Debug ABI and exclude imported memtailor from local target exports. Co-authored-by: Codex <noreply@openai.com>
Probe the selected target at configuration time and report MEMT_DEBUG explicitly. Propagate its usage requirements and check Debug compatibility for either discovery method. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Extend provider selection to mathic and mathicgb, validate transitive debug and TBB metadata, preserve library tests, and document mixed-provider constraints. Co-authored-by: Codex <noreply@openai.com>
d-torrance
left a comment
There was a problem hiding this comment.
I like the basic idea of this PR - the cmake build should absolutely support system-installed mathic and friends, which the autotools build has done since the beginning (or at least, for a very long time).
A couple quick initial comments for now from my phone. I'll dig into the actual code later
|
|
||
| Alternatively, see the [Docker guide](docker/README.md) for instructions on | ||
| using Docker to build Linux container images running Macaulay2. | ||
|
|
There was a problem hiding this comment.
Any build docs should go on the wiki.
You brought up a good point on Zoom yesterday, by the way, about the wiki not being reviewed. So this is definitely something to consider. But for the time being, let's stick with current practice.
There was a problem hiding this comment.
I think installation docs should be a part of M2 proper; anyway, I'll proceed to move docs to wiki here. Which means, move them to a separate branch on my fork, and do not forget to publish them once this PR is merged.
The documentation is staged on wiki-mathic-providers in the fork and should be published to the upstream wiki after this PR merges. Co-authored-by: Codex <noreply@openai.com>
Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
mahrud
left a comment
There was a problem hiding this comment.
The CMake build intentionally uses the submodule mathic/etc to make development easier. From my perspective this PR is counterproductive and adds unnecessary complexity to the CMake build.
|
There is nothing easier than external dependencies. Vendoring is bad, git submodules are awful, and 1% of developers and 0.01% of users who need it changed can go an extra hoop of installing an external dependency from source. Needless to say, the same argument applies to all the other M2 dependencies - let's bring them all in as submodules, sure, it will only make them more convenient for everybody |
This comment was marked as outdated.
This comment was marked as outdated.
I completely agree, but mathic/etc are not typical external libraries.
Unless things have significantly changed in the past few months, the CMake build is really meant for the 1% of developers that are likely to want to change something in M2's engine and mathic simultaneously, so the extra hoop is really for a much bigger portion of people who use the CMake build. Note that the autotools build already uses external mathic/etc libraries.
mathic/etc in particular have a complicated history. They used to be external libraries, then in #2160 Mike made them entirely internal to the engine, and #2173 was a compromise which allowed them (and in particular mathicgb) to continue being usable independently while making changes easy.
I'm just one voice here, pointing out that the discussion goes back 5+ years, but Doug/Michael/others can disagree and ultimately accept this change. Maybe you already discussed the history at the workshop but I didn't see it addressed in your proposal. |
|
@mahrud - cmake is winning over autotools, there is no question about it. So more and more people (and 🤖s) (And autotools development pace is glacial; e.g. anything that depends on GNU libtool there needs first to get into libtool, and so I taught GNU libtool to understand Apple clang OpenMP options, which have made it into libtool 2.6.2, but the corresponding changes to autoconf needed the fixed libtool to come out, and so I submitted the fix for it only yesterday. Hopefully it will make it into autoconf 2.73.4...) And I think @d-torrance @mikestillman and @antonleykin were on board with this change back in Cornell. |
|
@mahrud note also that Macaulay2/memtailor#23, Macaulay2/mathic#29 (and Macaulay2/mathic#30), and Macaulay2/mathicgb#84 |
|
|
||
| foreach(lib IN ITEMS memtailor mathic mathicgb) | ||
| string(TOUPPER ${lib} upper) | ||
| set(${upper}_PROVIDER AUTO CACHE STRING "${lib} provider: AUTO, SYSTEM, or BUNDLED") |
There was a problem hiding this comment.
The default should probably be BUNDLED for consistency with the current behavior, and with the autotools build. Let users opt in for SYSTEM.
I wonder if AUTO is even necessary? If the default is to bundle, and users opt-in for SYSTEM, then presumably they already have the libraries on their system. If not, then raise an error, or maybe fall back on the bundled build.
There was a problem hiding this comment.
OK, let's keep BUNDLED. Let's keep SYSTEM strict: missing or incompatible installed libraries should produce an error. And AUTO would remain an explicit opt-in for users who want system discovery with bundled fallback.
How about this?
| @@ -0,0 +1,51 @@ | |||
| # Keep CI's library test targets when using installed libraries. Copy just the | |||
There was a problem hiding this comment.
What's the advantage of this? I think it makes sense to run the unit tests for mathic & friends when we build them, but if they're already available in the system, then presumably they already passed the tests when the packages were built.
There was a problem hiding this comment.
I’ll remove this module, retain the library tests for bundled builds, and use M2’s own tests to validate system-library integration.
| set(_m2_mathic_expression_mathicgb "mgb::GroebnerConfiguration configuration(101, 2, 1)") | ||
| set(_m2_mathic_version_memtailor 1.4) | ||
| set(_m2_mathic_version_mathic 1.5) | ||
| set(_m2_mathic_version_mathicgb 1.4) |
There was a problem hiding this comment.
Why these minimum versions? M2 supports building with far older versions of the system libraries
There was a problem hiding this comment.
Are you saying that there are a bunch of systems out there with old versions of memtailor and mathic(gb) ?
Even if it's the case, these old versions are most probably cmake-deficient in some or another way.
There was a problem hiding this comment.
Yes, absolutely. From https://launchpad.net/ubuntu/+source/mathicgb:
- Ubuntu 18.04: 1.0~git20170606
- Ubuntu 20.04: 1.0~git20211216
- Ubuntu 24.04: 1.0~git20240206
- Ubuntu 26.04: 1.2
1.4 didn't hit Ubuntu until 26.10, which was just released 4 days ago
There was a problem hiding this comment.
I guess one can have a fallback, checking system libraries directly, without cmake scaffolding.
Another question is whether we want this extra bloat, which will have to stay in for some time.
There was a problem hiding this comment.
That's a good question. I care about supporting older versions for my Debian/Ubuntu packaging work, but I use the autotools build there.
|
the CI erros is just a connection failure. A restart (which I can't trigger without another push) should fix it |
mahrud
left a comment
There was a problem hiding this comment.
Since you requested my review, I'll share my honest feedback, which you can disregard if you wish.
I see several red flags here:
- files like
mathic-providers.yml,select-mathic-libraries.cmake, andtest_mathic_providers.pyseem over-engineered to the point that I can't understand their purpose on my own; - you directly quoted an LLM in response to Doug's question, which gives me the impression that you don't 100% understand them on your own either;
- I can accept a complex kludge that I don't fully understand, even one written by AI, if it fixed an important problem I couldn't solve otherwise, but besides appealing to general virtues (vendoring bad, submodules aweful), I don't see what actual issue you're solving in exchange for the imposed technical debt.
Again, you can disregard all of this, and if anyone who wanted this change at Cornell can say that they 100% understand it and take responsibility for its maintenance, I don't mind at all if they go ahead and merge it.
|
@mahrud - apologies, I got sloppy indeed. All these files you wanted gone are gone now. |
d-torrance
left a comment
There was a problem hiding this comment.
In addition to the other comments, I'm still confused by the 3 separate loops we have in e/CMakeLists.txt. It looks like we:
- Detect what we have
- Check our debug/tbb flags
- Make sure everything will play nicely with each other
Is that the basic idea?
| cmake -S../.. -B. -GNinja \ | ||
| -DCMAKE_BUILD_TYPE=Release -DBUILD_NATIVE=OFF \ | ||
| -DMEMTAILOR_PROVIDER=BUNDLED -DMATHIC_PROVIDER=BUNDLED \ | ||
| -DMATHICGB_PROVIDER=BUNDLED \ |
There was a problem hiding this comment.
Do we need this? BUNDLED is the default, right?
| set(_m2_mathic_expression_mathicgb "mgb::GroebnerConfiguration configuration(101, 2, 1)") | ||
| set(_m2_mathic_version_memtailor 1.4) | ||
| set(_m2_mathic_version_mathic 1.5) | ||
| set(_m2_mathic_version_mathicgb 1.4) |
There was a problem hiding this comment.
I'm still not sure about these minimum versions. If the goal is to make sure that we have, e.g., Macaulay2/memtailor#23, then they're not sufficient. None of those PR's have been included in a release yet. (They will soon -- I'll release new versions prior to M2 1.26.11.)
|
|
||
| set(_m2_mathic_expression_memtailor "libmemtailorIsPresent()") | ||
| set(_m2_mathic_expression_mathic "libmathicIsPresent()") | ||
| set(_m2_mathic_expression_mathicgb "mgb::GroebnerConfiguration configuration(101, 2, 1)") |
There was a problem hiding this comment.
Why not libmathicgbIsPresent() for consistency with the other two?
Description
Allow CMake to use installed memtailor, mathic and mathicgb through their CMake configs or pkg-config metadata.
MEMTAILOR_PROVIDER,MATHIC_PROVIDERandMATHICGB_PROVIDERdefault toBUNDLED;SYSTEMrequires a compatible installed library, andAUTOopts into installed libraries with bundled fallback. Existing caches retain their selected providers.Configuration reports the selected versions and providers and checks debug ABI flags, transitive dependency flags and mathicgb's TBB setting with compile/link probes. System mathic requires system memtailor; system mathicgb requires both. Minimum versions are memtailor 1.4, mathic 1.5 and mathicgb 1.4, with metadata describing their installed ABI.
The engine and interpreter inherit the selected libraries' headers and ABI definitions. A Debug M2 can use a complete Release system stack; bundled Debug consumers still require Debug dependency layouts. Headers from a custom prefix take precedence over headers in other dependency prefixes, preventing accidental use of Homebrew headers with different selected libraries. Only bundled libraries are installed/exported or have their own upstream unit-test targets added.
Selection remains in
M2/Macaulay2/e/CMakeLists.txt. Autotools behavior and submodule acquisition are unchanged. General build CI selects bundled providers and runs their library tests. The CMake wiki guide staged onwiki-mathic-providersdocuments configuration and ABI constraints; it should be published to the wiki after merge.Related issues and pull requests
Related metadata improvements: Macaulay2/memtailor#23, Macaulay2/mathic#29 and Macaulay2/mathicgb#84.
This PR supplies external engine discovery for #4758; the no-submodules policy is kept in that separate PR.
Testing
Latest header fixes were validated on the integration branch in #4758:
M2-core,M2-unit-testsand editor grammars with all three libraries installed under a custom prefix, using both CMake metadata and pkg-config-only discovery.M2 -q --check 1pass for both discovery paths.Earlier validation of provider selection: 19 selection checks, a Debug integration build against Release system libraries, and a fresh bundled Debug build without TBB (273 library tests plus an API/link smoke test) passed. Bundled exports and exclusion of system libraries from bundled exports were checked. These bundled tests were not repeated for the latest header fixes; bundled CI covers them. A full package/documentation installation was not run locally.
Existing Homebrew bottles of these versions lack the required metadata; their versions alone are insufficient. Current upstream source builds supply it.
Release notes
Use PR title.
AI disclosure
Tools and models used: OpenAI Codex (earlier work also used GPT-6 Astra).
How AI was used: implementation, validation, documentation and PR description.
Verification: the builds, tests and dependency audits above were run by Codex; human review remains pending.
License