Subject: please review "build-shared-libraries-with-gcc" patches
To: None <tech-toolchain@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-toolchain
Date: 06/18/2003 19:27:22
This is a multipart MIME message.
--==_Exmh_38885640105120
Content-Type: text/plain; charset=us-ascii
Hi -
Here are the patches which implement the changes discussed in
the "different behaviour of system cc and TOOLDIR/cc" thread last week.
I've tested this in a native and a cross build with the in-tree
gcc-2.95 so far.
Comments? More Testers?
(There is probably a bootstrap issue because libgcc is needed
earlier now in a standard system build , but this should be easy to fix.)
I'll be AFK until next week.
best regards
Matthias
--==_Exmh_38885640105120
Content-Type: text/plain ; name="gccmk.txt"; charset=us-ascii
Content-Description: gccmk.txt
Content-Disposition: attachment; filename="gccmk.txt"
Index: gnu/dist/toolchain/gcc/config/netbsd.h
===================================================================
RCS file: /cvsroot/src/gnu/dist/toolchain/gcc/config/netbsd.h,v
retrieving revision 1.18
diff -u -r1.18 netbsd.h
--- gnu/dist/toolchain/gcc/config/netbsd.h 2003/02/28 17:30:12 1.18
+++ gnu/dist/toolchain/gcc/config/netbsd.h 2003/06/18 17:15:52
@@ -68,7 +68,7 @@
#ifdef NETBSD_NATIVE
#define LIBGCC_SPEC "%{!symbolic:%{!shared:%{!p:%{!pg:-lgcc}}}%{shared:-lgcc_pic}%{p:-lgcc_p}%{pg:-lgcc_p}}"
#else
-#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}"
+#define LIBGCC_SPEC "%{!symbolic:%{!shared:-lgcc}%{shared:-lgcc_pic}}"
#endif
/* #ifdef NETBSD_AOUT */
Index: share/mk/bsd.gcc.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.gcc.mk,v
retrieving revision 1.1
diff -u -r1.1 bsd.gcc.mk
--- share/mk/bsd.gcc.mk 2003/05/31 20:33:15 1.1
+++ share/mk/bsd.gcc.mk 2003/06/18 17:15:52
@@ -8,12 +8,14 @@
_GCC_CRTBEGINS!= ${CC} --print-file-name=crtbeginS.o
_GCC_CRTEND!= ${CC} --print-file-name=crtend.o
_GCC_CRTENDS!= ${CC} --print-file-name=crtendS.o
+_GCC_CRTDIR!= dirname ${_GCC_CRTBEGIN}
_GCC_LIBGCCDIR!= dirname `${CC} --print-libgcc-file-name`
.else
_GCC_CRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o
_GCC_CRTBEGINS= ${DESTDIR}/usr/lib/crtbeginS.o
_GCC_CRTEND= ${DESTDIR}/usr/lib/crtend.o
_GCC_CRTENDS= ${DESTDIR}/usr/lib/crtendS.o
+_GCC_CRTDIR= ${DESTDIR}/usr/lib
_GCC_LIBGCCDIR= ${DESTDIR}/usr/lib
.endif
Index: share/mk/bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.220
diff -u -r1.220 bsd.lib.mk
--- share/mk/bsd.lib.mk 2003/06/11 04:56:58 1.220
+++ share/mk/bsd.lib.mk 2003/06/18 17:15:52
@@ -152,7 +152,7 @@
# Platform-independent linker flags for ELF shared libraries
.if ${OBJECT_FMT} == "ELF"
SHLIB_SOVERSION= ${SHLIB_MAJOR}
-SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
+SHLIB_SHFLAGS= -Wl,-soname,lib${LIB}.so.${SHLIB_SOVERSION}
SHLIB_LDSTARTFILE?= ${DESTDIR}/usr/lib/crti.o ${_GCC_CRTBEGINS}
SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${DESTDIR}/usr/lib/crtn.o
.endif
@@ -392,18 +392,15 @@
@echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
@rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
.if defined(DESTDIR)
- $(LD) -nostdlib -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
- ${SHLIB_LDSTARTFILE} \
- --whole-archive ${SOLIB} \
- --no-whole-archive ${LDADD} \
- -L${DESTDIR}${_LIBSODIR} -L${DESTDIR}${LIBDIR} \
- -R${_LIBSODIR} -R${LIBDIR} \
- ${SHLIB_LDENDFILE}
-.else
- $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
- ${SHLIB_LDSTARTFILE} \
- --whole-archive ${SOLIB} --no-whole-archive ${LDADD} \
- ${SHLIB_LDENDFILE}
+ $(CC) -v -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ \
+ -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
+ -Wl,--whole-archive ${SOLIB} \
+ -Wl,--no-whole-archive ${LDADD} \
+ -L${_GCC_LIBGCCDIR} -L${DESTDIR}${_LIBSODIR} -L${DESTDIR}${LIBDIR} \
+ -R${_LIBSODIR} -R${LIBDIR}
+.else
+ $(CC) -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
+ -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${LDADD}
.endif
.if ${OBJECT_FMT} == "ELF"
# We don't use INSTALL_SYMLINK here because this is just
Index: share/mk/bsd.prog.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
retrieving revision 1.169
diff -u -r1.169 bsd.prog.mk
--- share/mk/bsd.prog.mk 2003/06/13 04:04:18 1.169
+++ share/mk/bsd.prog.mk 2003/06/18 17:15:52
@@ -117,7 +117,7 @@
.endif
.if ${SHLIBDIR} != ${LIBDIR}
_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \
- -Wl,-rpath,${SHLIBDIR}:/usr/lib \
+ -R${SHLIBDIR} -R/usr/lib \
-L${DESTDIR}${SHLIBDIR}
.elif ${SHLIBINSTALLDIR} != ${LIBDIR}
_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \
--==_Exmh_38885640105120--