Subject: Re: New shared-lib snapshot available: NEED b on ftp.netbsd.org Sunday (PST)
To: None <jonathan@DSG.Stanford.EDU, port-pmax@NetBSD.ORG>
From: Sean Davidson <davidson@zk3.dec.com>
List: port-pmax
Date: 03/04/1997 11:17:43
>I've just put a new pmax shared-library snapshot of NetBSD-current on
>ftp.netbsd.org.  This snapshot differs from the previous snapshot in
>the following:
>
>   * All of libc.a is built as PIC files.   You should now be able
>     to link static or dynamically-linked executables without
>     getting error messags.
>
>   * The version of ld in the previous snapshot has been upgraded.
>     The binutils-2.7 ld is badly broken when it comes to building
>     static ELF binaries.   (nm and size dont' work on them).
>
>   * The static binaries are, unfortunately, up to 25% bigger.
>     /sbin, /bin, and a couple of kernels no longer fit on a 16Mbyte
>     root filesystem -- not even with a 4k/512 filesystem.
>
>   * Everything has been relinked with the latest shared-libs:
>     libc.so.12.11, instead of libc.so.12.7.
>
>Anyone with a 16Mbyte root filesystem -- still the default in the
>/etc/disktab entries -- is going to have to either work hard to tailor
>the contents of /sbin and /bin, or resize their root fileystem.  
>
>I recommend resizing the root filesystem; the binaries in /bin and
>/sbin may get slightly smaller, but there are just more things in the
>root partition than there used to be, the contents of libc is growing
>(e.g., due to YP) and the size of the static binaries in /sbin and
>/bin just keeps growing.
>
>If at all possible, i'd recommend resizing your NetBSD/pmax root
>filesystem to 32 Mbytes.  I realize this isn't going to be easy for
>insatllations with a single disk; it may require re-installation "from
>scratch".  It's very likely you can simply shrink an existing swap
>partition by 16 Mbytes or more; the dynamically-linked binaries in
>/usr/{bin,sbin,libexec} should reduce swap usage dramatically.
>

>I've been using a shared-lib environment myself since November.  I
>believe the shared-lib support in this snapshot should be quite stable.
>
>
>To Tom Yu (and others): Please note that I *still* haven't finished
>cleaning up the /usr/src/share/mk/bsd.lib.mk files to build shared
>libs properly. The portmaster of the NetBSD/alpha (Chris Demetriou)
>and I are still discussing the ``right'' way to support, and build,
>ELF shared-libs on all NetBSD ELF platforms.  I'd be grateful to
>anyone willing to help test this -- and to test a shared-lib X11R6.1.
>
>--Jonathan


For DIGITAL UNIX we ran into this same problem of the root file system getting
to big with more stuff being added and making it impossible for anyone to
upgrade an existing system.  We decided to move libc.so and a few other key
shared libraries into the root file system and create symlinks from the usr
file system to keep old programs happy.  We picked a few critical programs
to keep static and freed up a significant amount of space.

The static list is as follows:

	init, cp, fsck, halt, loader (ld.so for NetBSD/pmax), ls, mount,
	mount_*, mv, reboot, sh, fsck, fsck_*, umount

The shared libraries I have put in root are as follows:

	ld.so, libc.so.12.11, libcrypt.so.0.0, libedit.so.0.0, libkvm.so.4.0
	libm.so.0.1, libtermcap.so.0.0, libutil.so.3.3

and created symlinks to them in /usr/lib and /usr/libexec for ld.so.

I've done basically the same thing with NetBSD/pmax except if didn't take
the time to modify the above list of makefiles to link them statically and
now with my 32mb root file system I have 14mb free with a couple of extra
kernels hanging around and /var inside of root also.

Before I started this I had my root filesystem up to 32mb and the static
binaries still didn't fit.  I've been running with the share libraries,
rebuilt with my changes to bsd.lib.mk, makefiles and one change to a header
file for well over a month.

I have also rebuilt the entire X11R6.3 kit, minus X server (still the old
X11R5 stuff here) and have been using that too without any problems.  Even
the fvwm95 window manager works fine with these built shared libraries.

I have built everything from scratch with current as of Feb 24, 1997 and
the entire X11R6.3 source as of Feb 20, 1997.

I haven't modified the makefiles to install the shared libraries into root
and symlinking them back into usr yes because of the possible arguments
against dynamically linked binaries in root.  Copying them out of /usr/lib
and into /libexec and setting the symlinks must be done manually.

The only things missing form me in NetBSD/pmax is the dlopen, dlcose, dlsym
routines for program control of loading shared libraries, R4000 support so
I can put my R4000 cpu in my DECstation 5000/125, and and X11R6 X server.

I'm including my changes if anyone is interested.


Sean Davidson



./lib/csu/mips/Makefile
5c5
< OBJS=		crt0.o gcrt0.o
---
> OBJS=		crt0.o gcrt0.o crtn.o
10,11c10,11
< crt0.o: crt0.S
< 	${COMPILE.S} -DCRT0 ${.ALLSRC}
---
> crt0.o: crt0.c
> 	${COMPILE.S} -DCRT0 -DDYNAMIC ${.ALLSRC}
15,16c15,21
< gcrt0.o: crt0.S
< 	${COMPILE.S} -DMCRT0 ${.ALLSRC} -o ${.TARGET}
---
> gcrt0.o: crt0.c
> 	${COMPILE.S} -DMCRT0 -DDYNAMIC ${.ALLSRC} -o ${.TARGET}
> 	${LD} -x -r ${.TARGET}
> 	mv a.out ${.TARGET}
> 
> crtn.o: crt0.c
> 	${COMPILE.S} -DCRTN -DDYNAMIC ${.ALLSRC} -o ${.TARGET}
./lib/csu/mips/crt0.c
0a1,62
> #include <sys/param.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> 
> #ifndef CRTN
> extern void   start __P((long)) asm("start");
> extern void     _mcleanup __P((void));
> extern unsigned char    eprol asm ("eprol");
> extern unsigned char    etext;
> 
> char                    **environ;
> static char           empty[1];
> char                  *__progname = empty;
> 
> 
> void
> __start()
> {
> 	struct kframe {
> 		int	kargc;
> 		char	*kargv[1];	/* size depends on kargc */
> 		char	kargstr[1];	/* size varies */
> 		char	kenvstr[1];	/* size varies */
> 	};
> 
> 	register struct kframe *kfp;
> 	register char **argv, *ap;
> 
> #ifndef DYNAMIC
> 	asm("	la	$28,_gp");
> 	asm("	addiu	%0,$29,32" : "=r" (kfp));
> #else
> 	asm("	addiu	%0,$29,48" : "=r" (kfp));
> #endif
> 	/* just above the saved frame pointer
> 	kfp = (struct kframe *) (&param-1);*/
> 	argv = &kfp->kargv[0];
> 	environ = argv + kfp->kargc + 1;
> 
> 	if (ap = argv[0])
> 		if ((__progname = strrchr(ap, '/')) == NULL)
> 			__progname = ap;
> 		else
> 			++__progname;
> 
> asm("eprol:");
> 
> #ifdef MCRT0
> 	atexit(_mcleanup);
> 	monstartup((u_long)&eprol, (u_long)&etext);
> #endif MCRT0
> 
> asm ("_callmain:");           /* Defined for the benefit of debuggers */
> 	exit(main(kfp->kargc, argv, environ));
> }
> 
> #ifdef MCRT0
> asm ("        .text");
> asm ("_eprol:");
> #endif
> #endif
./sbin/Makefile.inc
5c5
< LDSTATIC=	-static
---
> LDSTATIC=	-Wl,-dynamic-linker,/libexec/ld.so -Wl,-rpath,/libexec
./usr.sbin/pppd/grammar.y
130c130
< 	| pnum			{ $$.b = gen_ncode(NULL, (unsigned long)$1,
---
> 	| pnum			{ $$.b = gen_ncode((unsigned long)$1,
135c135
< 	| HID			{ $$.b = gen_ncode(NULL, __pcap_atoin((char *)$1),
---
> 	| HID			{ $$.b = gen_ncode(__pcap_atoin((char *)$1),
147c147
< qid:	  pnum			{ $$.b = gen_ncode(NULL, (unsigned long)$1,
---
> qid:	  pnum			{ $$.b = gen_ncode((unsigned long)$1,
./sys/arch/pmax/conf/Makefile.pmax
43c43
< CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
---
> CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -mno-abicalls
50c50
< HOSTED_CFLAGS=	${CFLAGS}
---
> HOSTED_CFLAGS=	${CFLAGS} -mabicalls
186d185
< 
./sys/arch/pmax/stand/libsa/getenv.c
42a43,44
> #undef getenv
> 
./sys/arch/pmax/stand/libsa/gets.c
42a43,44
> #undef gets
> 
./sys/arch/pmax/stand/libsa/strcat.c
42a43,44
> #undef strcat
> 
./sys/arch/pmax/stand/libsa/strcpy.c
42a43,44
> #undef strcpy
> 
./sys/arch/mips/include/asm.h
62a63,66
> #ifdef PIC
> #define ABICALLS
> #endif
> 
./usr.bin/kdump/Makefile
4c4
< LDSTATIC=-static
---
> #LDSTATIC=-static
./usr.bin/ldd/Makefile
20c20
< LDFLAGS+= -static
---
> #LDFLAGS+= -static
./bin/Makefile.inc
5c5
< LDSTATIC=	-static
---
> LDSTATIC=	-Wl,-dynamic-linker,/libexec/ld.so -Wl,-rpath,/libexec
./domestic/bin/ed/Makefile
10c10
< LDSTATIC=       -static
---
> LDSTATIC=       -Wl,-dynamic-linker,/libexec/ld.so -Wl,-rpath,/libexec
20,21c20,21
< LDADD+= ${CRYPTLIBDIR}/libcrypt.a
< DPADD+= ${CRYPTLIBDIR}/libcrypt.a
---
> LDADD+= -lcrypt
> DPADD+= -lcrypt
./gnu/usr.bin/tar/Makefile
15c15
< LDSTATIC= -static
---
> #LDSTATIC= -static
./gnu/usr.bin/gzip/Makefile
14c14
< LDSTATIC= -static
---
> #LDSTATIC= -static
./share/mk/bsd.lib.mk
21a22,26
> .if (${MACHINE_ARCH} == "mips")
> COPTS+=		-fPIC -DPIC
> PICFLAG=	-fPIC -DPIC
> .endif
>