Skip to content

[Build] Source Build Fails on Linux - FetchContent for External Dependencies Fails (Not a git repository) #3640

@robert-macmillan

Description

@robert-macmillan

When attempting to build ArrayFire from source on Linux, CMake fails with errors Failed to get the hash for HEAD: and fatal: not a git repository: '.git'. Errors are the result of FetchContent_Populate called from AFconfigure_deps_vars.cmake and appear for all external dependencies.

Description

I am building ArrayFire from source following the instructions provided on the Build Instructions for Linux wiki page. I had previously followed these instructions successfully on 11/19/2024, and I executed the same code as before but with the failed results shown here.

I am fairly certain the build issue is caused by CMake attempting to fetch the external dependencies (e.g., forge, spdlog) and not finding either an acceptable .cmake file or retrieving a .git repository from FetchContent_Populate. The issue begins on line 256 of CMakeLists.txt --- I was attempting to build arrayfire using the following commands:

# Building ArrayFire
RUN git clone --recursive https://github.com/arrayfire/arrayfire.git && \
    cd arrayfire && \
    mkdir build && cd build && \
    . /opt/intel/oneapi/setvars.sh intel64 && \
    cmake .. -DCMAKE_BUILD_TYPE=Release -DAF_BUILD_OPENCL=ON -DAF_BUILD_EXAMPLES=OFF -DBUILD_TESTING=ON && make -j8

The call stack is:

30.37 Call Stack (most recent call first):
30.37   CMakeModules/AFfetch_content.cmake:822 (__FetchContent_directPopulate)
30.37   CMakeModules/AFconfigure_deps_vars.cmake:114 (FetchContent_Populate)
30.37   CMakeModules/AFconfigure_forge_dep.cmake:90 (af_dep_check_and_populate)
30.37   CMakeLists.txt:256 (include)

This issue appears to be related to #3527 and arrayfire/forge#236 opened in early January 2024. I could not figure out how to address this issue based on either issue. #3527 remains Open.

The build environment is a Docker container based on Ubuntu and created by meticulously following the Build Instructions for Linux. Here is the Dockerfile defining the build environment.

FROM ubuntu:latest

# Install General Dependencies
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends pkg-config build-essential git cmake libfreeimage-dev && \
    apt-get install -y --no-install-recommends nano wget tar gzip ca-certificates gpg-agent && \
    wget --no-check-certificate https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \
    tar -xf boost_1_87_0.tar.gz && cp -r boost_1_87_0/boost /usr/local/include

# Install CPU Backend Dependencies
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends libopenblas-dev libfftw3-dev liblapacke-dev

# Install CUDA Backend Dependencies
RUN wget --no-check-certificate https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb && \
    dpkg -i cuda-keyring_1.1-1_all.deb && \
    apt-get update -y && \
    apt-get install -y cuda-12-6

ENV PATH="${PATH}:/usr/local/cuda-12.6/bin"

# Install Intel oneAPI Base Toolkit Backend Dependencies
RUN apt-get update -y && apt-get install -y gnupg2 && \
    # download the key to system keyring
    wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
    | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \
    # add signed entry to apt sources and configure the APT client to use Intel repository
    echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
    | sudo tee /etc/apt/sources.list.d/oneAPI.list && \
    apt-get -y update && apt-get install -y intel-oneapi-base-toolkit

# Install OpenCL Backend Dependencies
RUN apt-get update -y && \
    apt-get install -y opencl-headers ocl-icd-opencl-dev

# Install ArrayFire Graphics Library
RUN apt-get update -y && \
    apt-get install -y libglfw3-dev libfontconfig1-dev doxygen

# Building ArrayFire
RUN git clone --recursive https://github.com/arrayfire/arrayfire.git && \
    cd arrayfire && \
    mkdir build && cd build && \
    . /opt/intel/oneapi/setvars.sh intel64 && \
    cmake .. -DCMAKE_BUILD_TYPE=Release -DAF_BUILD_OPENCL=ON -DAF_BUILD_EXAMPLES=OFF -DBUILD_TESTING=ON && make -j8

And here is the command used to build the docker container
docker build -t build-arrayfire:0.2.1 -f ./Dockerfiles/Dockerfile-build-arrayfire .

Error Log

30.37 [ 11%] Creating directories for 'af_forge-populate'
30.37 [ 22%] Performing download step for 'af_forge-populate'
30.37 [ 33%] Performing disconnected update step for 'af_forge-populate'
30.37 CMake Error at /arrayfire/build/extern/af_forge-subbuild/af_forge-populate-prefix/tmp/af_forge-populate-gitupdate.cmake:34 (message):
30.37   Failed to get the hash for HEAD:
30.37 
30.37   fatal: not a git repository: '.git'
30.37 
30.37 
30.37 
30.37 gmake[2]: *** [CMakeFiles/af_forge-populate.dir/build.make:126: af_forge-populate-prefix/src/af_forge-populate-stamp/af_forge-populate-update_disconnected] Error 1
30.37 gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/af_forge-populate.dir/all] Error 2
30.37 gmake: *** [Makefile:91: all] Error 2
30.37 
30.37 CMake Error at CMakeModules/AFfetch_content.cmake:798 (message):
30.37   Build step for af_forge failed: 2
30.37 Call Stack (most recent call first):
30.37   CMakeModules/AFfetch_content.cmake:822 (__FetchContent_directPopulate)
30.37   CMakeModules/AFconfigure_deps_vars.cmake:114 (FetchContent_Populate)
30.37   CMakeModules/AFconfigure_forge_dep.cmake:90 (af_dep_check_and_populate)
30.37   CMakeLists.txt:256 (include)
30.37 
30.37 
30.37 -- Configuring incomplete, errors occurred!

Build Environment

Compiler version: GNU 13.3.0, Cuda release 12.6 (V12.6.85)
CMake version: 3.28.3
Host Operation System: Ubuntu 22.04.5 LTS
Build Operating system: Ubuntu 24.04.1 LTS (hosted in Docker)
Docker version: 28.0.1
Build environment: See Dockerfile above ... please let me know if you need additional information
CMake variables:

-- Cache values
AF_BUILD_CPU:BOOL=ON
AF_BUILD_CUDA:BOOL=ON
AF_BUILD_DOCS:BOOL=ON
AF_BUILD_EXAMPLES:BOOL=OFF
AF_BUILD_FORGE:BOOL=OFF
AF_BUILD_ONEAPI:BOOL=OFF
AF_BUILD_OPENCL:BOOL=ON
AF_BUILD_UNIFIED:BOOL=ON
AF_CACHE_KERNELS_TO_DISK:BOOL=ON
AF_COMPUTE_LIBRARY:STRING=Intel-MKL
AF_CTEST_SEPARATED:BOOL=OFF
AF_INSTALL_STANDALONE:BOOL=OFF
AF_SKIP_UNSUPPORTED_TESTS:BOOL=OFF
AF_STACKTRACE_TYPE:STRING=Basic
AF_WITH_CPUID:BOOL=ON
AF_WITH_CUDNN:BOOL=OFF
AF_WITH_EXTERNAL_PACKAGES_ONLY:BOOL=OFF
AF_WITH_FAST_MATH:BOOL=OFF
AF_WITH_FMT_HEADER_ONLY:BOOL=OFF
AF_WITH_IMAGEIO:BOOL=ON
AF_WITH_LOGGING:BOOL=ON
AF_WITH_NONFREE:BOOL=OFF
AF_WITH_RELATIVE_TEST_DIR:BOOL=OFF
AF_WITH_SPDLOG_HEADER_ONLY:BOOL=OFF
AF_WITH_STACKTRACE:BOOL=ON
AF_WITH_STATIC_CUDA_NUMERIC_LIBS:BOOL=OFF
AF_WITH_STATIC_FREEIMAGE:BOOL=OFF
AF_WITH_STATIC_MKL:BOOL=OFF
CLBlast_DIR:PATH=CLBlast_DIR-NOTFOUND
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_INSTALL_PREFIX:PATH=/usr/local
CUDA_HOST_COMPILER:FILEPATH=/usr/bin/cc
CUDA_SDK_ROOT_DIR:PATH=CUDA_SDK_ROOT_DIR-NOTFOUND
CUDA_TOOLKIT_ROOT_DIR:PATH=/usr/local/cuda-12.6
CUDA_USE_STATIC_CUDA_RUNTIME:BOOL=ON
Forge_DIR:PATH=Forge_DIR-NOTFOUND
GTest_DIR:PATH=GTest_DIR-NOTFOUND
MKL_DIR:PATH=MKL_DIR-NOTFOUND
MKL_THREAD_LAYER:STRING=Intel OpenMP
MKL_mkl_avx_LINK_LIBRARY:FILEPATH=MKL_mkl_avx_LINK_LIBRARY-NOTFOUND
MKL_mkl_mc_LINK_LIBRARY:FILEPATH=MKL_mkl_mc_LINK_LIBRARY-NOTFOUND
fmt_DIR:PATH=fmt_DIR-NOTFOUND
glad_DIR:PATH=glad_DIR-NOTFOUND
span-lite_DIR:PATH=span-lite_DIR-NOTFOUND
spdlog_DIR:PATH=spdlog_DIR-NOTFOUND

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions