NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57615: Install ldscript as libfoo.so to handle dependencies b/w libraries



>Number:         57615
>Category:       lib
>Synopsis:       Install ldscript as libfoo.so to handle dependencies b/w libraries
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 11 03:30:01 +0000 2023
>Originator:     Rin Okuyama
>Release:        10.99.7
>Organization:
Internet Initiative Japan Inc.
>Environment:
NetBSD netbsd 10.99.7 NetBSD 10.99.7 (AMD64_NET_MPSAFE) #2: Tue Aug 15 12:13:48 JST 2023  rin@netbsd:/home/rin/src/sys/arch/amd64/compile/AMD64_NET_MPSAFE amd64
>Description:
Currently, we locally enable --copy-dt-needed-entries by default for
ld(1) to handle dependencies between shared libraries:

http://mail-index.netbsd.org/source-changes/2023/09/11/msg147552.html

Without this workaround, for example, symbols from libterminfo.so
cannot be resolved for curses(3) based applications, unless -lterminfo
is explicitly specified. See, e.g., PR lib/57592:

http://gnats.netbsd.org/57592

Another candidate fix should be to add -Wl,--copy-dt-needed-entries to
LDFLAGS in /usr/share/mk/sys.mk. Then, this flag is enabled when
compiling 3rd party applications, as long as their build frameworks
(configure etc.) respect LDFLAGS.

However, IMO, more better fix should be install dedicated ldscripts for
such libraries, instead of hacking around global ld(1) flags. That is,
for the case of libcurses, provide this script

----
INPUT(/usr/lib/libcurses.so.9.1 AS_NEEDED(-lterminfo))
----

as /usr/lib/libcurses.so. Then, -lterminfo is automatically specified
for -lcurses. And this is what FreeBSD does, which has separated
libncursesw and libtinfow recently with this trick:

https://cgit.freebsd.org/src/tree/lib/ncurses/ncurses

I think we can generate such a ldscript by using LIBDPLIBS (not only
just for libcurses, but for other libraries also). Do you think this
is a correct way to go?

Also, we can handle static libraries in a similar manner, but in this
case, we need to change default prefix for library itself, i.e., we
need to reserve libfoo.a as ldscript, and other file name for archive.
>How-To-Repeat:
N/A
>Fix:
Described above.



Home | Main Index | Thread Index | Old Index