Bug 274108 - devel/libnotify: fix build with lld 17
Summary: devel/libnotify: fix build with lld 17
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-desktop (Team)
URL:
Keywords:
Depends on:
Blocks: 273753
  Show dependency treegraph
 
Reported: 2023-09-26 14:24 UTC by Dimitry Andric
Modified: 2023-11-26 21:08 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (desktop)


Attachments
devel/libnotify: fix build with lld 17 (624 bytes, patch)
2023-09-26 14:25 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2023-09-26 14:24:53 UTC
Building devel/libnotify with lld 17 results in the following link error:

cc  -o libnotify/libnotify.so.4.0.0 libnotify/libnotify.so.4.0.0.p/meson-generated_.._notify-enum-types.c.o libnotify/libnotify.so.4.0.0.p/meson-generated_.._notify-marshal.c.o libnotify/libnotify.so.4.0.0.p/notify.c.o libnotify/libnotify.so.4.0.0.p/notification.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libnotify.so.4 -fstack-protector-strong -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Wl,-rpath,/usr/local/lib -Wl,-rpath-link,/usr/local/lib -Wl,--version-script,/wrkdirs/share/dim/ports/devel/libnotify/work/libnotify-0.8.2/libnotify/libnotify.map /usr/local/lib/libgdk_pixbuf-2.0.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so /usr/local/lib/libgio-2.0.so -Wl,--end-group
ld: error: version script assignment of 'global' to symbol '__progname' failed: symbol not defined
ld: error: version script assignment of 'global' to symbol 'environ' failed: symbol not defined
cc: error: linker command failed with exit code 1 (use -v to see invocation)

This is because lld 17 defaults to errors when undefined symbols are referenced in linker version scripts.

Apparently the __progname and environ symbols (which usually come from libc, not libnotify.so) were explicitly added in:

commit 0b0b10cff8d7b5ed08d11c6fa4d66e1977d6eb79
Author: Baptiste Daroussin <bapt@FreeBSD.org>
Date:   2019-12-16T19:40:37+01:00

    Fix build with old binutils.

    Somehow linker scripts should not hide __progname and environ from symbols.

    Reported by:    kib

but it is unclear what the original error was, or how old "old" is, and there is no reference to a PR.

In any case, I think the devel/libnotify/files/patch-libnotify_libnotify.map file can simply be deleted now.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2023-09-26 14:25:36 UTC
Created attachment 245257 [details]
devel/libnotify: fix build with lld 17
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-10-06 17:52:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=623262a13efb4c659fda87783fb5e6164c24a774

commit 623262a13efb4c659fda87783fb5e6164c24a774
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-09-26 14:19:09 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-10-06 17:48:54 +0000

    devel/libnotify: fix build with lld 17

    Building devel/libnotify with lld 17 results in the following link
    error:

      cc  -o libnotify/libnotify.so.4.0.0 libnotify/libnotify.so.4.0.0.p/meson-generated_.._notify-enum-types.c.o libnotify/libnotify.so.4.0.0.p/meson-generated_.._notify-marshal.c.o libnotify/libnotify.so.4.0.0.p/notify.c.o libnotify/libnotify.so.4.0.0.p/notification.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libnotify.so.4 -fstack-protector-strong -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Wl,-rpath,/usr/local/lib -Wl,-rpath-link,/usr/local/lib -Wl,--version-script,/wrkdirs/share/dim/ports/devel/libnotify/work/libnotify-0.8.2/libnotify/libnotify.map /usr/local/lib/libgdk_pixbuf-2.0.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so /usr/local/lib/libgio-2.0.so -Wl,--end-group
      ld: error: version script assignment of 'global' to symbol '__progname' failed: symbol not defined
      ld: error: version script assignment of 'global' to symbol 'environ' failed: symbol not defined
      cc: error: linker command failed with exit code 1 (use -v to see invocation)

    This is because lld 17 defaults to errors when undefined symbols are
    referenced in linker version scripts.

    Apparently the __progname and environ symbols (which usually come from
    libc, not libnotify.so) were explicitly added in:

    commit 0b0b10cff8d7b5ed08d11c6fa4d66e1977d6eb79
    Author: Baptiste Daroussin <bapt@FreeBSD.org>
    Date:   2019-12-16T19:40:37+01:00

        Fix build with old binutils.

        Somehow linker scripts should not hide __progname and environ from symbols.

        Reported by:    kib

    but it is unclear what the original error was, or how old "old" is, and
    there is no reference to a PR.

    In any case, I think the patch-libnotify_libnotify.map file can simply
    be deleted now.

    PR:             274108
    Approved by:    maintainer timeout (10 days)
    MFH:            2023Q4

 devel/libnotify/files/patch-libnotify_libnotify.map (gone) | 11 -----------
 1 file changed, 11 deletions(-)
Comment 3 Romain Tartière freebsd_committer freebsd_triage 2023-11-26 01:30:28 UTC
Unfortunately, this break notify-send, see 275104
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-11-26 18:25:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=50e1b669d76a12aab4bc9646261cd426847dc825

commit 50e1b669d76a12aab4bc9646261cd426847dc825
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-11-26 18:09:08 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-11-26 18:21:23 +0000

    devel/libnotify: fix build with lld 17 (take 2)

    The fix for bug 274108 broke running the notify-send command, resulting
    in:

      ld-elf.so.1: /usr/local/lib/libglib-2.0.so.0: Undefined symbol "environ"

    This is because libnotify uses the same linker version script for both
    its libnotify.so shared library and for its notify-send executable.

    The linker version script places all symbols that do not begin with
    "notify_" into the local scope, making them effectively hidden. This is
    fine for a shared library, but not for an executable, since it will also
    hide the symbols "environ" and "__progname", which are required for most
    programs.

    Fix it by not using the linker version script for the notify-send
    executable, so no required symbols are hidden.

    PR:             275104, 274108
    MFH:            2023Q4

 .../libnotify/files/patch-libnotify_meson.build (new)  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-11-26 21:08:18 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8498d8899949e5aba0fe6056411514478fae5cc5

commit 8498d8899949e5aba0fe6056411514478fae5cc5
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-11-26 21:05:36 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-11-26 21:06:42 +0000

    devel/libnotify: bump portrevision after 50e1b669d76a

    This is because the change influences runtime behavior: the port built
    successfully before, but only the notify-send command did not behave
    correctly.

    Noted by:       kib
    PR:             275104, 274108
    MFH:            2023Q4

 devel/libnotify/Makefile | 1 +
 1 file changed, 1 insertion(+)