Repository navigation
Add a CMake build system beside configure/make - #966
DiamonDinoia wants to merge 3 commits into
Conversation
The CMake build supports the configure options, environment variables, make target names, compiler flags and install layout of the configure/make build. It adds per-config flag tables, the testsuite, blastest and examples in dual mode, documentation in docs/BuildSystemCMake.md, and GitHub Actions CI for Linux, macOS and Windows. Squashed from: - Add CMake per-config flag tables (translation of config/*/make_defs.mk) - Add CMake build system (configs, threading, BLAS/CBLAS, install, packaging) - Port testsuite, blastest, and examples to dual-mode CMake - Document the CMake build (option mapping, plugin flow) - Audit fixes: memkind link parity, sde emulator path, f2c flags, changelog guard, pc serialization - Add GitHub Actions CI for the CMake build (parallel to CircleCI make flow) - Link consumers of openmp builds against OpenMP::OpenMP_C for static linking - CI: add macOS (firestorm, single/pthreads) and Windows (ucrt64) CMake legs Assisted-by: XiaomiMiMo/MiMo-V2.6-Pro-MOPD Assisted-by: claude-sonnet-5-5 Assisted-by: Qwen/Qwen3.8-27B-FP8 Assisted-by: claude-opus-5-5 Assisted-by: mistralai/Mistral-Medium-3.5-128B
|
I'm concerned that you did not use enough AI models to generate this PR 😆 |
|
Put them against each other so the keep themselves in check |
|
CMake is definitely overdue, so thanks for the PR. I'll review shortly. |
ef79bc0 to
7e3dd41
Compare
|
One quick thing I noted: I really would rather not add Github Actions, but I would be OK with moving all of the CircleCI tests to CMake. Given a full working CMake the next release would have the traditional configure script deprecated and then eventually replaced with a CMake wrapper. |
|
Happy to do so. |
7e3dd41 to
5a00b82
Compare
|
I cannot see why it failed so I cannot fix :( |
|
5a00b82 to
0b78993
Compare
| ## Quick start | ||
|
|
||
| ```sh | ||
| cmake -S . -B build -DBLIS_CONFIG=auto -DBLIS_THREADING=openmp |
There was a problem hiding this comment.
-B build will fail. build is part of blis's source. I suggest out.
| @@ -0,0 +1,193 @@ | |||
| function(blis_add_objects name) | |||
There was a problem hiding this comment.
Flag pairs are deduplicated. For example:
... --diag_suppress A --diag_suppress B ...
becomes
... --diag_suppress A B ...
This will break NVHPC builds and others (e.g. -mllvm X -mllvm Y).
The CMake build matches configure/make on every checked surface. Compile commands match make on the checked configs. The generated blis.pc and config.mk match make apart from prefix lines. Every make target name exists as a CMake target. The install layout matches make, with and without DESTDIR. Correctness fixes close the wrong-result rows found in review. Assembly sources compile in the assembler dialect configure uses. The uninstall targets remove the Windows DLL and import library. Tests fail on a nonzero exit code or on a FAILURE line in the output. The modules split into files with one concern each in cmake/. The per-config flag tables are generated from the make tables. The CMake files drop from 7,217 lines to under 3,700. The top CMakeLists.txt is at most 300 lines. The minimum version is CMake 3.20...4.4. The build supports MSVC, clang-cl, the clang GNU frontend and MinGW. A CI workflow builds and tests Linux, Windows, MSVC and s390x. The CMake files are formatted with gersemi. Assisted-by: Hermes Agent
0b78993 to
5abf3d6
Compare
SummaryThis is good work. I found no blocking correctness problems for the common gcc/clang paths. Before merge, it needs some CI and doc cleanup and a few compiler-parity fixes. What was checked
Should fix before merge
Parity gaps against configure/common.mk
Nits
OverallThe make_defs parser, the fail-at-build-time handling for configs whose make_defs stop with an error, and the — Claude |
Give the RISC-V preprocess probe the toolchain flags. A cross clang build can auto-detect its config. Compare blastest omit names in full. Omitting only xerbla_array no longer disables the blastest drivers. Correct the docs and the CircleCI comments. No comment names a file or tool that this tree does not have. Make compiler detection agree with configure: the AOCC release parse, ARMClang to clang, the icc 15.0 skx rule, and correct yes and no flags. Gate the vendor flags like common.mk: -fopenmp, -pthread, clang warnings, symbol flags and SIMD flags go to the gcc, icc and clang blocks only. Add -lrt on Linux only, with the Bionic probe. Give Darwin the raw LIBPTHREAD text that make writes in LDFLAGS and blis.pc. Move the Windows export flags to the link command. The compile-only copy is gone, and the flags control DLL exports. Add aocc to the OpenMP, visibility, SIMD and pthread flag branches. This differs from make on purpose, because common.mk has no aocc in those blocks. Split LIBPTHREAD into one link item for each word and keep one copy on the libblis link rule, as make links it. Use Threads::Threads for the default pthread item on Android. Bionic keeps the pthread functions in libc. Rewrite the dylib install name at install time with CMAKE_INSTALL_NAME_TOOL. A --prefix relocation sets the id to the new libdir. Keep CMake 3.20 compatibility: no IS_EXECUTABLE condition, no NO_CACHE option, and no newer minimum. Known limits: - Mach-O compatibility and current version fields stay at make's values (ld64 0.0.0). A dylib built by an earlier CMake revision of this branch with other fields cannot overwrite the installed file. - A CMake-built executable can record a nonzero Mach-O compatibility version. dyld can then reject a 0.0.0 dylib that replaces the previous file. - A LIBPTHREAD value with a space-separated option pair, like -L /opt/custom/lib -lpthread, splits into one item for each word. CMake can drop the bare directory item. - No real AOCC, ARMClang, NVHPC, mingw, macOS or Android NDK toolchain compiled this code. CI is the first real test. Checked and not changed: - pthreads link flags with system support off. Probe F1 proved this FALSE. configure forces single threading when system support is off, so the branch does not run. - A trailing comma in -Wl,--export-all-symbols, that goes to the linker. Probe F3 proved this FALSE. The flag is compile only and does not go to the link editor. Assisted-by: Claude Opus 5.5 (claude-opus-5-5) Assisted-by: Qwen/Qwen3.8-27B-FP8 Assisted-by: XiaomiMiMo/MiMo-V2.6-Pro-MOPD Assisted-by: gpt-6.1-sol (review)
Re-checked at
One remaining bug: a default macOS install leaves the dylib id as
A consumer linked with the Minor:
With the install-name fix, this looks ready to merge as experimental from my side. — Claude |
Give the RISC-V preprocess probe the toolchain flags. A cross clang build can auto-detect its config. Compare blastest omit names in full. Omitting only xerbla_array no longer disables the blastest drivers. Correct the docs and the CircleCI comments. No comment names a file or tool that this tree does not have. Make compiler detection agree with configure: the AOCC release parse, ARMClang to clang, the icc 15.0 skx rule, and correct yes and no flags. Gate the vendor flags like common.mk: -fopenmp, -pthread, clang warnings, symbol flags and SIMD flags go to the gcc, icc and clang blocks only. Add -lrt on Linux only, with the Bionic probe. Give Darwin the raw LIBPTHREAD text that make writes in LDFLAGS and blis.pc. Move the Windows export flags to the link command. The compile-only copy is gone, and the flags control DLL exports. Add aocc to the OpenMP, visibility, SIMD and pthread flag branches. This differs from make on purpose, because common.mk has no aocc in those blocks. Split LIBPTHREAD into one link item for each word and keep one copy on the libblis link rule, as make links it. Use Threads::Threads for the default pthread item on Android. Bionic keeps the pthread functions in libc. Rewrite the dylib install name at install time with CMAKE_INSTALL_NAME_TOOL. A --prefix relocation sets the id to the new libdir. Keep CMake 3.20 compatibility: no IS_EXECUTABLE condition, no NO_CACHE option, and no newer minimum. Known limits: - Mach-O compatibility and current version fields stay at make's values (ld64 0.0.0). A dylib built by an earlier CMake revision of this branch with other fields cannot overwrite the installed file. - A CMake-built executable can record a nonzero Mach-O compatibility version. dyld can then reject a 0.0.0 dylib that replaces the previous file. - A LIBPTHREAD value with a space-separated option pair, like -L /opt/custom/lib -lpthread, splits into one item for each word. CMake can drop the bare directory item. - No real AOCC, ARMClang, NVHPC, mingw, macOS or Android NDK toolchain compiled this code. CI is the first real test. Checked and not changed: - pthreads link flags with system support off. Probe F1 proved this FALSE. configure forces single threading when system support is off, so the branch does not run. - A trailing comma in -Wl,--export-all-symbols, that goes to the linker. Probe F3 proved this FALSE. The flag is compile only and does not go to the link editor. Assisted-by: Claude Opus 5.5 (claude-opus-5-5) Assisted-by: Qwen/Qwen3.8-27B-FP8 Assisted-by: XiaomiMiMo/MiMo-V2.6-Pro-MOPD Assisted-by: gpt-6.1-sol (review)
399351a to
8bc5290
Compare
|
Closing remark written by Claude (Anthropic's AI model). I'm posting it as-is, at my request. All the findings from the earlier reviews are fixed at Where the lines goThe PR adds about 4,480 lines: roughly 3,860 of CMake, 430 of CI config and 210 of docs. Most of the CMake isn't building BLIS. It's reproducing make's interface: its target names, I'd question that goal. If configure eventually becomes a thin wrapper around CMake, as was suggested earlier in this thread, the code that imitates make turns into dead weight. A narrower definition of parity would cover most of what matters: the same objects, the same flags, and the same installed library, headers, What I'd cut
That comes to about 1,000 to 1,100 lines. None of it touches flag assembly, so the per-object parity check (338 objects, identical to make) should still pass. Smaller things
What I'd keep
The rest should stay as it is: registry expansion, compiler blacklisting and auto-detect, the None of this blocks merging the build as experimental. It's more about keeping it small if it ever becomes the main build. Claude |
|
@devinamatthews Should we merge this? |
|
If there are features that we can cut. Happy to do so. I asked AI to
maintain feature parity as that is easily verifiable
|
Hi Devin,
I would like to make contributions to blis but all my editors require cmake for linting to work. I asked AI to port all the options and features from the current build system in cmake. And I asked them to verify that the compile commands are the same flag per flag, file per file object per object.
After a few rounds of review, modularization I ended up with something I understand seems reasonable. I re-wrote the docs as they were full of em dashes. The performance on my machine is the same as other other build system. And in my tests it does what I expect. This does not need to be mainteined for others. You can mark it as experimental dev only. I only need this to be able to make other changes, mainly by hand.
Cheers,
Marco
The CMake build supports the configure options, environment variables, make target names, compiler flags and install layout of the configure/make build. It adds per-config flag tables, the testsuite, blastest and examples in dual mode, documentation in docs/BuildSystemCMake.md~~, and GitHub Actions CI for Linux, macOS and Windows~~.
Assisted-by: XiaomiMiMo/MiMo-V2.6-Pro-MOPD
Assisted-by: claude-sonnet-5-5
Assisted-by: Qwen/Qwen3.8-27B-FP8
Assisted-by: claude-opus-5-5
Assisted-by: mistralai/Mistral-Medium-3.5-128B