M2 icon indicating copy to clipboard operation
M2 copied to clipboard

building M2 on Apple silicon MacOS Sonoma

Open mikestillman opened this issue 1 year ago • 3 comments

This issue will contain my experiments for compiling M2 on Apple silicon, on MacOS Sonoma, and with different compilers, cmake/autotools, etc. I have found a number of issues, and now I want to be systematic about this.

My use of this as an issue is experimental (for me!)

Here is the first list to try

  • [ ] cmake build, apple clang
    • [x] configure earlier, I needed to install brew packages msolve and texinfo (for install-info) I also need to add in -DBUILD_NATIVE=off, perhaps this should be done automatically? -DCMAKE_PREFIX_PATH="`brew --prefix tbb@2020`;`brew --prefix`"
    • [x] executable ninja M2-core
    • [x] examples ninja install-packages Question: How do I tell what the default target for ninja is?
    • [ ] package tests One test in RunExternalM2 fails. Also, with one package left, the process appears to hang (it is either done with SpecialFanoFourfolds, or hanging during that).
    • [ ] M2 tests
  • [ ] cmake build, llvm clang
  • [ ] cmake build, gcc14

mikestillman avatar Aug 21 '24 14:08 mikestillman

@d-torrance @mahrud When compiling on appleclang, on MacOS Sonoma (maybe others too), I get the following problem during ctest. This same problem happens with every test in the normal directory.

Try

ctest -R normal/000-core.m2 -V

Running this gives on my apple M1 mac:

4155: Test command: /Users/mike/src/M2-current-branches/M2-development/M2/BUILD/mike/builds.tmp/cmake-appleclang/usr-dist/arm64-Darwin-macOS-14.6.1/bin/M2 "-q" "--stop" "--silent" "--no-debug" "--no-randomize" "-e" "errorDepth=1" "-e" "debugLevel=0" "-e" "gbTrace=" "-e" "path=join(path,{"/Users/mike/src/M2-current-branches/M2-development/M2/Macaulay2/tests/","/Users/mike/src/M2-current-branches/M2-development/M2/packages/"})" "-e" "input("/Users/mike/src/M2-current-branches/M2-development/M2/Macaulay2/tests/normal/000-core.m2")" "-e" "exit 0"
4155: Working Directory: /Users/mike/src/M2-current-branches/M2-development/M2/Macaulay2/tests/normal
4155: Environment variables: 
4155:  GC_MAXIMUM_HEAP_SIZE=400M
4155: Test timeout computed to be: 900
4155: currentString:2:0:(3):[2]: error: syntax error at '-*end of file*-'
4155: ../../m2/startup.m2.in:619:14:(0): --backtrace: parse error--
1/1 Test #4155: normal/000-core.m2 ...............***Failed    0.34 sec

0% tests passed, 1 tests failed out of 1

On a branch that I have where development was last merged into it a month or two ago (I think July, but I can check), the ctest's work fine.

Perhaps some recent change to startup.m2.in is involved?

mikestillman avatar Aug 22 '24 18:08 mikestillman

Seems like a file system problem almost. Have you tried this on the main branch?

mahrud avatar Aug 22 '24 18:08 mahrud

  • Question: How do I tell what the default target for ninja is?

Run ninja -t browse. It'll list the targets that ninja all will run, and you can click through to see the subtargets.

mahrud avatar Aug 25 '24 13:08 mahrud

I see this sort of ctest errors on the current branch on a x86_64 Linux system.

UpdateCTestConfiguration  from :/home/dima/software/M2/M2/BUILD/build/DartConfiguration.tcl
Parse Config file:/home/dima/software/M2/M2/BUILD/build/DartConfiguration.tcl
Test project /home/dima/software/M2/M2/BUILD/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 4433
    Start 4433: normal/000-core.m2

4433: Test command: /home/dima/software/M2/M2/BUILD/build/usr-dist/x86_64-Linux-Gentoo-2.17/bin/M2 "-q" "--stop" "--silent" "--no-debug" "--no-randomize" "-e" "errorDepth=1" "-e" "debugLevel=0" "-e" "gbTrace=" "-e" "path=join(path,{"/home/dima/software/M2/M2/Macaulay2/tests/","/home/dima/software/M2/M2/packages/"})" "-e" "input("/home/dima/software/M2/M2/Macaulay2/tests/normal/000-core.m2")" "-e" "exit 0"
4433: Working Directory: /home/dima/software/M2/M2/Macaulay2/tests/normal
4433: Environment variables: 
4433:  GC_MAXIMUM_HEAP_SIZE=400M
4433: Test timeout computed to be: 900
4433: currentString:2:0:(3):[2]: error: syntax error at '-*end of file*-'
4433: ../../m2/startup.m2.in:622:15:(0): --backtrace: parse error--
1/1 Test #4433: normal/000-core.m2 ...............***Failed    0.34 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.41 sec

The following tests FAILED:
	4433 - normal/000-core.m2 (Failed)
Errors while running CTest
Output from these tests are in: /home/dima/software/M2/M2/BUILD/build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

(there are quite a few other tests which error out like this)

dimpase avatar Aug 08 '25 02:08 dimpase

@mahrud - so this is not macOS-specific, it's cmake/ctest

dimpase avatar Aug 08 '25 18:08 dimpase

I see it again, and wonder why m2/startup.m2.in is even involved. That's a templated file for autotools only, no?

dimpase avatar Oct 27 '25 18:10 dimpase

Both build systems use startup.m2.in.

d-torrance avatar Oct 27 '25 18:10 d-torrance

OK, but why does it pop up in tests? Normally speaking one tests the results of a build, not unprocessed sources.

dimpase avatar Oct 27 '25 18:10 dimpase

startup.m2.in is a little funny. During the build, the various templated things get replaced, and then it's stored inside the M2 binary as a string. This string is the first bit of top-level code that's run at startup.

When M2 runs into an error, it always prints the line of code where the error occurred. And if this line of code happens to be from this string, it prints the location as startup.m2.in.

d-torrance avatar Oct 27 '25 18:10 d-torrance

so the actual error is from startup.m2, not startup.m2.in? perhaps this ought to be fixed

dimpase avatar Oct 27 '25 19:10 dimpase

startup.m2 isn't actually ever run -- it's shipped with M2 for reference. The actual error is occurring in the string inside the M2 binary.

d-torrance avatar Oct 27 '25 19:10 d-torrance

yes, but this string is made from startup.m2, right?

dimpase avatar Oct 27 '25 20:10 dimpase

Kind of. Both the string and startup.m2 are generated from startup.m2.in. If you make changes to startup.m2, then nothing will happen -- any changes would need to be made to startup.m2.in before recompiling M2.

d-torrance avatar Oct 27 '25 20:10 d-torrance

What is the string containing startup.m2 doing in M2 executable? Is it there to skip reading these commands from a file, so that the interpreter is running commands in this string?

dimpase avatar Oct 28 '25 23:10 dimpase