SUMMARY: Building Bash statically on Solaris9? (fwd)

From: Hugh Sasse <hgs_at_dmu.ac.uk>
Date: Wed Nov 18 2009 - 08:33:53 EST
I had seven people reply to this enquiry.

I was pointed to FAQ 6.24 which talks about static linking under Solaris.
The upshot of this is that static linking becomes impossible in Solar10
(though I was on Solaris9), and this is for a number of reasons, detailed
there.  I'd managed to miss this.

Most people asked why I wanted to use bash rather than sh.  It is to
ease interactions because when in this single user or maintenance
mode the kind of work being done is such that errors need to be
minimised.  Having the support of history and completion reduces the
cognitive load, especially if the shell is consistent with that used
for normal (multiuser, non-root) interaction. This question was
sometimes framed as why I want to replace the default shell: I don't
necessarily, I want to have bash available: changing the default
shell could upset some scripts.

A number of people asked what the problem with dynamic linking  is
because /usr and / have been on the same partition for years now.
The system is old, and whilst I could probably reformat the disk to
make this case, given the available free space, I'm reluctant to
dismantle a working system for this purpose.

It was also pointed out that lbdl.so is in /etc/lib anyway

It was also suggested that in my bash build I should do --disable-shared
as well as --enable-static.  I've not tried this yet.

It has been suggested that I:

share -o rw=localhost /
mount localhost:/ /mnt

so that I can copy the files I need from /usr into /, so the mount goes
over the top when it occurs, but in single user mode I can still access
the files. There is sufficient space for this.

Thus I can still build with dynamic linking and still have
everything work.

        Thank you,
        Hugh

---------- Original  message ----------
Date: Wed, 11 Nov 2009 10:32:20 +0000 (GMT)
From: Hugh Sasse <hgs(AT)dmu(DOT)ac(DOT)uk>
To: sunmanagers(AT)sunmanagers(DOT)org
Subject: Building Bash statically on Solaris9?

Short form:

Can anyone tell me the correct way to build bash-3.2.48 statically
on Solaris9?

Long form:

My understanding is that to be able to use bash in single user mode it
must be built statically (so it doesn't try to get libraries from unmounted 
file systems).  I also need a newer version than 2.05 for computed completion
to work properly, according to the docs I can find.  So I'm trying to build
bash-3.2.48 on the basis that 3.2.x has been around the block a few times,
whereas 4.0 is still rather new. (Were it 4.1 I'd be happier).

I'm using a --prefix=/usr (and I'm hoping that it won't try to
overwrite anything other than /bin/bash -- particularly libraries in
/usr.  The trouble with recursive make files is that make -n install
doesn't tell you everything.)

Using the configure options for --enable-static-link still seems to
link against dynamic libraries, and won't find my iconv in
/usr/local/lib. If I --disable-nls I get errors with gettext (which
I'd have thought it shouldn't even look at).  Adding /usr/local/lib
to LD_LIBRARY_PATH didn't help, because that appends it, but export
LD_OPTIONS="-I/usr/local/lib -B static" which prepends it to the ld
command line seemed to overcome the problems with iconv, but it now
fails with:

gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tilde -L./lib/malloc -L./lib/sh -static   -g -O2 -o bash shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o  dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o alias.o array.o arrayfunc.o braces.o bracecomp.o bashhist.o bashline.o  list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o pcomplib.o syntax.o xmalloc.o  -lbuiltins -lsh -lreadline -lhistory -ltermcap -lglob -ltilde -lmalloc lib/intl/libintl.a -liconv  -lsocket
Undefined                       first referenced
 symbol                             in file
getnetconfig                        /usr/lib/libsocket.a(_soutil.o)
_dlopen                             /usr/lib/libc.a(nss_deffinder.o)
setnetconfig                        /usr/lib/libsocket.a(_soutil.o)
_dlclose                            /usr/lib/libc.a(nss_deffinder.o)
_dlsym                              /usr/lib/libc.a(nss_deffinder.o)
endnetconfig                        /usr/lib/libsocket.a(_soutil.o)
ld: fatal: Symbol referencing errors. No output written to bash
collect2: ld returned 1 exit status

dlopen etc look like they are for handling dynamic libraries.
Indeed the manual page says:

Dynamic Linking Library Functions                     dlopen(3DL)

so I don't see why this is needed.

Installing GNU libtool didn't fix this.  There's a collection of things
called Gnulib which I could try to get, but it isn't a single package
and I'm not sure what to do about that. Also, it seems relatively new.

So, I'm wondering how to proceed.  Maybe this doesn't work because it
has not been done before and is thus untested, which leads to the idea
that maybe there's a good reason for that: "You should not be doing this".
If so, I'd like to know why not, and what I should do instead.

I believe I'm still on topic for this list because this is about
efficient and effective sysadmin (use of completion facilities
http://www.biostat.wisc.edu/~annis/commentary.html#37) and the
problems are specific to differences between Solaris and GNU/Linux
about how things should build.

        Thank you,
        Hugh
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Nov 18 08:35:10 2009

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:15 EST