Bug 256654 - x11-wm/plasma5-kwin: trim overlinking via -Wl,--as-needed
Summary: x11-wm/plasma5-kwin: trim overlinking via -Wl,--as-needed
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2021-06-16 18:32 UTC by Jan Beich
Modified: 2024-03-30 09:52 UTC (History)
3 users (show)

See Also:
arrowd: maintainer-feedback+


Attachments
v0 (draft: direct LDFLAGS, _DEPENDS not adjusted) (894 bytes, patch)
2021-06-16 18:32 UTC, Jan Beich
no flags Details | Diff
v1 (draft: direct LDFLAGS) (2.29 KB, patch)
2021-06-16 20:24 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2021-06-16 18:32:55 UTC
Created attachment 225866 [details]
v0 (draft: direct LDFLAGS, _DEPENDS not adjusted)

-Wl,--as-needed is opt-out in Meson (-Db_asneeded=false) but opt-in CMake (-DCMAKE_LINK_WHAT_YOU_USE=ON). When subpackaging (review D16457) arrives kwin_x11 and kwin_wayland can be in separate packages but for now -Wl,--as-needed shaves unused libraries.

--- kwin_x11	before
+++ kwin_x11	after
@@ -1,63 +1,17 @@
  0x0000000000000001 NEEDED               Shared library: [libkwin.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libkwin4_effect_builtins.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libkwineffects.so.13]
- 0x0000000000000001 NEEDED               Shared library: [libkwinglutils.so.13]
- 0x0000000000000001 NEEDED               Shared library: [libKF5GlobalAccelPrivate.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Plasma.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5QuickAddons.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5Quick.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5QmlModels.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5Qml.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5Crash.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Service.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5WaylandClient.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libkdecorations2.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libkdecorations2private.so.8]
- 0x0000000000000001 NEEDED               Shared library: [libKScreenLocker.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Notifications.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Package.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5WindowSystem.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5GlobalAccel.so.5]
  0x0000000000000001 NEEDED               Shared library: [libQt5X11Extras.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5ConfigWidgets.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Codecs.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5ConfigGui.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5ConfigCore.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5Xml.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Auth.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5AuthCore.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5CoreAddons.so.5]
  0x0000000000000001 NEEDED               Shared library: [libKF5I18n.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKF5WidgetsAddons.so.5]
  0x0000000000000001 NEEDED               Shared library: [libQt5Widgets.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5Network.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libQt5Concurrent.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libKWaylandServer.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libwayland-server.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-composite.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-damage.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-glx.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-icccm.so.4]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-keysyms.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-randr.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-shm.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-sync.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-xfixes.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-render.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxcb-shape.so.0]
  0x0000000000000001 NEEDED               Shared library: [libxcb.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libinput.so.10]
- 0x0000000000000001 NEEDED               Shared library: [libudev.so.0]
- 0x0000000000000001 NEEDED               Shared library: [libxkbcommon.so.0]
  0x0000000000000001 NEEDED               Shared library: [libQt5Gui.so.5]
  0x0000000000000001 NEEDED               Shared library: [libQt5Core.so.5]
- 0x0000000000000001 NEEDED               Shared library: [libGL.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libepoxy.so.0]
- 0x0000000000000001 NEEDED               Shared library: [liblcms2.so.2]
- 0x0000000000000001 NEEDED               Shared library: [libKF5Activities.so.5]
  0x0000000000000001 NEEDED               Shared library: [libQt5DBus.so.5]
  0x0000000000000001 NEEDED               Shared library: [libc++.so.1]
  0x0000000000000001 NEEDED               Shared library: [libcxxrt.so.1]
- 0x0000000000000001 NEEDED               Shared library: [libm.so.5]
  0x0000000000000001 NEEDED               Shared library: [libthr.so.3]
  0x0000000000000001 NEEDED               Shared library: [libc.so.7]
Comment 1 Jan Beich freebsd_committer freebsd_triage 2021-06-16 20:24:08 UTC
Created attachment 225873 [details]
v1 (draft: direct LDFLAGS)

Total gain is minor due to indirect dependencies and plugins.

$ pkg upgrade -qy
$ pkg autoremove -n
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 2 packages:

Installed packages to be REMOVED:
        kf5-krunner: 5.82.0
        kf5-threadweaver: 5.82.0

Number of packages to be removed: 2

$ pkg rquery %n:\ %sh kf5-krunner kf5-threadweaver
kf5-krunner: 422KiB
kf5-threadweaver: 273KiB
Comment 2 Jan Beich freebsd_committer freebsd_triage 2021-06-16 20:24:42 UTC
Comment on attachment 225873 [details]
v1 (draft: direct LDFLAGS)

poudriere log: https://reviews.freebsd.org/P510
Comment 3 Gleb Popov freebsd_committer freebsd_triage 2023-05-18 06:33:08 UTC
What are implications of putting -Wl,--as-needed into LDFLAGS for all ports?
Comment 4 Jan Beich freebsd_committer freebsd_triage 2023-05-31 10:44:46 UTC
(In reply to Gleb Popov from comment #3)
Out of scope. Exposing underlinking bugs but I haven't investigated what other distros do.

Already default in USES=meson via https://github.com/mesonbuild/meson/commit/58ca96994f5a Maybe safe in USES=cmake, less safe in GNU_CONFIGURE and "here be dragons" elsewhere.
Comment 5 Gleb Popov freebsd_committer freebsd_triage 2023-09-01 13:53:40 UTC
How about adding USES=cmake:asneeded ? It doesn't fit there, but this will give us a way to opt-in for arbitrary ports and then just flip the switch and remove the argument.
Comment 6 Tobias C. Berner freebsd_committer freebsd_triage 2023-09-06 18:07:37 UTC
(In reply to Gleb Popov from comment #5)
Moin moin 

If you add it to cmake.mk, I would probably opt for an opt-out flag, like for ninja: noninja.


mfg Tobias
Comment 7 Gleb Popov freebsd_committer freebsd_triage 2023-09-28 07:33:15 UTC
I'm a bit confused. According to https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6263/diffs the -DCMAKE_LINK_WHAT_YOU_USE=ON arguments actually adds -Wl,--**no**as-needed ???
Comment 8 Gleb Popov freebsd_committer freebsd_triage 2023-10-16 15:49:22 UTC
After a bit of digging [1] it turns out that CMake doesn't have a direct counterpart for -Db_asneeded and -DCMAKE_LINK_WHAT_YOU_USE does serves a completely different purpose.

I think it is fine to get the patch in as it is.

[1] https://stackoverflow.com/q/77279155/637669
Comment 9 Gleb Popov freebsd_committer freebsd_triage 2024-03-30 09:52:43 UTC
Jan, if you do not plan to push this, let's close the PR?