Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jun 2011 23:47:23 +0200
From:      Jeremie Le Hen <jeremie@le-hen.org>
To:        Kostik Belousov <kib@FreeBSD.org>
Cc:        kan@freebsd.org, freebsd-hackers@freebsd.org, Jeremie Le Hen <jeremie@le-hen.org>
Subject:   Re: compiling ports with SSP (was: [PATCH] Add -lssp_nonshared to GCC's LIB_SPEC unconditionally)=
Message-ID:  <20110601214723.GD53247@felucia.tataz.chchile.org>
In-Reply-To: <20101106194702.GN2392@deviant.kiev.zoral.com.ua>
References:  <20100919081406.GH6864@felucia.tataz.chchile.org> <20100919184146.GE2389@deviant.kiev.zoral.com.ua> <20100920162925.GL6864@felucia.tataz.chchile.org> <20100920192708.GK2389@deviant.kiev.zoral.com.ua> <20100927094651.GB57265@felucia.tataz.chchile.org> <20100927154457.GJ43070@deviant.kiev.zoral.com.ua> <20101005181804.GJ7536@felucia.tataz.chchile.org> <20101105213905.GT30284@felucia.tataz.chchile.org> <20101105190023.29e5d39d@kan.dnsalias.net> <20101106194702.GN2392@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi Kostik,

Thanks to b.f., I've been reminded that this patch has yet to be
committed :).

As a reminder, here are the archive pointers to the discussion:
http://lists.freebsd.org/pipermail/freebsd-hackers/2010-August/032549.html
continued...
http://lists.freebsd.org/pipermail/freebsd-hackers/2010-September/033028.html
continued...
http://lists.freebsd.org/pipermail/freebsd-hackers/2010-November/033478.html

On Sat, Nov 06, 2010 at 09:47:02PM +0200, Kostik Belousov wrote:
> On Fri, Nov 05, 2010 at 07:00:23PM -0400, Alexander Kabaev wrote:
> > On Fri, 5 Nov 2010 22:39:06 +0100
> > Jeremie Le Hen <jeremie@le-hen.org> wrote:
> > 
> > > Hi Kib,
> > > 
> > > On Tue, Oct 05, 2010 at 08:18:04PM +0200, Jeremie Le Hen wrote:
> > > > 
> > > > On Mon, Sep 27, 2010 at 06:44:57PM +0300, Kostik Belousov wrote:
> > > > > Hardcoding /usr/lib as the path to the library in the script looks
> > > > > problematic.  For the buidlworld, you are linking resulting
> > > > > binaries with the host library, instead of the
> > > > > buildworld-produced one. For lib32, it makes non-working
> > > > > combination of 32/64 bit.
> > > > 
> > > > Sorry for the late reply, but I had to collect various evidences
> > > > for my sayings and my development machine is reaaaaaaaaaaally slow.
> > > > 
> > > > In fact it seems the toolchain built for buildworld contains a ld(1)
> > > > binary which invariably bases lookups for libraries in ${WORLDTMP},
> > > > even in case of an absolute path.  I have two evidences of this:
> > > > - Putting /usr/obj/usr/src/tmp/usr/lib/libssp_nonshared.a in
> > > >   /usr/obj/usr/src/tmp/usr/lib/libc.ld leads toolchain's ld(1) to
> > > > use /usr/obj/usr/src/tmp/usr/obj/usr/src/tmp/usr/lib/libssp_nonshared.a;
> > > > - I also verified this with a hand-wrought opensnoop-like DTrace
> > > > script.
> > > 
> > > I dare to remind you about my patch.  Do you have any other concerns?
> > > 
> > > Thanks.
> > > Regards,
> > > -- 
> > > Jeremie Le Hen
> > > 
> > > Humans are born free and equal.  But some are more equal than others.
> > > 					    Coluche
> > 
> > Hmm, I thought I did approve this patch already a long time agi, but
> > since you asked:
> > 
> > +.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
> > 
> > this should be:
> > 
> > +.if defined(SHLIB_LDSCRIPT)
> > 
> > ditto for all other similar places. Otherwise I do not think we should
> > hold the patch in queue ans should unleash it on unsuspecting public.
> 
> Also, I think the "DEBUG" lines should be removed.

Sure, I'll do it in my next update.

> You install the libxxx.ld and then symlink libxxx.so to libxxx.ld.
> Why ? Would it be enough to install just the libxxx.so ?

I just thought it would be less puzzling for users than noticing that
libc.so is only a few hundred of ascii.  I don't have a strong opinion
about this though.

> Otherwise, I think you need the similar
> .if ${SHLIBDIR} == ${LIBDIR}
> magic, that is better to be avoided.

Can you explain a little bit more about this one please?  I'm willing to
post an updated patch for further review. 

Regards,
-- 
Jeremie Le Hen

Humans are born free and equal.  But some are more equal than others.
					    Coluche

--x+6KMIRAuhnl3hBn
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="ld_ssp_nonshared.diff"

diff -urNp src.orig/lib/libc/Makefile src/lib/libc/Makefile
--- src.orig/lib/libc/Makefile	2010-08-01 12:35:01.000000000 +0000
+++ src/lib/libc/Makefile	2010-09-21 23:40:51.000000000 +0000
@@ -20,6 +20,7 @@ CFLAGS+=-DNLS
 CLEANFILES+=tags
 INSTALL_PIC_ARCHIVE=
 PRECIOUSLIB=
+SHLIB_LDSCRIPT=libc.ldscript
 
 #
 # Only link with static libgcc.a (no libgcc_eh.a).
diff -urNp src.orig/lib/libc/libc.ldscript src/lib/libc/libc.ldscript
--- src.orig/lib/libc/libc.ldscript	1970-01-01 00:00:00.000000000 +0000
+++ src/lib/libc/libc.ldscript	2010-09-24 21:56:57.000000000 +0000
@@ -0,0 +1,2 @@
+/* $FreeBSD */
+GROUP ( @@SHLIB@@ /usr/lib/libssp_nonshared.a )
diff -urNp src.orig/share/mk/bsd.lib.mk src/share/mk/bsd.lib.mk
--- src.orig/share/mk/bsd.lib.mk	2010-07-30 15:25:57.000000000 +0000
+++ src/share/mk/bsd.lib.mk	2010-09-24 22:01:04.000000000 +0000
@@ -293,9 +293,19 @@ _libinstall:
 	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
 	    ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
 .if defined(SHLIB_LINK)
+.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+	@echo "DEBUG: install lib${LIB}.ld to ${DESTDIR}${LIBDIR}/${SHLIB_LINK}"
+	sed -e 's,@@SHLIB@@,${SHLIBDIR}/${SHLIB_NAME},g' \
+	    ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
+	${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	    ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}
+	ln -sf lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+.else
 .if ${SHLIBDIR} == ${LIBDIR}
+	@echo "DEBUG: symlink (1) ${DESTDIR}${LIBDIR}/${SHLIB_LINK} to ${SHLIB_NAME}"
 	ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
 .else
+	@echo "DEBUG: symlink (2) ${DESTDIR}${LIBDIR}/${SHLIB_LINK} to ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME}"
 	ln -fs ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \
 	    ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
 .if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME})
@@ -303,8 +313,9 @@ _libinstall:
 	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}
@@ -372,6 +383,9 @@ clean:
 .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)

--x+6KMIRAuhnl3hBn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110601214723.GD53247>