libgit2 icon indicating copy to clipboard operation
libgit2 copied to clipboard

build failed if -DUSE_ICONV=ON is given

Open leleliu008 opened this issue 2 years ago • 6 comments

Reproduction steps

curl -LO https://github.com/libgit2/libgit2/archive/v1.5.1.tar.gz
tar vxf v1.5.1.tar.gz
cd libgit2-1.5.1

cmake \
    -S . \
    -B build.d \
    -DBUILD_TESTS=OFF \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_SHARED_LIBS=OFF \
    -DUSE_SSH=OFF \
    -DUSE_ICONV=ON \
    -DUSE_HTTPS=OpenSSL \
    -DREGEX_BACKEND=pcre2 \
    -DCMAKE_FIND_ROOT_PATH='/home/leleliu008/.ppkg/installed/openssl;/home/leleliu008/.ppkg/installed/pcre2;/home/leleliu008/.ppkg/installed/zlib;/home/leleliu008/.ppkg/installed/libiconv' \
    -DCMAKE_C_FLAGS=-I/home/leleliu008/.ppkg/installed/openssl/include \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DCMAKE_FIND_DEBUG_MODE=ON \
    -DCMAKE_FIND_USE_CMAKE_PATH=ON \
    -DCMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH=OFF \
    -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF \
    -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF \
    -DCMAKE_FIND_USE_INSTALL_PREFIX=OFF \
    -DCMAKE_INCLUDE_PATH=/include \
    -DCMAKE_LIBRARY_PATH=/lib \
    -DCMAKE_PROGRAM_PATH='/bin;/sbin'
cmake --build build.d

Expected behavior

ca be successfully built.

Actual behavior

/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv_init_precompose':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:982: undefined reference to `libiconv_open'
/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv_clear':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:990: undefined reference to `libiconv_close'
/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:1015: undefined reference to `libiconv'
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/cli/CMakeFiles/git2_cli.dir/build.make:596: git2_cli] Error 1
gmake[2]: Leaving directory '/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/build.d'
gmake[1]: *** [CMakeFiles/Makefile2:326: src/cli/CMakeFiles/git2_cli.dir/all] Error 2
gmake[1]: Leaving directory '/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/build.d'
gmake: *** [Makefile:139: all] Error 2

cmake-config.log cmake-build.log

Version of libgit2 (release number or SHA1)

https://github.com/libgit2/libgit2/archive/v1.5.1.tar.gz

Operating system(s) tested

ubuntu-22.10

more

I noticed that cmake config log say Found Iconv: provided by libc, this is not correct, I using a seperate libiconv, I do not use the iconv functions in libc. It seems that libiconv.so was not linked into the git2 due to it was expected to be provided by libc but actually it was in a seperate library.

leleliu008 avatar Feb 11 '23 19:02 leleliu008

Thanks for the bug report. We can take a look.

In the meantime, I'm curious why you want iconv on Linux at all?

ethomson avatar Feb 15 '23 10:02 ethomson

libiconv implemented by GNU is full featured, although musl libc also implements libiconv, but older version do not support all features in GNU's libiconv.

leleliu008 avatar Feb 16 '23 02:02 leleliu008

That's not what I'm asking - iconv support is really only useful for core.precomposeUnicode which is a macOS feature. I'm curious why you're enabling it on Linux?

ethomson avatar Feb 16 '23 07:02 ethomson

I'm writing a package manager, I find this library supports libiconv, I enable it for all platfroms.

leleliu008 avatar Feb 16 '23 07:02 leleliu008

If don't expect to be used in GNU/Linux system, it's better to give a warnning if user enables it, I didn't dig into the source code, although your docs say iconv (OSX) to handle the HFS+ path encoding peculiarities, I thought your build system would ignore -DUSE_ICONV=ON on GNU/Linux, but actually it didn't, so I thought it was a bug. If it isn't a bug, fell free to close it.

leleliu008 avatar Feb 16 '23 07:02 leleliu008

It should work with USE_ICONV on Unix, and we should fix it if it doesn't. I was just curious about your use case.

ethomson avatar Feb 16 '23 08:02 ethomson