On Mon Oct 22, 2018 at 09:42:17PM +0200, Christian Weisgerber wrote:
> The amd64 architecture has now switched to LLVM's lld linker as the
> default ld(1).
> 
> Known build failures that still need to be fixed:
> 
> productivity/ledger     editline/readline.h not found

I'm trying to explain why the diff below is correct and lld fixes OpenBSD
cmake's CheckLibraryExists[1] function.

Please look at the following CMakeLists.txt code example:


cmake_minimum_required(VERSION 2.8.5)
PROJECT(test)
include(CheckLibraryExists)
check_library_exists(edit readline "" HAVE_EDIT)
if (HAVE_EDIT)
        message("HAVE_EDIT is found")
else()
        message("HAVE_EDIT is NOT found")
endif()


1.) ld.bfd
$ doas ln -f /usr/bin/ld.bfd /usr/bin/ld
$ cmake ../
-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.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
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for readline in edit
-- Looking for readline in edit - not found
HAVE_EDIT is NOT found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rsadowski/cmake_test/build

We see "HAVE_EDIT is NOT found" but it's wrong because readline is in
libedit:

$ objdump -x /usr/obj/lib/libedit/libedit.so.5.2 | grep readline
0000000000000000 l    df *ABS*  0000000000000000 readline.c
00000000002341d0 l     O .bss   0000000000000001 readline.used_event_hook
0000000000234064 g     O .data  0000000000000004 readline_echoing_p
0000000000005660 g     F .text  000000000000019a readline
0000000000234020 g     O .data  0000000000000008 rl_readline_name
0000000000234018 g     O .data  0000000000000004 rl_readline_version

Ok that's a bug in OpenBSD. Let's see with lld:

$ doas ln -f /usr/bin/ld.lld /usr/bin/ld
$  cmake ../
-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.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
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for readline in edit
-- Looking for readline in edit - found
HAVE_EDIT is found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rsadowski/cmake_test/build

HAVE_EDIT is found. Great lld fix that! So back to ledger, after we
found readline in libedit we have "HAVE_EDIT".

Ok let's see in ledger-3.1.1/src/system.hh.in:

   170 #if HAVE_EDIT
   171 #include <editline/readline.h>
   172 #endif

editline/readline.h don't exists in OpenBSD or any port.

I hope I described it well.

Rafael Sadowski

[1]: https://cmake.org/cmake/help/v3.10/module/CheckLibraryExists.html


Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: patches/patch-CMakeLists_txt
diff -N patches/patch-CMakeLists_txt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-CMakeLists_txt        24 Oct 2018 18:59:36 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Unbreak lld.
+check_library_exists() finds function "readline" in libedit and define 
HAVE_EDIT.
+According to this, system.hh.in incldues <editline/readline.h>, which does not
+exist in OpenBSD.
+
+Index: CMakeLists.txt
+--- CMakeLists.txt.orig
++++ CMakeLists.txt
+@@ -231,7 +231,7 @@ endmacro(find_req_library_and_header _header_var _head
+ find_req_library_and_header(GMP_PATH gmp.h GMP_LIB gmp)
+ find_req_library_and_header(MPFR_PATH mpfr.h MPFR_LIB mpfr)
+ 
+-check_library_exists(edit readline "" HAVE_EDIT)
++#check_library_exists(edit readline "" HAVE_EDIT)
+ find_opt_library_and_header(EDIT_PATH histedit.h EDIT_LIB edit HAVE_EDIT)
+ 
+ #find_package(Gettext)           # Used for running tests

Reply via email to