Date: Tue, 1 May 2012 15:14:01 +0200 From: Jeremie Le Hen <jlh@FreeBSD.org> To: hackers@FreeBSD.org Subject: Optionally have ld(1) script instead of symlink for .so Message-ID: <20120501131401.GA86527@felucia.tataz.chchile.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
I plan to commit the attached patch. It brings a new variable for
library Makefiles (SHLIB_LDSCRIPT). When defined, it contains the name
of a template file used to generate the ld(1) script.
Two variables may appear in the template file:
- @@SHLIB@@ will be substituted by the real shared library full path
(${SHLIBDIR}/${SHLIB_NAME});
- @@LIBDIR@@ will be substituted with ${LIBDIR}.
This is wrapped with some cursed magic to allow building 32bits
libraries on 64bits platforms and cross-building.
This is the first step toward being able to build ports with SSP
painlessly.
Any comment or concern?
--
Jeremie Le Hen
Men are born free and equal. Later on, they're on their own.
Jean Yanne
[-- Attachment #2 --]
diff -r 897395797d88 -r bc47fd6cab07 Makefile.inc1
--- a/Makefile.inc1 Sun Apr 29 00:02:52 2012 +0200
+++ b/Makefile.inc1 Sun Apr 29 00:09:30 2012 +0200
@@ -265,6 +265,7 @@
# world stage
WMAKEENV= ${CROSSENV} \
_SHLIBDIRPREFIX=${WORLDTMP} \
+ _LDSCRIPTROOT= \
VERSION="${VERSION}" \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH}
@@ -307,6 +308,7 @@
# Yes, the flags are redundant.
LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
_SHLIBDIRPREFIX=${LIB32TMP} \
+ _LDSCRIPTROOT=${LIB32TMP} \
VERSION="${VERSION}" \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH} \
@@ -319,11 +321,11 @@
-DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \
-DWITHOUT_HTML -DNO_CTF -DNO_LINT -ECC -ECXX -EAS -ELD \
DESTDIR=${LIB32TMP}
-LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS
+LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS
.endif
# install stage
-IMAKEENV= ${CROSSENV}
+IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1
.if empty(.MAKEFLAGS:M-n)
IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
diff -r 897395797d88 -r bc47fd6cab07 share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk Sun Apr 29 00:02:52 2012 +0200
+++ b/share/mk/bsd.lib.mk Sun Apr 29 00:09:30 2012 +0200
@@ -271,6 +271,15 @@
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
.if defined(SHLIB_LINK)
+# _LDSCRIPTROOT and _SHLIBDIRPREFIX serve almost the same purpose but the
+# former needs to be empty during installworld while the later does not.
+.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+ sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \
+ -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \
+ ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
+ ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+.else
.if ${SHLIBDIR} == ${LIBDIR}
ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
.else
@@ -281,8 +290,9 @@
rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
.endif
.endif
-.endif
-.endif
+.endif # SHLIB_LDSCRIPT
+.endif # SHLIB_LINK
+.endif # SHIB_NAME
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
@@ -350,6 +360,9 @@
.endif
.if defined(SHLIB_NAME)
.if defined(SHLIB_LINK)
+.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+ rm -f lib${LIB}.ld
+.endif
rm -f ${SHLIB_LINK}
.endif
.if defined(LIB) && !empty(LIB)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120501131401.GA86527>
