Date: Sat, 15 Dec 2012 00:54:19 +0100 From: Baptiste Daroussin <bapt@FreeBSD.org> To: hackers@FreeBSD.org Subject: Fix overlinking in base aka import pkgconf Message-ID: <20121214235418.GF18884@ithaqua.etoilebsd.net>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Hi, Some of our binary are overlinked, the way we handle the linking doesn't help for that. On proposition could be to use pkgconf https://github.com/pkgconf/pkgconf which is BSD license pkg-config implementation 100% compatible with pkg-config. What I propose is to create a new PCADD variable for the Makefiles. PCADD will invoke pkgconf to gather the libraries and the cflags for a given project. The second thing would be to create .pc files for all of our libraries. for example: usr.bin/fstat dynamic build is overlinked With the following simple patch we can solve the problem: Index: Makefile =================================================================== --- Makefile (revision 243899) +++ Makefile (working copy) @@ -5,7 +5,7 @@ SRCS= fstat.c fuser.c main.c LINKS= ${BINDIR}/fstat ${BINDIR}/fuser DPADD= ${LIBKVM} ${LIBUTIL} ${LIBPROCSTAT} -LDADD= -lkvm -lutil -lprocstat +PCADD= procstat MAN1= fuser.1 fstat.1 This requires the following .pc files quick and dirty ones: - util.pc: prefix=/usr libdir=${prefix}/lib includedir=${prefix}/include Name: util Libs: -L${libdir} -lutil Cflags: -I${includedir} - kvm.pc: prefix=/usr libdir=${prefix}/lib includedir=${prefix}/include Name: kvm Libs: -L${libdir} -lkvm Cflags: -I${includedir} - procstat.pc: prefix=/usr libdir=${prefix}/lib includedir=${prefix}/include Name: procstat Requires.private: kvm util Libs: -L${libdir} -lprocstat Cflags: -I${includedir} The quick and dirty patch for our framework is: Index: bsd.prog.mk =================================================================== --- bsd.prog.mk (revision 243899) +++ bsd.prog.mk (working copy) @@ -36,6 +36,18 @@ LDFLAGS+= -static .endif +.if defined(PCADD) +PCFLAGS!= ${PKGCONF} --cflags ${PCADD} +.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") +PCLIBS!= ${PKGCONF} --libs --static ${PCADD} +.else +PCLIBS!= ${PKGCONF} --libs ${PCADD} +.endif +CFLAGS+= ${PCFLAGS} +CXXFLAGS+= ${PCFLAGS} +LDADD+= ${PCLIBS} +.endif + .if defined(PROG_CXX) PROG= ${PROG_CXX} .endif Index: sys.mk =================================================================== --- sys.mk (revision 243899) +++ sys.mk (working copy) @@ -137,6 +137,8 @@ PC ?= pc PFLAGS ?= +PKGCONF ?= pkgconf + RC ?= f77 RFLAGS ?= Of course a lot of work is needed to get something really well integrated but I wanted feedback first before working on anything like this :) regards, Bapt [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlDLvCoACgkQ8kTtMUmk6EzbPACbB6cR+36w0Gv8sFW93J7EJTbi k5QAnRpPMLDTjadalIT32dhOTjvjl7PX =nloN -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121214235418.GF18884>
