Getting more shared libraries out of HLFS

Kevin Day drealin01 at
Sat Jun 17 14:30:31 PDT 2006

==== GCC ====
GCC provides separate names for both static and shared libraries.

There are two cases directly related to HLFS.

1) and libssp_nonshared.a
I made a patch for this in one of my previous mailings.
Bottom line, libssp_nonshared.a and seem to be the same file.
Which is rather strange, given how by defaukt the libssp project treats
-fstack-protector{,-all} as incLIBGCC=-lgcc_sluding -lssp and 

2) libgcc.a and
  /lib/gcc/$target/*/*.a contains 3 files:
    libgcc.a     - Can be safely replaced with
    libgcc_eh.a  - I have no clue what this one is for
    libgcov.a    - Can be safely removed as HLFS suggested already

3) Once this was done I had to apply a patch to uClibc, so that it
would not try to combine the shared library and the static
*.o files in order to create a shared pthread library.  The patch for
this is attached: uClibc-0.9.28-shared_fixes-1.patch

4) It turns out that module-init-tools wants the static *.a's.
   The *.a's requirement can be worked around by linking the insmod
dynamically for module-init-tools (when yo:
   # make insmod_static_LDFLAGS='-shared'
   # make insmod_static_LDFLAGS='-shared' install

==== FLEX ====
It seems that flex does not create a shared library and only creates
the libfl.a.

So, I decided to create one myself.

AFTER YOU BUILD flex according to hlfs instructions run the following,
before deleting the any parts of the compiled source

1) Create the shared library with all the necessary object files
#gcc -fstack-protector-all -shared -lm -lc -lgcc_s -fpic -fPIC \
-Wl,-soname, -o$VERSION buf.o ccl.o dfa.o ecs.o \
filter.o gen.o main.o misc.o nfa.o options.o parse.o regex.o scan.o \
scanopt.o skel.o sym.o tables.o tables_shared.o tblcmp.o yylex.o

2) Copy the shared library over to desired path either /lib or /usr/lib
# cp -v$VERSION /lib

3) Make symbolic links for the dynamic linker to properly find
# ln -vsf$VERSION /lib/
# ln -vsf /lib/

Now you can delete the /lib/libfl.a.
The location of the libraries above might be /usr/lib instead of
just /lib.

At this point any library can link to the and future changes
to the shared library should not break anything.

Do Not omit a single .o file nor the -shared -lm -lc.
Do Not add any .o file not listed in the commands above.
the -lgcc_s, may be changed to -lgcc if you have and wish to use the
static libgcc instead of the shared one. (remember, GCC gives different
names to their shared and static libraries..)

==== bzip2 ====
Ever since using the latest gcc (4.1.?), I had problems with bzip2's
shared library.  It turns out to be a simple fix.  The symbolic links
are not set properly by bzip2's Makefile.

Do the following
1) Copy the shared library over to desired path either /lib or /usr/lib
# cp -v$VERSION
# ln -vs$VERSION /lib/
# ln -vs /lib/

More information about the hlfs-dev mailing list