Subject: Changes to bsd.lib.mk for some architectures
To: None <tech-toolchain@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-toolchain
Date: 11/12/1999 17:37:14
A while back I mentioned about using the same .o files for pic and
non-pic libraries. Well, I've generalised it a little and come up
with the trailing patches. Basically, if MKPICLIB is set to "no" in
bsd.own.mk, then no _pic.a libraries will get built and the shared
libraries are generated from the .a libraries.
I've done a "make build" with this on a pmax and have no problems so
far. It also seems from a limited look that the alpha can also use
this, but that ELF i386 and sparc can't. I'll do a full test on alpha
over the weekend.
The only thing I'm not completely happy with is the set generation. At
the moment, makeflist also searchs for a shl.{pic,nopic} and all the
_pic.a libraries are moved to a shl.pic.
All of this has some practical benefits - src/lib and gnu/src/lib
build quicker (roughly 33% - there's only two compiles per source file
instead of three) and there's an overall reduction in disk space used.
Surprisingly (until you think about it) there's not much space saved
in the compressed sets - obviously if all the data was the same in two
libraries then the second should compress very well :)
Do anyone have a problem with this, suggestions on how to handle set
generation any better or any general comments?
Simon.
--
Index: distrib/sets/makeflist
===================================================================
RCS file: /cvsroot/basesrc/distrib/sets/makeflist,v
retrieving revision 1.18
diff -p -u -r1.18 makeflist
--- makeflist 1999/07/04 20:07:51 1.18
+++ makeflist 1999/11/12 06:25:50
@@ -69,6 +69,12 @@ if [ "$arch" = "mips" -o "$machine" = "a
else
shlib=aout
fi
+# Add any lib*_pic.a libraries
+if [ "$arch" = "mips" ]; then
+ shlibpic=nopic
+else
+ shlibpic=pic
+fi
for setname in $lists; do
cat $setd/lists/$setname/mi
@@ -81,6 +87,9 @@ for setname in $lists; do
if [ "$shlib" != "" ]; then
if [ -f $setd/lists/$setname/shl.mi ]; then
cat $setd/lists/$setname/shl.mi
+ fi
+ if [ -f $setd/lists/$setname/shl.pic ]; then
+ cat $setd/lists/$setname/shl.pic
fi
if [ -f $setd/lists/$setname/shl.${shlib} ]; then
cat $setd/lists/$setname/shl.${shlib}
Index: libexec/ld.aout_so/Makefile
===================================================================
RCS file: /cvsroot/basesrc/libexec/ld.aout_so/Makefile,v
retrieving revision 1.28
diff -p -u -r1.28 Makefile
--- Makefile 1999/03/19 22:06:37 1.28
+++ Makefile 1999/11/12 06:25:50
@@ -18,8 +18,13 @@ LDFLAGS+=-Bshareable -Bsymbolic -assert
.if defined(DESTDIR)
LDFLAGS+= -nostdlib -L${DESTDIR}/usr/lib
.endif
+.if ${MKPICLIB} == "no"
+LDADD+= -lc
+DPADD+= ${LIBC}
+.else
LDADD+= -lc_pic
DPADD+= ${LIBC_PIC}
+.endif
.PATH: ${CLIB}/stdio $(.CURDIR)/arch/$(MACHINE_ARCH)
Index: libexec/ld.elf_so/Makefile
===================================================================
RCS file: /cvsroot/basesrc/libexec/ld.elf_so/Makefile,v
retrieving revision 1.30
diff -p -u -r1.30 Makefile
--- Makefile 1999/07/05 17:55:34 1.30
+++ Makefile 1999/11/12 06:25:50
@@ -33,8 +33,14 @@ CPPFLAGS+= -DDEBUG -DRTLD_LOADER
CPPFLAGS+= -D_RTLD_SOURCE
#CPPFLAGS+= -DRTLD_DEBUG -DRTLD_DEBUG_RELOC
-LDADD+= -L${DESTDIR}/${LIBDIR} -L${CLIBOBJ} -non_shared -lc_pic
+LDADD+= -L${DESTDIR}/${LIBDIR} -L${CLIBOBJ} -non_shared
+.if ${MKPICLIB} == "no"
+LDADD+= -lc
+DPADD+= ${LIBC}
+.else
+LDADD+= -lc_pic
DPADD+= ${LIBC_PIC}
+.endif
STRIPFLAG=
Index: share/mk/bsd.hostprog.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.hostprog.mk,v
retrieving revision 1.3
diff -p -u -r1.3 bsd.hostprog.mk
--- bsd.hostprog.mk 1999/09/24 17:48:57 1.3
+++ bsd.hostprog.mk 1999/11/12 06:25:50
@@ -19,7 +19,9 @@ CFLAGS+= ${COPTS}
LIBBZ2?= /usr/lib/libbz2.a
LIBC?= /usr/lib/libc.a
+.if ${MKPICLIB} != "no"
LIBC_PIC?= /usr/lib/libc_pic.a
+.endif
LIBCOMPAT?= /usr/lib/libcompat.a
LIBCRYPT?= /usr/lib/libcrypt.a
LIBCURSES?= /usr/lib/libcurses.a
Index: share/mk/bsd.lib.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.lib.mk,v
retrieving revision 1.159
diff -p -u -r1.159 bsd.lib.mk
--- bsd.lib.mk 1999/09/14 01:31:11 1.159
+++ bsd.lib.mk 1999/11/12 06:25:50
@@ -72,12 +72,10 @@ APICFLAGS ?=
# On mips, all libs need to be compiled with ABIcalls, not just sharedlibs.
CPICFLAGS?=
APICFLAGS?=
-#CPICFLAGS?= -fpic -DPIC
-#APICFLAGS?= -DPIC
# so turn shlib PIC flags on for ${CPP}, ${CC}, and ${AS} as follows:
-AINC+=-DPIC -DABICALLS
-COPTS+= -fPIC ${AINC}
+AINC+=-DABICALLS
+COPTS+= ${AINC}
AFLAGS+= -fPIC
AS+= -KPIC
@@ -238,8 +236,13 @@ POBJS+=${OBJS:.o=.po}
.endif
.if ${MKPIC} != "no"
-_LIBS+=lib${LIB}_pic.a
+.if ${MKPICLIB} == "no"
+SOLIB=lib${LIB}.a
+.else
+SOLIB=lib${LIB}_pic.a
+_LIBS+=${SOLIB}
SOBJS+=${OBJS:.o=.so}
+.endif
.if defined(SHLIB_MAJOR) && defined(SHLIB_MINOR)
_LIBS+=lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
.endif
@@ -281,21 +284,21 @@ lib${LIB}_p.a:: ${POBJS} __archivebuild
lib${LIB}_pic.a:: ${SOBJS} __archivebuild
@echo building shared object ${LIB} library
-lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: lib${LIB}_pic.a ${DPADD} \
+lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: ${SOLIB} ${DPADD} \
${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
@echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
@rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
.if defined(DESTDIR)
$(LD) -nostdlib -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
${SHLIB_LDSTARTFILE} \
- --whole-archive lib${LIB}_pic.a \
+ --whole-archive ${SOLIB} \
-L${DESTDIR}${LIBDIR} -R${LIBDIR} \
--no-whole-archive ${LDADD} \
${SHLIB_LDENDFILE}
.else
$(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
${SHLIB_LDSTARTFILE} \
- --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
+ --whole-archive ${SOLIB} --no-whole-archive ${LDADD} \
${SHLIB_LDENDFILE}
.endif
.if ${OBJECT_FMT} == "ELF"
Index: share/mk/bsd.own.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.own.mk,v
retrieving revision 1.129
diff -p -u -r1.129 bsd.own.mk
--- bsd.own.mk 1999/10/06 18:24:00 1.129
+++ bsd.own.mk 1999/11/12 06:25:50
@@ -94,6 +94,11 @@ NOPIC=1
NOLINT=1
.endif
+# On mips, pic and non-pic code is the same
+.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
+MKPICLIB=no
+.endif
+
# Data-driven table using make variables to control how
# toolchain-dependent targets and shared libraries are built
# for different platforms and object formats.
@@ -186,6 +191,9 @@ MKLINKLIB=no
.else
MKLINKLIB?=yes
.endif
+.if ${MKPICLIB} == "no"
+MKPICINSTALL=no
+.endif
.if ${MKLINKLIB} == "no"
MKPICINSTALL=no
MKPROFILE=no
@@ -222,6 +230,7 @@ MKOBJ?=yes
MKPIC=no
.else
MKPIC?=yes
+MKPICLIB?= yes
.endif
.if defined(NOPICINSTALL)
Index: share/mk/bsd.prog.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.prog.mk,v
retrieving revision 1.104
diff -p -u -r1.104 bsd.prog.mk
--- bsd.prog.mk 1999/09/14 01:31:11 1.104
+++ bsd.prog.mk 1999/11/12 06:25:50
@@ -31,7 +31,9 @@ LIBCRT0?= ${DESTDIR}/usr/lib/crt0.o
LIBBZ2?= ${DESTDIR}/usr/lib/libbz2.a
LIBC?= ${DESTDIR}/usr/lib/libc.a
+.if ${MKPICLIB} != "no"
LIBC_PIC?= ${DESTDIR}/usr/lib/libc_pic.a
+.endif
LIBCOMPAT?= ${DESTDIR}/usr/lib/libcompat.a
LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a
LIBCURSES?= ${DESTDIR}/usr/lib/libcurses.a