ElmerCSC / elmerfem

Official git repository of Elmer FEM software
http://www.elmerfem.org
Other
1.15k stars 315 forks source link

UMFPACK integration and build process issues in Windows MSYS2 environment #479

Closed Foadsf closed 3 weeks ago

Foadsf commented 1 month ago

Description

I'm encountering persistent issues with UMFPACK integration and the build process in the Windows MSYS2 environment. Despite several attempts to resolve these problems, I'm still facing difficulties in successfully building the project.

Current State

I'm currently on the fix-umf4-wrapper branch, commit 743306ef15087aa60b3ebe2c844716f93e809dc2. This branch represents my attempts to resolve UMFPACK-related issues and improve the build process.

Steps to Reproduce

  1. Clone the repository and checkout the fix-umf4-wrapper branch:

    git checkout fix-umf4-wrapper
    git checkout 743306ef15087aa60b3ebe2c844716f93e809dc2
  2. Ensure you're in an MSYS2 MinGW 64-bit environment.

  3. Run the bootstrap script:

    ./bootstrap.sh clean

Current Issues

  1. CMake warns about unused UMFPACK_ROOT variable:

    CMake Warning:
     Manually-specified variables were not used by the project:
       UMFPACK_ROOT
  2. Build process fails due to missing 'umfpack.h':

    ...\elmerfem\fem\src\umf4_f77wrapper.c:81:10: fatal error: umfpack.h: No such file or directory
      81 | #include "umfpack.h"
         |          ^~~~~~~~~~~
    compilation terminated.
  3. Potential issues with CMake configuration and UMFPACK integration.

What I've Tried

  1. Updated bootstrap.sh to automatically install required packages, including UMFPACK via SuiteSparse.
  2. Modified CMake commands to include UMFPACK_ROOT.
  3. Added checks in the build script to verify UMFPACK detection.
  4. Reviewed and updated CMakeLists.txt files to better handle UMFPACK.

Next Steps

I need assistance with:

  1. Properly integrating UMFPACK with the project's CMake configuration.
  2. Ensuring that the umfpack.h header is correctly located and included.
  3. Resolving any potential conflicts between the project's build system and the MSYS2 environment.
  4. Reviewing the overall build process for any other issues that may be preventing successful compilation.

Any insights or suggestions would be greatly appreciated. Thank you for your help!

Biswa96 commented 1 month ago

I have cloned the fix-umf4-wrapper branch. The following diff may fix the issue with umfpack.h include.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -653,7 +653,7 @@ ELSE()
   ADD_SUBDIRECTORY(umfpack)
   SET(HAVE_UMFPACK TRUE)
   SET(UMFPACK_LIBRARIES umfpack)
-  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/umfpack/include)
+  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/umfpack/src/umfpack/include)
 ENDIF()

 ADD_SUBDIRECTORY(fhutiter)

But now I get a different error which does not seem related to msys2.

Fatal Error: Cannot open module file 'huti_interfaces.mod' for reading at (1): No such file or directory
mmuetzel commented 1 month ago

The CMake build rules seem to be pretty dated. I applied the following patch on top of your fix-umf4-wrapper branch to be even able to configure with cmake -DWITH_MPI=OFF -DEXTERNAL_UMFPACK=ON -DWITH_OpenMP=ON -DCMAKE_C_FLAGS="-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" .. --fresh: 0001-Some-updates-for-CMake-build-rules.patch

Additionally, I made the following change to fix the build order (what @Biswa96 pointed out) and link to the necessary dependencies: 0002-WIP-build-order-and-library-dependencies.patch That one probably needs to be cleaned up because it looks like some of this is already done conditionally on MPI.

But even with these changes, building the tests (with cmake --build .) doesn't work:

ninja: build stopped: multiple rules generate fmodules/toroidcurrents.mod.

So, I applied the following patch and configured with cmake -DWITH_MPI=OFF -DEXTERNAL_UMFPACK=ON -DWITH_OpenMP=ON -DCMAKE_C_FLAGS="-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" -DENABLE_TESTING=OFF .. --fresh: 0003-optional-tests.patch

With that, building succeeded. But I don't know how to test it now...

I hope that helps.

Biswa96 commented 1 month ago

The new bootstrap.sh has many redundant checks. pacman -S --needed already checks if a package is installed. pacman -Syu also shows which packages are being updated.

Foadsf commented 1 month ago

@Biswa96 and @mmuetzel thanks a lot. Here is a summary of what I did:

Given that you are MSYS2 experts, could you be kind enough to help me fix the bootstrap.sh bash script? The idea is that anyone with a freshly installed environment should be able to run it to automatically check if it is being run in the right environment if the right dependency packages are installed, and if not install them, and then build and compile automatically.

P.S. Relevant discussion here on MSYS2 Discord

mmuetzel commented 3 weeks ago

ElmerFEM is building with MSYS2 with the bundled UMFPACK and with the library that is distributed by MSYS2 in CI now.

I guess this could be closed.