Bug 2225287

Summary: lvm: link against lvm2cmds library to save space
Product: [Community] LVM and device-mapper Reporter: Gwendal Grignou <gwendal>
Component: lvm2Assignee: LVM Team <lvm-team>
lvm2 sub component: Default / Unclassified QA Contact: cluster-qe <cluster-qe>
Status: NEW --- Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, thornber, zkabelac
Version: unspecifiedFlags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gwendal Grignou 2023-07-24 21:32:59 UTC
Description of problem:
Looking at the size of the package, in the dynamic version, lvm and lvm2cmd are about the same size:
```
ls -l /build/brya/sbin/lvm /build/brya/lib64/liblvm2cmd.so.2.03
-r-xr-xr-x 1 root root 2084640 Jul 24 13:27 /build/brya/lib64/liblvm2cmd.so.2.03
-r-xr-xr-x 1 root root 2217600 Jul 24 13:27 /build/brya/sbin/lvm
```

Looking at their Makefile.in, they both link against $OBJECTS directly (https://gitlab.com/lvmteam/lvm2/-/blob/main/tools/Makefile.in#L123), so there are a lot of code duplication:

```
lvm: $(OBJECTS) lvm.o $(LVMINTERNAL_LIBS)
...
liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
...
```

It is confirmed by lddtree, where lvm does not depend on liblvm2cmd.a
Could it be possible to link dynamic lvm against liblvm2cmd, thus saving ~2MB of space?


Version-Release number of selected component (if applicable): ToT.

How reproducible:
Always.

Steps to Reproduce:
1. Compile lvm2 (used gentoo sys-fs/lvm2)

Actual results:
lvm and lvm2cmd are ~2MB

Expected results:
lvm should be smaller if linked against lvm2cmd.

Additional info: