OpenBSD upgrade cmake from 3.20.3 to 3.22.1: Linking issues /different behaviour
I am struggling with a CMake package upgrade from 3.20.3 to 3.22.1. For my example I use weechat-3.3:
With 3.20.3:
cmake ../
-- The C compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for include file langinfo.h
-- Looking for include file langinfo.h - found
-- Looking for include file sys/resource.h
-- Looking for include file sys/resource.h - found
-- Looking for mallinfo
-- Looking for mallinfo - not found
-- Looking for mallinfo2
-- Looking for mallinfo2 - not found
-- Looking for eat_newline_glitch
-- Looking for eat_newline_glitch - found
-- Looking for include file libintl.h
-- Looking for include file libintl.h - found
-- Looking for dgettext
-- Looking for dgettext - not found
-- Looking for libintl_dgettext in /usr/local/lib/libintl.so.7.0
-- Looking for libintl_dgettext in /usr/local/lib/libintl.so.7.0 - found
-- Found Intl: /usr/local/lib/libintl.so.7.0
-- Found GCRYPT: -L/usr/local/lib -lgcrypt -lgpg-error
-- Found ZLIB: /usr/lib/libz.so.6.0 (found version "1.2.11")
-- Looking for libiconv_open in /usr/local/lib/libiconv.so.7.0
-- Looking for libiconv_open in /usr/local/lib/libiconv.so.7.0 - found
-- Looking for iconv_open in /usr/local/lib/libiconv.so.7.0
-- Looking for iconv_open in /usr/local/lib/libiconv.so.7.0 - not found
-- Performing Test ICONV_2ARG_IS_CONST
-- Performing Test ICONV_2ARG_IS_CONST - Failed
-- Found CURL: /usr/local/lib/libcurl.so.26.13 (found version "7.81.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rsadowski/cmake_test/build
with 3.22.1:
-- The C compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for include file langinfo.h
-- Looking for include file langinfo.h - found
-- Looking for include file sys/resource.h
-- Looking for include file sys/resource.h - found
-- Looking for mallinfo
-- Looking for mallinfo - not found
-- Looking for mallinfo2
-- Looking for mallinfo2 - not found
-- Looking for eat_newline_glitch
-- Looking for eat_newline_glitch - found
-- Looking for include file libintl.h
-- Looking for include file libintl.h - found
-- Looking for dgettext
-- Looking for dgettext - not found
-- Looking for libintl_dgettext in /usr/local/lib/libintl.so.7.0
-- Looking for libintl_dgettext in /usr/local/lib/libintl.so.7.0 - not found
CMake Error at CMakeLists.txt:160 (message):
Gettext not found
-- Found GCRYPT: -L/usr/local/lib -lgcrypt -lgpg-error
-- Found ZLIB: /usr/lib/libz.so.6.0 (found version "1.2.11")
-- Looking for libiconv_open in /usr/local/lib/libiconv.so.7.0
-- Looking for libiconv_open in /usr/local/lib/libiconv.so.7.0 - not found
-- Looking for iconv_open in /usr/local/lib/libiconv.so.7.0
-- Looking for iconv_open in /usr/local/lib/libiconv.so.7.0 - not found
-- Performing Test ICONV_2ARG_IS_CONST
-- Performing Test ICONV_2ARG_IS_CONST - Failed
-- Found CURL: /usr/local/lib/libcurl.so.26.13 (found version "7.81.0")
-- Configuring incomplete, errors occurred!
See also "/home/rsadowski/cmake_test/build_new/CMakeFiles/CMakeOutput.log".
See also "/home/rsadowski/cmake_test/build_new/CMakeFiles/CMakeError.log".
cmake/FindIconv.cmake
if(ICONV_FOUND)
# Already in cache, be silent
set(ICONV_FIND_QUIETLY TRUE)
endif()
include(CheckLibraryExists)
include(CheckFunctionExists)
find_path(ICONV_INCLUDE_PATH
NAMES iconv.h
PATHS /usr/include /usr/local/include /usr/pkg/include
)
find_library(ICONV_LIBRARY
NAMES iconv
PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib
)
if(ICONV_INCLUDE_PATH)
if(ICONV_LIBRARY)
check_library_exists("${ICONV_LIBRARY}" libiconv_open "" LIBICONV_OPEN_FOUND)
check_library_exists("${ICONV_LIBRARY}" iconv_open "" ICONV_OPEN_FOUND)
if(LIBICONV_OPEN_FOUND OR ICONV_OPEN_FOUND)
set(ICONV_FOUND TRUE)
endif()
else()
check_function_exists(iconv_open ICONV_FOUND)
endif()
endif()
When we compare CMakeError.log form the both cmake version wee see the following "issue?":
2.20.3:
/usr/bin/cc -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration -DCHECK_FUNCTION_EXISTS=iconv_open CMakeFiles/cmTC_8ef03.dir/CheckFunctionExists.c.o -o cmTC_8ef03 -L/usr/local/lib -liconv -liconv -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
..OK
2.22.1:
/usr/bin/cc -fsigned-char -Wall -Wextra -Werror-implicit-function-declaration -DCHECK_FUNCTION_EXISTS=iconv_open CMakeFiles/cmTC_a9df5.dir/CheckFunctionExists.c.o -o cmTC_a9df5 -Wl,-z,origin,-rpath,/usr/local/lib /usr/local/lib/libiconv.so.7.0 -liconv -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
ld: error: unable to find library -liconv
cc: error: linker command failed with exit code 1 (use -v to see invocation)
This linker call also fails in some other applications on OpenBSD with the same pattern -Wl,-z,origin,-rpath,/usr/local/lib /usr/local/lib/libiconv.so.7.0 -liconv
vs L/usr/local/lib -liconv -liconv
.
I would like to debug this further, would really appreciate ideas on where to look further.