Skip to content
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

CHOLMOD: Add dependency to system libraries after SuiteSparse libraries #555

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Nov 30, 2023

The headers of OpenMP might be installed at a location where headers of older versions of SuiteSparse libraries are installed.
Try two approaches to avoid that these older headers are picked up when building CHOLMOD:

  • Add the dependency to OpenMP (and other system libraries) after the dependencies to other SuiteSparse libraries have been added.
  • Link to the OpenMP target instead of adding the include folder.

Maybe that helps with the issue described in #175.

@Fabian188: Could you please test this if you come around to it?

This might help with the search order of include and library directories.
Use OpenMP CMake target instead of library and include folder names.
Maybe helps with the issue described in DrTimothyAldenDavis#175.
@DrTimothyAldenDavis DrTimothyAldenDavis merged commit 6840af6 into DrTimothyAldenDavis:dev2 Nov 30, 2023
23 checks passed
@DrTimothyAldenDavis
Copy link
Owner

I've also added #error messages if a stale header is found, so that the compile-time errors (if any) will be more obvious.

See my next push to dev2, coming shortly.

@DrTimothyAldenDavis
Copy link
Owner

If this change fixes CHOLMOD, it would need to be done in all packages that use OpenMP, right?

That would be GraphBLAS, LAGraph, ParU, SPQR, and UMFPACK.

SuiteSparse_config also brings in OpenMP.

@Fabian188
Copy link

@mmuetzel Did I understand you right, that I shall pull dev2 and do cmake --fresh?

I did like this

grep include CM*
CMakeCache.txt://C header files (include)
CMakeCache.txt:CMAKE_INSTALL_INCLUDEDIR:PATH=include
CMakeCache.txt://C header files for non-gcc (/usr/include)
CMakeCache.txt:CMAKE_INSTALL_OLDINCLUDEDIR:PATH=/usr/include
CMakeCache.txt:OpenMP_CXX_INCLUDE_DIR:PATH=/opt/homebrew/include
CMakeCache.txt:OpenMP_C_INCLUDE_DIR:PATH=/opt/homebrew/include
 git log | head -n 20
commit 9b590e9d8076810cd68862fd3179397fb9ff86a6
Merge: bc21716ac 6840af6d0
Author: Tim Davis <[email protected]>
Date:   Thu Nov 30 12:57:35 2023 -0600

    Merge branch 'dev2' of https://github.com/DrTimothyAldenDavis/SuiteSparse into dev2

commit bc21716ac739ad8827b3faa6b748a6f4153d57da
Author: Tim Davis <[email protected]>
Date:   Thu Nov 30 12:57:29 2023 -0600

    add #error tests to check for stale headers

commit 6840af6d0485198df14b83d917c057fb44f5e242
Merge: 1e0c53a32 195f652d0
Author: Tim Davis <[email protected]>
Date:   Thu Nov 30 12:51:26 2023 -0600

    Merge pull request #555 from mmuetzel/cholmod

I get the new error message but the problem persists.

Consolidate compiler generated dependencies of target UMFPACK
/Library/Developer/CommandLineTools/usr/bin/make  -f UMFPACK/CMakeFiles/UMFPACK.dir/build.make UMFPACK/CMakeFiles/UMFPACK.dir/build
[ 19%] Building C object UMFPACK/CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o
cd /Users/fwein/code/SuiteSparse-org/mybuild/UMFPACK && /Library/Developer/CommandLineTools/usr/bin/cc -DBLAS_Apple -DUMFPACK_EXPORTS -I/Users/fwein/code/SuiteSparse-org/mybuild/UMFPACK -I/Users/fwein/code/SuiteSparse-org/UMFPACK -I/Users/fwein/code/SuiteSparse-org/UMFPACK/Source -I/Users/fwein/code/SuiteSparse-org/UMFPACK/Include -I/Users/fwein/code/SuiteSparse-org/SuiteSparse_config -I/opt/homebrew/include -I/Users/fwein/code/SuiteSparse-org/AMD/Include -I/Users/fwein/code/SuiteSparse-org/CHOLMOD/Include -Xclang -fopenmp  -O3 -DNDEBUG -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.5 -fPIC -MD -MT UMFPACK/CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o -MF CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o.d -o CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o -c /Users/fwein/code/SuiteSparse-org/UMFPACK/Source2/umf_di_assemble.c
In file included from /Users/fwein/code/SuiteSparse-org/UMFPACK/Source2/umf_di_assemble.c:10:
In file included from /Users/fwein/code/SuiteSparse-org/UMFPACK/Source/umf_assemble.c:14:
In file included from /Users/fwein/code/SuiteSparse-org/UMFPACK/Source/umf_internal.h:330:
/Users/fwein/code/SuiteSparse-org/UMFPACK/Include/umfpack.h:87:2: error: "UMFPACK 6.3.0 requires SuiteSparse_config 7.4.0 or later"
#error "UMFPACK 6.3.0 requires SuiteSparse_config 7.4.0 or later"
 ^
/Users/fwein/code/SuiteSparse-org/UMFPACK/Include/umfpack.h:91:2: error: "UMFPACK 6.3.0 requires AMD 3.3.0 or later"
#error "UMFPACK 6.3.0 requires AMD 3.3.0 or later"
 ^

@Fabian188
Copy link

Honestly I wonder why brew brings in the headers. Does brew build locally? I thought binaries are pulled and AAIK I don't have any dev variants tools to compile against.

@DrTimothyAldenDavis
Copy link
Owner

Ok. That's progress. At least the new #error check is catching the issue.

Here's the problem that remains:

...
-I/Users/fwein/code/SuiteSparse-org/SuiteSparse_config -I/opt/homebrew/include -I/Users/fwein/code/SuiteSparse-org/AMD/Include -I/Users/fwein/code/SuiteSparse-org/CHOLMOD/Include ...

Note that the homebrew include comes before the AMD include. So it gets the stale amd.h in /opt/himebrew/include and not the latest amd.h in Users/fwein/code/SuiteSparse-org/AMD/Include

My guess is we need the same fix to umfpack as @mmuetzel made to cholmod, to bring in OpenMP after AMD.

Same for SPQR, ParU, etc.

@Fabian188
Copy link

This is the list of what had be built:

make
[  0%] Built target SuiteSparseConfig
[  0%] Built target SuiteSparseConfig_static
[  1%] Built target Mongoose_static
[  1%] Built target Mongoose
[  1%] Built target Mongoose_static_dbg
[  1%] Built target mongoose_exe
[  1%] Built target demo_exe
[  1%] Built target mongoose_test_io
[  1%] Built target mongoose_test_edgesep
[  1%] Built target mongoose_test_memory
[  1%] Built target mongoose_test_performance
[  1%] Built target mongoose_test_reference
[  1%] Built target mongoose_unit_test_io
[  1%] Built target mongoose_unit_test_graph
[  1%] Built target mongoose_unit_test_edgesep
[  1%] Built target AMD
[  1%] Built target AMD_static
[  2%] Built target BTF
[  2%] Built target BTF_static
[  2%] Built target CAMD
[  3%] Built target CAMD_static
[  3%] Built target CCOLAMD
[  3%] Built target CCOLAMD_static
[  3%] Built target COLAMD
[  3%] Built target COLAMD_static
[  6%] Built target CHOLMOD
[ 10%] Built target CHOLMOD_static
[ 10%] Built target cholmod_di_demo
[ 10%] Built target cholmod_dl_demo
[ 10%] Built target cholmod_si_demo
[ 10%] Built target cholmod_sl_demo
[ 14%] Built target CXSparse
[ 17%] Built target CXSparse_static
[ 17%] Built target LDL
[ 17%] Built target LDL_static
[ 18%] Built target KLU
[ 19%] Built target KLU_static
[ 19%] Built target KLU_CHOLMOD
[ 19%] Built target KLU_CHOLMOD_static

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Dec 1, 2023

If this change fixes CHOLMOD, it would need to be done in all packages that use OpenMP, right?

That would be GraphBLAS, LAGraph, ParU, SPQR, and UMFPACK.

SuiteSparse_config also brings in OpenMP.

Correct.

Theoretically, it's not only OpenMP that can be problematic. The same could happen for BLAS, LAPACK, MPFR, or any other dependency.

@DrTimothyAldenDavis
Copy link
Owner

CHOLMOD uses the BLAS, LAPACK, OpenMP, and CUDA, and your change to CHOLMOD worked for @Fabian188 because the most recent failure was in UMFPACK not getting the proper amd.h.

So CHOLMOD must have worked (@Fabian188 : can you confirm)? If it worked, it found the correct amd.h, and not the stale one in /opt/homebrew/include.

I tried homebrew on my Mac (intel-based) and this issue didn't occur. I might be using a different OpenMP library that isn't in homebrew, perhaps. I installed suite-sparse from homebrew, too, just to see what would happen. It has an older version (SuiteSparse 7.2) but it didn't put the include files in /opt/homebrew/include.

I'll try it on my MacBook Air; maybe that will trigger this issue.

@DrTimothyAldenDavis
Copy link
Owner

Got it! I can replicate the issue.

I installed with "brew install suite-sparse" on my MacBook Air, and it placed a slightly stale copy of all of SuiteSparse include files in /opt/homebrew/include.

Then I did "make" at the top-level of SuiteSparse (not using the root CMakeLists.txt). CHOLMOD builds fine, so it must be finding the correct amd.h (version 3.3.0). The /opt/homebrew/include/amd.h is 3.0.4.

But then KLU failed. It reports the following:

[ 98%] Building C object CMakeFiles/KLU_CHOLMOD_static.dir/User/klu_cholmod.c.o
/Library/Developer/CommandLineTools/usr/bin/cc  -I/Users/davis/dev2/SuiteSparse/KLU/build -I/Users/davis/dev2/SuiteSparse/KLU -I/Users/davis/dev2/SuiteSparse/KLU/Source -I/Users/davis/dev2/SuiteSparse/KLU/Include -I/Users/davis/dev2/SuiteSparse/KLU/User -isystem /Users/davis/dev2/SuiteSparse/CHOLMOD/Include -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include -isystem /Users/davis/dev2/SuiteSparse/CAMD/Include -isystem /Users/davis/dev2/SuiteSparse/CCOLAMD/Include -isystem /usr/local/include -isystem /Users/davis/dev2/SuiteSparse/BTF/Include -O3 -DNDEBUG -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.6 -Xclang -fopenmp -MD -MT CMakeFiles/KLU_CHOLMOD_static.dir/User/klu_cholmod.c.o -MF CMakeFiles/KLU_CHOLMOD_static.dir/User/klu_cholmod.c.o.d -o CMakeFiles/KLU_CHOLMOD_static.dir/User/klu_cholmod.c.o -c /Users/davis/dev2/SuiteSparse/KLU/User/klu_cholmod.c
In file included from /Users/davis/dev2/SuiteSparse/KLU/User/klu_cholmod.c:22:
In file included from /Users/davis/dev2/SuiteSparse/KLU/User/klu_cholmod.h:11:
/Users/davis/dev2/SuiteSparse/KLU/Include/klu.h:842:2: error: "KLU 2.3.0 requires BTF 2.3.0 or later"
#error "KLU 2.3.0 requires BTF 2.3.0 or later"
 ^
1 error generated.

In the script above, /usr/local/include comes before /Users/davis/dev2/SuiteSparse/BTF/Include.
Note that I have 2 stale copies of BTF. I have:

  1. /usr/local/include/btf.h version 2.2.1, which I probably installed myself sometime, with "make install" from my own older copy of SuiteSparse itself.
  2. /opt/homebrew/include/btf.h version 2.0.4 which is a symbolic link to ../Cellar/suite-sparse/7.1.0/include/btf.h

Either btf.h file above needs to be ignored by cmake, of course. I deleted the /usr/local/include/btf.h file and KLU built just fine. Interestingly, it was KLU_CHOLMOD_static that failed. KLU itself built just fine.

If I touch Source/klu.c and rebuild with verbose, klu.c builds fine and doesn't use -I/usr/local/include:

[ 48%] Building C object CMakeFiles/KLU_static.dir/Source/klu.c.o
/Library/Developer/CommandLineTools/usr/bin/cc  -I/Users/davis/dev2/SuiteSparse/KLU/build -I/Users/davis/dev2/SuiteSparse/KLU -I/Users/davis/dev2/SuiteSparse/KLU/Source -I/Users/davis/dev2/SuiteSparse/KLU/Include -I/Users/davis/dev2/SuiteSparse/KLU/User -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include -isystem /Users/davis/dev2/SuiteSparse/BTF/Include -O3 -DNDEBUG -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.6 -MD -MT CMakeFiles/KLU_static.dir/Source/klu.c.o -MF CMakeFiles/KLU_static.dir/Source/klu.c.o.d -o CMakeFiles/KLU_static.dir/Source/klu.c.o -c /Users/davis/dev2/SuiteSparse/KLU/Source/klu.c

If I put a garbage /usr/local/include/btf.h with a syntax error in it, and do a clean build, klu.o builds just fine. klu_cholmod.c chokes on the garbage /usr/local/include/btf.h.

Building the klu_cholmod.c for the shared library works just fine. It's only the STATIC klu_cholmod build that fails by tripping over the garbage btf.h.

@DrTimothyAldenDavis
Copy link
Owner

So it's not homebrew that is the problem, I think, because /usr/local/include/btf.h wasn't coming from brew.

@DrTimothyAldenDavis
Copy link
Owner

Continuing further, it's the both the dynamic and static build of UMFPACK that fails, because it finds the wrong SuiteSparse_config and the wrong amd.h:

Consolidate compiler generated dependencies of target UMFPACK
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/UMFPACK.dir/build.make CMakeFiles/UMFPACK.dir/build
[  0%] Building C object CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -DBLAS_Apple -DUMFPACK_EXPORTS -I/Users/davis/dev2/SuiteSparse/UMFPACK/build -I/Users/davis/dev2/SuiteSparse/UMFPACK -I/Users/davis/dev2/SuiteSparse/UMFPACK/Source -I/Users/davis/dev2/SuiteSparse/UMFPACK/Include -I/usr/local/include -F/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/System/Library/Frameworks -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/CHOLMOD/Include -Xclang -fopenmp  -O3 -DNDEBUG -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.6 -fPIC -MD -MT CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o -MF CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o.d -o CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o -c /Users/davis/dev2/SuiteSparse/UMFPACK/Source2/umf_di_assemble.c
In file included from /Users/davis/dev2/SuiteSparse/UMFPACK/Source2/umf_di_assemble.c:10:
In file included from /Users/davis/dev2/SuiteSparse/UMFPACK/Source/umf_assemble.c:14:
In file included from /Users/davis/dev2/SuiteSparse/UMFPACK/Source/umf_internal.h:330:
/Users/davis/dev2/SuiteSparse/UMFPACK/Include/umfpack.h:87:2: error: "UMFPACK 6.3.0 requires SuiteSparse_config 7.4.0 or later"
#error "UMFPACK 6.3.0 requires SuiteSparse_config 7.4.0 or later"
 ^
/Users/davis/dev2/SuiteSparse/UMFPACK/Include/umfpack.h:91:2: error: "UMFPACK 6.3.0 requires AMD 3.3.0 or later"
#error "UMFPACK 6.3.0 requires AMD 3.3.0 or later"
 ^
2 errors generated.
make[2]: *** [CMakeFiles/UMFPACK.dir/Source2/umf_di_assemble.c.o] Error 1
make[1]: *** [CMakeFiles/UMFPACK.dir/all] Error 2
make: *** [all] Error 2
mac $ 

Note the order of include directories in the command above that fails:

 -I/usr/local/include 
 -F/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/System/Library/Frameworks
 -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config 
 -isystem /Users/davis/dev2/SuiteSparse/AMD/Include
 -isystem /Users/davis/dev2/SuiteSparse/CHOLMOD/Include 

I'm using the built-in Apple Clang 15. I'm using SuiteSparse/UMFPACK/CMakeLists.txt directly, not the root CMakeLists.txt. Removing /usr/local/include/amd.h and /usr/local/include/SuiteSparse_config.h allows UMFPACK to build successfully.

@DrTimothyAldenDavis
Copy link
Owner

Then the ParU build fails because gets the stale /usr/local/include/umfpack.h. It would also fail because it would link in the stale amd.h, colamd.h, etc.

[ 51%] Building CXX object CMakeFiles/ParU_static.dir/Source/paru_Diag_update.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++ -DBLAS_Apple -I/Users/davis/dev2/SuiteSparse/ParU/build -I/Users/davis/dev2/SuiteSparse/ParU -I/Users/davis/dev2/SuiteSparse/ParU/Source -I/Users/davis/dev2/SuiteSparse/ParU/Include -I/Users/davis/dev2/SuiteSparse/ParU/../UMFPACK/Source -F/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/System/Library/Frameworks -isystem /Users/davis/dev2/SuiteSparse/CHOLMOD/Include -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /usr/local/include -isystem /Users/davis/dev2/SuiteSparse/UMFPACK/Include -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include -isystem /Users/davis/dev2/SuiteSparse/CAMD/Include -isystem /Users/davis/dev2/SuiteSparse/CCOLAMD/Include -O3 -DNDEBUG -std=gnu++11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.6 -Xclang -fopenmp -MD -MT CMakeFiles/ParU_static.dir/Source/paru_Diag_update.cpp.o -MF CMakeFiles/ParU_static.dir/Source/paru_Diag_update.cpp.o.d -o CMakeFiles/ParU_static.dir/Source/paru_Diag_update.cpp.o -c /Users/davis/dev2/SuiteSparse/ParU/Source/paru_Diag_update.cpp
In file included from /Users/davis/dev2/SuiteSparse/ParU/Source/paru_Diag_update.cpp:20:
In file included from /Users/davis/dev2/SuiteSparse/ParU/Source/paru_internal.hpp:17:
In file included from /Users/davis/dev2/SuiteSparse/ParU/Include/ParU.hpp:42:
/Users/davis/dev2/SuiteSparse/ParU/Include/ParU_definitions.h:39:2: error: "ParU 0.1. requires UMFPACK 6.3.0 or later"
#error "ParU 0.1. requires UMFPACK 6.3.0 or later"

@DrTimothyAldenDavis
Copy link
Owner

Correction, ParU doesn't #include amd.h, colamd.h, etc directly. Once the stale umfpack.h is removed, ParU builds fine.

Then SPQR fails because it gets the stale CHOLMOD, etc.

So I can replicate the problem on my side, and I can test against the #include'ing of stale files in my /usr/local/include folder. It's not quite the same error that @Fabian188 is seeing, where /opt/homebrew/include causes the problem. But the theme is the same.

I can force all /usr/local/include/*.h files from a stale SuiteSparse to be present, and then watch which new build of SuiteSparse fails.

@Fabian188
Copy link

So I can replicate the problem on my side, and I can test against the #include'ing of stale files in my /usr/local/include folder. It's not quite the same error that @Fabian188 is seeing, where /opt/homebrew/include causes the problem. But the theme is the same.

I assume you have an older Intel MacBook air? If you switch, you'll compile significantly faster (4 times for my software) and your errors will be from /opt/homebrew, too :)

@DrTimothyAldenDavis
Copy link
Owner

It's a M1 Air. The brew I used to install suite-sparse was the arm-based brew, and I'm building a native arm. The gcc I'm using is not really gcc but:

mac $ gcc --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I'm not sure why I'm seeing the errors from the /usr/local/include folder and not /opt/homebrew/include. But the principle is the same, at least.

@DrTimothyAldenDavis
Copy link
Owner

Oh, here's a twist. SPEX uses gmp and mpfr from homebrew, and I get conflicts with /opt/homebrew/include, not from /usr/local/include:

Consolidate compiler generated dependencies of target SPEX
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/SPEX.dir/build.make CMakeFiles/SPEX.dir/build
[  1%] Building C object CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -DSPEX_EXPORTS -I/Users/davis/dev2/SuiteSparse/SPEX/build -I/Users/davis/dev2/SuiteSparse/SPEX -I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source -I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Util/Source -I/Users/davis/dev2/SuiteSparse/SPEX/Include -I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Demo -I/opt/homebrew/include -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include -O3 -DNDEBUG -std=gnu11 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -mmacosx-version-min=13.6 -fPIC -MD -MT CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o -MF CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o.d -o CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o -c /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c
In file included from /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c:45:
In file included from /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/spex_left_lu_internal.h:18:
In file included from /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Util/Source/spex_util_internal.h:106:
/Users/davis/dev2/SuiteSparse/SPEX/Include/SPEX.h:270:2: error: "SPEX 2.3.0 requires SuiteSparse_config 7.4.0 or later"
#error "SPEX 2.3.0 requires SuiteSparse_config 7.4.0 or later"

Note the bad order in the command above:

-I/opt/homebrew/include -isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config -isystem /Users/davis/dev2/SuiteSparse/AMD/Include -isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include

Sorry for all the github spam :-).

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Dec 1, 2023

Building the klu_cholmod.c for the shared library works just fine. It's only the STATIC klu_cholmod build that fails by tripping over the garbage btf.h.

Documentation is a bit sparse on this topic (or I didn't find the correct places). But what I gather from CMake's sources is that the library dependencies (i.e., the -l and -L flags) are always transient for static libraries -- no matter if the dependency was linked with PRIVATE, PUBLIC, or INTERFACE scope. But the latter makes a difference for pre-processor flags (e.g., -D and -I flags) for shared and for static libraries.
If that is true, we should probably make most of the dependencies PRIVATE also for the static libraries. That is in those cases where we do not want -I or -D flags to be inherited. That's already done for the shared libraries. So, we could probably just mirror the scope settings from there...
That difference is probably what makes the build succeed when linking to the CHOLMOD target, but makes it fail when linking to the CHOLMOD_static target.

I'll try to prepare a changeset for that some time later today or tomorrow. But I can't reproduce the issue here. It would be nice if you could check if that actually helps.

mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this pull request Dec 1, 2023
Changes to the CMake build rules for KLU, ParU, SPQR, and UMFPACK that are
similar to DrTimothyAldenDavis#555.
@DrTimothyAldenDavis
Copy link
Owner

The problem comes from both dynamic and static cases. I'm seeing the same kind of errors with stale headers when building the Example library on my MacBook Air, after I did

brew install suite-sparse
that places all of the SuiteSparse 7.1.0 headers in /opt/homebrew/include, and in the list of -I, the -I/opt/homebrew/include comes first. This happens for both the dynamic and static build of the Example library.

The Example library prints out the version numbers it gets from the headers, and (in most cases) also calls the library itself to get the version number via a function call. It prints out both ... and they don't match. The headers are stale but the libraries are the most recent ones. For example, for CHOLMOD, both my_demo and my_demo_static report:

CHOLMOD: v4.0.4 (June 16, 2023)
CHOLMOD: v5.1.0 (in library)

This was after a LOCAL_INSTALL option, so all the include files and libraries are found in SuiteSparse/include and SuiteSparse/lib. I will try a "make ; sudo make install" of suiteSparse and then try the Example to see if that makes a difference.

mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this pull request Dec 1, 2023
Changes to the CMake build rules for KLU, ParU, SPEX, SPQR, and UMFPACK
that are similar to DrTimothyAldenDavis#555.
mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this pull request Dec 1, 2023
Changes to the CMake build rules for KLU, ParU, SPEX, SPQR, and UMFPACK
that are similar to DrTimothyAldenDavis#555.
mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this pull request Dec 1, 2023
Changes to the CMake build rules for KLU, ParU, SPEX, SPQR, and UMFPACK
that are similar to DrTimothyAldenDavis#555.
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