conda-forge / zstd-feedstock

A conda-smithy repository for zstd.
BSD 3-Clause "New" or "Revised" License
2 stars 26 forks source link

Cannot use CMake zstd config file #58

Closed rouault closed 2 years ago

rouault commented 2 years ago

Solution to issue cannot be found in the documentation.

Issue

lib/cmake/zstd/zstdTargets.cmake refers to a lib/libzstd.a file that doesn't exist, which prevents using find_package(zstd)

Given the following CMakeLists.txt file:

cmake_minimum_required(VERSION 3.10)
project(test LANGUAGES C)
find_package(zstd)

running cmake . -DCMAKE_PREFIX_PATH=$CONDA_PREFIX gives the following error:

-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /home/even/miniconda3/envs/zstd_test/lib/cmake/zstd/zstdTargets.cmake:87 (message):
  The imported target "zstd::libzstd_static" references the file

     "/home/even/miniconda3/envs/zstd_test/lib/libzstd.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/home/even/miniconda3/envs/zstd_test/lib/cmake/zstd/zstdTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /home/even/miniconda3/envs/zstd_test/lib/cmake/zstd/zstdConfig.cmake:1 (include)
  CMakeLists.txt:3 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/even/test/CMakeFiles/CMakeOutput.log".

Installed packages

# packages in environment at /home/even/miniconda3/envs/zstd_test:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
libgcc-ng                 11.2.0              h1d223b6_13    conda-forge
libgomp                   11.2.0              h1d223b6_13    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_13    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zstd                      1.5.2                ha95c52a_0    conda-forge

Environment info

active environment : zstd_test
    active env location : /home/even/miniconda3/envs/zstd_test
            shell level : 1
       user config file : /home/even/.condarc
 populated config files : /home/even/.condarc
          conda version : 4.11.0
    conda-build version : 3.21.4
         python version : 3.8.8.final.0
       virtual packages : __cuda=11.4=0
                          __linux=5.13.0=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/even/miniconda3  (writable)
      conda av data dir : /home/even/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/even/miniconda3/pkgs
                          /home/even/.conda/pkgs
       envs directories : /home/even/miniconda3/envs
                          /home/even/.conda/envs
               platform : linux-64
             user-agent : conda/4.11.0 requests/2.25.1 CPython/3.8.8 Linux/5.13.0-28-generic ubuntu/20.04.4 glibc/2.31
                UID:GID : 1000:1000
             netrc file : /home/even/.netrc
           offline mode : False
h-vetinari commented 2 years ago

Running into the same problem in https://github.com/conda-forge/llvmdev-feedstock/pull/163, in an otherwise unchanged recipe.

h-vetinari commented 2 years ago

OK, this is because build.sh hard-deletes the static libs without telling CMake about it.

hmaarrfk commented 2 years ago

I think this has been a general grip with how certain static libraries get packages.

The configuration files, like the cmake ones, dont get duplicated, so the static and the dynamic library start to conflict.

hmaarrfk commented 2 years ago

maybe we should use the options instead

https://github.com/facebook/zstd/blob/ae4670466c5db56493f356c1a81e8cbefef3271e/build/cmake/lib/CMakeLists.txt#L13

hmaarrfk commented 2 years ago

@conda-forge-admin please rerender

conda-forge-linter commented 2 years ago

Hi! This is the friendly automated conda-forge-webservice.

I just wanted to let you know that I rerendered the recipe in conda-forge/zstd-feedstock#61.

h-vetinari commented 2 years ago

Actually, this seems to cause other problems as well (https://github.com/conda-forge/llvmdev-feedstock/pull/163):

[...]
[166/166] Linking CXX executable bin/llvm-config
FAILED: bin/llvm-config 
[...]/bin/ld: $PREFIX/lib/libzstd.so.1.5.2: error adding symbols: file in wrong format

At first this looked like a cross-compilation issue, but it's definitely zstd-related, because the same switch

[...]
[434/3181] Building native llvm-config...
[1/152] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o
[...]
[152/152] Linking CXX executable bin/llvm-config
[444/3181] Linking CXX shared module unittests/Support/DynamicLibrary/SecondLib.so
[...]

happened for the (successful) LLVM 14 as well.