Bug 249143

Summary: pkgbase: Library archive files .a found in non *-dev packages
Product: Base System Reporter: Martin <martin.jakob>
Component: miscAssignee: freebsd-pkgbase (Nobody) <pkgbase>
Status: Closed FIXED    
Severity: Affects Some People CC: dfr, emaste, lwhsu
Priority: --- Keywords: needs-qa, pkgbase
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://reviews.freebsd.org/D41841

Description Martin 2020-09-06 08:03:49 UTC
Following *.a files are found in non dev pkgbase packages

clibs.plist:             /usr/lib/libcurses.a
clibs.plist:             /usr/lib/libcursesw.a
clibs.plist:             /usr/lib/libpthread.a
clibs.plist:             /usr/lib/libtermcap.a
clibs.plist:             /usr/lib/libtermcapw.a
clibs.plist:             /usr/lib/libtermlib.a
clibs.plist:             /usr/lib/libtermlibw.a
clibs.plist:             /usr/lib/libtinfo.a
clibs.plist:             /usr/lib/libtinfow.a
libcompiler_rt.plist:    /usr/lib/libgcc.a
utilities.plist:         /usr/lib/libfl.a
utilities.plist:         /usr/lib/libl.a
utilities.plist:         /usr/lib/libutempter.a

except /usr/lib/libfl.a /usr/lib/libl.a (what are those?), all are symlinks to other libraries:

/usr/lib/libcurses.a@    ->  libncurses.a
/usr/lib/libcursesw.a@   ->  libncursesw.a
/usr/lib/libpthread.a@   ->  libthr.a
/usr/lib/libtermcap.a@   ->  libncurses.a
/usr/lib/libtermcapw.a@  ->  libncursesw.a
/usr/lib/libtermlib.a@   ->  libncurses.a
/usr/lib/libtermlibw.a@  ->  libncursesw.a
/usr/lib/libtinfo.a@     ->  libncurses.a
/usr/lib/libtinfow.a@    ->  libncursesw.a
/usr/lib/libgcc.a@       ->  libcompiler_rt.a
/usr/lib/libfl.a
/usr/lib/libl.a
/usr/lib/libutempter.a@  ->  libulog.a

the symlink targets are already in the respective dev packages, so shouldn't the symlinks themself be there as well?
Comment 1 Ed Maste freebsd_committer freebsd_triage 2020-09-07 17:45:23 UTC
> the symlink targets are already in the respective dev packages, so shouldn't
> the symlinks themself be there as well?

Yes, they should. These come from cases like (from lib/ncurses/ncurses/Makefile):

.if ${MK_INSTALLLIB} != "no"
SYMLINKS+=      libncurses${LIB_SUFFIX}.a ${LIBDIR}/libcurses${LIB_SUFFIX}.a
SYMLINKS+=      libncurses${LIB_SUFFIX}.a ${LIBDIR}/libtermcap${LIB_SUFFIX}.a
SYMLINKS+=      libncurses${LIB_SUFFIX}.a ${LIBDIR}/libtermlib${LIB_SUFFIX}.a
SYMLINKS+=      libncurses${LIB_SUFFIX}.a ${LIBDIR}/libtinfo${LIB_SUFFIX}.a
.endif

We don't currently have a way to tag symlinks as belonging to -dev.
Comment 2 Martin 2020-09-20 10:45:49 UTC
There are some dangling symlinks related to ncurses:
dangling: /usr/lib/libtinfow.so -> libncursesw.so
dangling: /usr/lib/libtermlib.so -> libncurses.so
dangling: /usr/lib/libtinfo.so -> libncurses.so
dangling: /usr/lib/libcurses.so -> libncurses.so
dangling: /usr/lib/libtermcapw.so -> libncursesw.so
dangling: /usr/lib/libcursesw.so -> libncursesw.so
dangling: /usr/lib/libtermcap.so -> libncurses.so
dangling: /usr/lib/libtermlibw.so -> libncursesw.so


and some other dangling links:
dangling: /usr/lib/libpthread.so -> libthr.so
dangling: /usr/lib/libutempter.so -> libulog.so
dangling: /usr/lib/libxnet.so -> libc.so
dangling: /usr/lib/libxo/encoder/test.enc -> /usr/tests/lib/libxo/libenc_test.so
Comment 3 Martin 2020-10-11 12:56:21 UTC
Searching for these symlinks in the METALOG shows this (i omitted the uname=, gname=, mode= and flags= properties):

grep -E "lib(c|ncurses.*|pthread|thr|ulog|utempter|xnet)\.so" /usr/obj/usr/src/amd64.amd64/worldstage/METALOG | sort -b -k 7 | column -t

./lib/libc.so.7           type=file ... size=2031360                     tags=package=clibs
./lib/libncurses.so.9     type=file ... size=401496                      tags=package=clibs
./lib/libncursesw.so.9    type=file ... size=459800                      tags=package=clibs
./lib/libthr.so.3         type=file ... size=129744                      tags=package=clibs
./usr/lib/libcurses.so    type=link ... link=libncurses.so               tags=package=clibs
./usr/lib/libcursesw.so   type=link ... link=libncursesw.so              tags=package=clibs
./usr/lib/libpthread.so   type=link ... link=libthr.so                   tags=package=clibs
./usr/lib/libtermcap.so   type=link ... link=libncurses.so               tags=package=clibs
./usr/lib/libtermcapw.so  type=link ... link=libncursesw.so              tags=package=clibs
./usr/lib/libtermlib.so   type=link ... link=libncurses.so               tags=package=clibs
./usr/lib/libtermlibw.so  type=link ... link=libncursesw.so              tags=package=clibs
./usr/lib/libtinfo.so     type=link ... link=libncurses.so               tags=package=clibs
./usr/lib/libtinfow.so    type=link ... link=libncursesw.so              tags=package=clibs
./usr/lib/libxnet.so      type=link ... link=libc.so                     tags=package=clibs
./usr/lib/libc.so         type=file ... size=134                         tags=package=clibs,dev
./usr/lib/libncurses.so   type=link ... link=../../lib/libncurses.so.9   tags=package=clibs,dev
./usr/lib/libncursesw.so  type=link ... link=../../lib/libncursesw.so.9  tags=package=clibs,dev
./usr/lib/libthr.so       type=link ... link=../../lib/libthr.so.3       tags=package=clibs,dev
./lib/libulog.so.0        type=file ... size=9552                        tags=package=utilities
./usr/lib/libutempter.so  type=link ... link=libulog.so                  tags=package=utilities
./usr/lib/libulog.so      type=link ... link=../../lib/libulog.so.0      tags=package=utilities,dev


The most dangling symlinks are symlinks pointing to another symlink, which does not exist. e.g.

/usr/lib/libcurses.so -> /usr/lib/libncurses.so -> ../../lib/libncurses.so.9

The reason it does not exist on my system, is, that i don't install the dev-, debug-, lib32- and tests-packages.

/usr/lib/libncurses.so   -> ../../lib/libncurses.so.9 
/usr/lib/libncursesw.so  -> ../../lib/libncursesw.so.9
/usr/lib/libthr.so       -> ../../lib/libthr.so.3
/usr/lib/libulog.so      -> ../../lib/libulog.so.0

/usr/lib/libc.so differs a little, because it is a text file, with this content:
GROUP ( /lib/libc.so.7 /usr/lib/libc_nonshared.a )

As i see it, at least the symlinks should be moved from the dev- to the "main" package. Or are there reason for the current placement?

The above mentioned /usr/lib/libxo/encoder/test.enc should be moved to the tests-package because the target is in the /usr/tests/ directory.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2023-05-01 17:12:22 UTC
wrt libfl:

It comes from usr.bin/lex/lib/Makefile. libln.a is (currently) in the utilities-dev package, while two the two links end up in utilities, for the same reason as mentioned above. They're just LINKS rather than SYMLINKS.

.if ${MK_INSTALLLIB} != "no"
LINKS=  ${LIBDIR}/libln.a ${LIBDIR}/libl.a
LINKS+= ${LIBDIR}/libln.a ${LIBDIR}/libfl.a
.endif
Comment 5 dfr 2023-09-12 12:18:49 UTC
I think this happens because bsd.link.mk doesn't know that some of the symlinks should be in -dev packages instead. This puts the symlinks in the main package as dangling links which target files which are installed by the -dev package.
Comment 6 dfr 2023-09-13 10:24:01 UTC
I made a diff which should fix this: https://reviews.freebsd.org/D41841
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-09-14 09:21:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4e899378bf5d89c20430d32982d2635657f34c04

commit 4e899378bf5d89c20430d32982d2635657f34c04
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-09-13 10:18:09 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-09-14 09:19:42 +0000

    pkgbase: put library links and symlinks in the -dev package

    Some libraries (e.g. ncurses) install links to the main library for
    backwards compatibilty. This change ensures that those links are in the
    dev package since the files being linked to are in that package.

    PR:             249143
    MFC after:      1 week
    Reviewed by:    emaste, manu
    Differential Revision: https://reviews.freebsd.org/D41841

 share/mk/bsd.lib.mk   | 1 +
 share/mk/bsd.links.mk | 8 ++++++++
 2 files changed, 9 insertions(+)
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-10-20 14:14:55 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8015c5477bd9a110f12c77ab9d2bd98a15258ec2

commit 8015c5477bd9a110f12c77ab9d2bd98a15258ec2
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-09-13 10:18:09 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-10-20 12:16:47 +0000

    pkgbase: put library links and symlinks in the -dev package

    Some libraries (e.g. ncurses) install links to the main library for
    backwards compatibilty. This change ensures that those links are in the
    dev package since the files being linked to are in that package.

    PR:             249143
    MFC after:      1 week
    Reviewed by:    emaste, manu
    Differential Revision: https://reviews.freebsd.org/D41841

    (cherry picked from commit 4e899378bf5d89c20430d32982d2635657f34c04)

 share/mk/bsd.lib.mk   | 1 +
 share/mk/bsd.links.mk | 8 ++++++++
 2 files changed, 9 insertions(+)