Skip to content

cmake: Use standard try_run instead of execute_process #126

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

Merged

Conversation

LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Apr 3, 2025

The previous approach creates unwanted artifacts in the source directory and does not propagate generator/fortran compiler, etc.

Depends-on: #123

Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
@LecrisUT
Copy link
Contributor Author

LecrisUT commented Apr 3, 2025

@prj- See this PR, this should address your issue in #123 (comment)

@prj-
Copy link
Contributor

prj- commented Apr 3, 2025

I don't understand what is going here. When will master be functional with CMake 4.0.0? What are the least amount of changes needed to make it work again?

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Apr 3, 2025

I don't understand what is going here. When will master be functional with CMake 4.0.0?

The failure that you shared in #123 is unrelated to CMake 4.0. It should be occurring in the master branch as well. This change should take care of the failure where you had to specify the compiler with FC

What are the least amount of changes needed to make it work again?

2f142d6, all the rest are the commits from #123

@prj-
Copy link
Contributor

prj- commented Apr 4, 2025

It should be occurring in the master branch as well.

It does not.

$ ../../../bin/cmake --version
cmake version 3.31.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ ../../../bin/cmake .. -DCMAKE_INSTALL_PREFIX=/media/psf/repositories/petsc/arch-scalapack -DCMAKE_INSTALL_NAME_DIR:STRING="/media/psf/repositories/petsc/arch-scalapack/lib" -DCMAKE_INSTALL_LIBDIR:STRING="lib" -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR="/usr/bin/ar" -DCMAKE_C_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc" -DMPI_C_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc" -DCMAKE_RANLIB=/usr/bin/ranlib -DCMAKE_C_FLAGS:STRING="-Wno-lto-type-mismatch -Wno-stringop-overflow -g -O0 -Wno-implicit-int -Wno-int-conversion -Wno-implicit-function-declaration -Wno-deprecated-non-prototype -fno-common" -DCMAKE_C_FLAGS_DEBUG:STRING="-Wno-lto-type-mismatch -Wno-stringop-overflow -g -O0 -Wno-implicit-int -Wno-int-conversion -Wno-implicit-function-declaration -Wno-deprecated-non-prototype -fno-common" -DCMAKE_C_FLAGS_RELEASE:STRING="-Wno-lto-type-mismatch -Wno-stringop-overflow -g -O0 -Wno-implicit-int -Wno-int-conversion -Wno-implicit-function-declaration -Wno-deprecated-non-prototype -fno-common" -DCMAKE_CXX_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicxx" -DMPI_CXX_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicxx" -DCMAKE_CXX_FLAGS:STRING="-Wno-lto-type-mismatch -Wno-psabi -g -O0" -DCMAKE_CXX_FLAGS_DEBUG:STRING="-Wno-lto-type-mismatch -Wno-psabi -g -O0" -DCMAKE_CXX_FLAGS_RELEASE:STRING="-Wno-lto-type-mismatch -Wno-psabi -g -O0" -DCMAKE_Fortran_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90" -DMPI_Fortran_COMPILER="/media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90" -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none -ffree-line-length-0 -Wno-lto-type-mismatch -g -O0 -fallow-argument-mismatch" -DCMAKE_Fortran_FLAGS_DEBUG:STRING="-ffree-line-length-none -ffree-line-length-0 -Wno-lto-type-mismatch -g -O0 -fallow-argument-mismatch" -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-ffree-line-length-none -ffree-line-length-0 -Wno-lto-type-mismatch -g -O0 -fallow-argument-mismatch" -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_STATIC_LIBS:BOOL=OFF -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON -DLAPACK_LIBRARIES="-lf2clapack -lf2cblas -lm -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -L/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lmpifort -lmpi -lgfortran -lm -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -L/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lgfortran -lm -lgcc_s" -DSCALAPACK_BUILD_TESTS=OFF
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- The C compiler identification is GNU 14.2.0
-- The Fortran compiler identification is GNU 14.2.0
cc1: warning: command-line option ‘-ffree-line-length-512’ is valid for Fortran but not for C
cc1: warning: command-line option ‘-fallow-argument-mismatch’ is valid for Fortran but not for C
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90 - skipped
-- Found MPI_C: /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc (found version "4.1")
-- Found MPI_Fortran: /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90 (found version "4.1")
-- Found MPI: TRUE (found version "4.1")
-- Found MPI_LIBRARY : TRUE 
-- --> MPI C Compiler : /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc
-- --> C Compiler : /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpicc
-- --> MPI Fortran Compiler : /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90
-- --> Fortran Compiler : /media/psf/repositories/petsc/arch-linux-c-debug-real/bin/mpif90
-- =========
-- Compiling and Building BLACS INSTALL Testing to set correct variables
-- Configure in the INSTALL directory successful
-- Build in the BLACS INSTALL directory successful
-- =========
-- Testing FORTRAN_MANGLING
-- CDEFS set to Add_
-- =========
-- CHECKING BLAS AND LAPACK LIBRARIES
-- --> LAPACK supplied by user is -lf2clapack -lf2cblas -lm -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -L/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lmpifort -lmpi -lgfortran -lm -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -L/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lgfortran -lm -lgcc_s.
-- Looking for Fortran dgesv
-- Looking for Fortran dgesv - found
-- --> LAPACK routine dgesv is found: 1.
-- --> LAPACK supplied by user is WORKING, will use -lf2clapack -lf2cblas -lm -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -L/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lmpifort -lmpi -lgfortran -lm -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -L/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lgfortran -lm -lgcc_s.
-- BLAS library: 
-- LAPACK library: -lf2clapack -lf2cblas -lm -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -L/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lmpifort -lmpi -lgfortran -lm -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/usr/lib/gcc/aarch64-linux-gnu/14 -L/usr/lib/gcc/aarch64-linux-gnu/14 -Wl,-rpath,/media/psf/repositories/petsc/arch-linux-c-debug-real/lib -lgfortran -lm -lgcc_s
-- =========
-- Configuring done (4.0s)
-- Generating done (1.1s)

@prj-
Copy link
Contributor

prj- commented Apr 4, 2025

I've tried to cherry-pick 2f142d6 on top of master and this indeed fix CMake 4.0.0 builds. Would it be possible to merge just this commit first? I'm not sure why you'd want to combine new features and bug fixes in the same PR.

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Apr 4, 2025

It should be occurring in the master branch as well.

It does not.

Unless you can provide me with a dockerfile reproducer I cannot reproduce the issue you've had because

  • on normal systems the Fortran compiler is detectable by the system, but you have a more special layout that requires passing the compiler manually
  • based on reading the code, the previous version is very fragile and it would potentially break for other users
  • the only difference there is the increase of the cmake policy to NEW, but I couldn't find a relevant policy that you are hitting

Would it be possible to merge just this commit first? I'm not sure why you'd want to combine new features and bug fixes in the same PR.

Philosophy, I do not want things merged without proper testing. The tests may not cover or all edge-cases, but I do not want to add PRs without making sure the changes do not have a regression, and the minimum for that w.r.t. CMake environments is #123. Locally I am still unable to build this from a vanilla Fedora container so I am reliant on the CI environment for test coverage.

Otherwise I do organize my PRs and commits to make the review process as easy as possible for upstream developers.

If you want to help, you can contact the upstream developers to get #123 and this PR merge in a timely manner. Or if you are opposed to my philosophy, go ahead and cheerry-pick the change and make another PR and accelerate the process there as you see fit.

@prj-
Copy link
Contributor

prj- commented Apr 8, 2025

@langou, ScaLAPACK currently can't be configured with CMake 4.0.0. Do you have plans to fix this, e.g., by merging some of the open PRs?

@langou
Copy link
Contributor

langou commented Apr 8, 2025

Hi @prj-, do you have a suggestion on which open PRs to merge? Julien.

@LecrisUT
Copy link
Contributor Author

LecrisUT commented Apr 8, 2025

#123 and then this one

@langou langou merged commit 0e87672 into Reference-ScaLAPACK:master Apr 8, 2025
3 of 4 checks passed
@langou
Copy link
Contributor

langou commented Apr 8, 2025

Thanks @LecrisUT. Let me know if there are issues. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants