NetBSD Problem Report #57615

From www@netbsd.org  Mon Sep 11 03:27:23 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id DDA0D1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 11 Sep 2023 03:27:23 +0000 (UTC)
Message-Id: <20230911032722.4A95F1A9239@mollari.NetBSD.org>
Date: Mon, 11 Sep 2023 03:27:22 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Install ldscript as libfoo.so to handle dependencies b/w libraries
X-Send-Pr-Version: www-1.0

>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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.