BallisticLA / RandBLAS

A header-only C++ library for sketching in randomized linear algebra
https://randblas.readthedocs.io/en/stable/
Other
71 stars 5 forks source link

Compilation issues due to concepts #102

Closed jucaleb4 closed 1 month ago

jucaleb4 commented 1 month ago

Hey! I downloaded RandBLAS but am having trouble compiling while following the installation guide. I'm running on a Mac with Ventura 13.6.6.

Specifically, most of the errors are with concepts. First (per the installation guide), I run cmake without any error:

cmake -DCMAKE_BUILD_TYPE=Release \\n    -Dblaspp_DIR=/Users/calebju/Code/github/RandBLAS-build/../blaspp-install/lib/cmake/blaspp/ \\n    -DRandom123_DIR=/Users/calebju/Code/github/RandBLAS-build/../random123-install/include/ \\n    -DCMAKE_BINARY_DIR=/Users/calebju/Code/github/RandBLAS-build \\n    -DCMAKE_INSTALL_PREFIX=/Users/calebju/Code/github/RandBLAS-build/../RandBLAS-install \\n    -DCMAKE_CXX_FLAGS="-D __APPLE__" \\n    ../RandBLAS/

The issue arises once I make:

make -j install

I'll paste a small error snippet, since the other errors are nearly identical to the following (but I can paste more if needed):

/Users/calebju/Code/github/RandBLAS/RandBLAS/../RandBLAS/sparse_data/base.hh:180:21: error: expected concept name with optional arguments
    { A.n_rows } -> std::convertible_to<const int64_t>;

After Google-ing this error, I suspected I may not be using/not have C++20.

I just updated my llvm to version 14 (Homebrew clang version 14.0.6). I checked I have C++20's concepts (I made sure the following code works by compiling this and this code) and following the CMake tutorial, which suggests to add the following to the top of CMakeLists.txt:

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

Given the fact I appear to have C++20 and have specified it in my CMakeList.txt, I am unsure what else to do. Some help would be greatly appreciated!

jucaleb4 commented 1 month ago

I found a hack-y solution to get this to work, and I will write it down here in case it can help anyone.

Here are the steps:

  1. I uninstalled XCode and reinstalled a new one. Doing this upgraded my default clang from v12.0.X to 14.0.3
  2. After installing the new clang, my compiler was complaining it could not find a compiler in XCode anymore. I resolved this by add a new command line argument directing it to my default clang (see option 1 in this suggestion). In particular, my cmake invocation became
    cmake -DCMAKE_BUILD_TYPE=Release \
    -Dblaspp_DIR=/Users/calebju/Code/github/RandBLAS-build/../blaspp-install/lib/cmake/blaspp/ \
    -DRandom123_DIR=/Users/calebju/Code/github/RandBLAS-build/../random123-install/include/ \ 
    -DCMAKE_BINARY_DIR=/Users/calebju/Code/github/RandBLAS-build \
    -DCMAKE_INSTALL_PREFIX=/Users/calebju/Code/github/RandBLAS-build/../RandBLAS-install \
    -DCMAKE_CXX_FLAGS="-D __APPLE__" \
    -D CMAKE_C_COMPILER="/usr/bin/clang" \ 
    ../RandBLAS/

Here is my thought process for coming to this solution:

Even though I had compiled some small C code with concepts by specifying a particular clang and using -std=C++20, my guess is CMake was still using my default clang, which may have been too old and/or did not have C++20 support/default. And my mac is too old to update to the latest XCode. So uninstalling and reinstalling seemed to magically update my default clang.

For some reason, setting CC and CXX (as suggested by this Stack Overflow) to my preferred clang did not work. I had to pass it in the command line.

jucaleb4 commented 1 month ago

Closing this since I found a solution to my compilation issue.