Bug 270740 - devel/cargo-c: Generated pkg-config files have broken Libs.private definitions
Summary: devel/cargo-c: Generated pkg-config files have broken Libs.private definitions
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: Jan Beich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-10 14:47 UTC by Daniel Engberg
Modified: 2023-04-10 15:31 UTC (History)
0 users

See Also:
jbeich: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2023-04-10 14:47:50 UTC
A lot of non related libraries gets defined...

audio/lewton:
Libs.private:  -lexecinfo -lpthread -lgcc_s -lc -lm -lrt -lpthread -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat

graphics/libimagequant:
Libs.private:  -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat -lexecinfo -lpthread -lgcc_s -lc -lm -lrt -lpthread -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat

etc
Comment 1 Daniel Engberg freebsd_committer freebsd_triage 2023-04-10 15:03:59 UTC
Looking this seems to "leak" from libc crate?
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-04-10 15:14:21 UTC
Only -lgcc_s (see upstream issue) breaks static linking.

$ cc a.c -static $(pkg-config -static --cflags --libs imagequant | sed 's/gcc_s/gcc/')
$ file ./a.out
./a.out: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), statically linked, for FreeBSD 14.0 (1400085), FreeBSD-style, with debug_info, not stripped

$ cat a.c
#include <libimagequant.h>

int main()
{
  (void)liq_attr_create();
  return 0;
}
Comment 3 Jan Beich freebsd_committer freebsd_triage 2023-04-10 15:29:46 UTC
Overlinking isn't a problem with static libraries as ld(1) only includes object files (*.o) from archives (*.a) that satisfy references. However, object files can be large, so one may want to pass -Wl,--gc-section to trim unused stuff.
Comment 4 Jan Beich freebsd_committer freebsd_triage 2023-04-10 15:31:42 UTC
Note, to overlink a static library pass -Wl,--whole-archive