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]
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 on attachment 225873 [details] v1 (draft: direct LDFLAGS) poudriere log: https://reviews.freebsd.org/P510
What are implications of putting -Wl,--as-needed into LDFLAGS for all ports?
(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.
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.
(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
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 ???
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
Jan, if you do not plan to push this, let's close the PR?