From: Dr. David Kirkby on 16 Jul 2010 07:02 I've got some code someone written for converting a static library to a shared one. It's based on the GNU linker. lapack_command="ld -L"$f95_dir" -L"$SAGE_LOCAL"/lib -shared -soname liblapack.so -o liblapack.so --whole-archive liblapack.a --no-whole- arch ive -lc -lm -lf95" $lapack_command I want to convert that to use the Sun linker, as I trust that more, so came up with this. I have this in a loop, but you can see the point. * The environment variable SAGE64 is set to "yes" if I want 64-bit libraries. (I thought the linker would have worked that out, but it seems to create them by default in a way that applications think they are 32-bit). * $SAGE_LOCAL/lib has some libraries in it. Is there possibly any use for this bit of the command - I can't see what it might achieve. if [ "x`uname`" = xSunOS ]; then cd "$SAGE_LOCAL/lib" if [ "x$SAGE64" = xyes ] ; then # To create a 64-bit shared library, the linker flag # '-64' must be added. Note this is not the same as # the compiler flag '-m64' LINKER_FLAG=-64 fi for ATLAS_LIBRARY in libatlas liblapack libf77blas libcblas ; do echo "Building shared library $ATLAS_LIBRARY.so from the static library $ATLAS_LIBRARY.a" /usr/ccs/bin/ld $LINKER_FLAG -L"$SAGE_LOCAL/lib" -G -h $ATLAS_LIBRARY.so -o $ATLAS_LIBRARY.so -zallextract $ATLAS_LIBRARY.a -zdefaultextract - lc -lm -lgfortran if [ $? -ne 0 ]; then echo "Failed to build ATLAS library $ATLAS_LIBRARY.so" exit 1 else echo "$ATLAS_LIBRARY.so has been built on Solaris." fi done fi Is this syntax right correct or optimal ? I'm aware the Sun linker in OpenSolaris will take the GNU options, but I want this to work on any Solaris 10 release on SPARC or x86. Dave
From: Rainer Orth on 16 Jul 2010 08:12 "Dr. David Kirkby" <david.kirkby(a)onetel.net> writes: > I've got some code someone written for converting a static library to > a shared one. It's based on the GNU linker. > > lapack_command="ld -L"$f95_dir" -L"$SAGE_LOCAL"/lib -shared -soname > liblapack.so -o liblapack.so --whole-archive liblapack.a --no-whole- > arch > ive -lc -lm -lf95" > $lapack_command You cannot do this in general: to be properly sharable, the object files need to be compiled as position-independent code (-Kpic/-fpic), which isn't usually the case in archive libraries. So I'd forget about this and properly build PIC code and link it into a shared library. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University
From: Dr. David Kirkby on 16 Jul 2010 18:25 On Jul 16, 1:12 pm, Rainer Orth <r...(a)CeBiTec.Uni-Bielefeld.DE> wrote: > "Dr. David Kirkby" <david.kir...(a)onetel.net> writes: > > > I've got some code someone written for converting a static library to > > a shared one. It's based on the GNU linker. > > > lapack_command="ld -L"$f95_dir" -L"$SAGE_LOCAL"/lib -shared -soname > > liblapack.so -o liblapack.so --whole-archive liblapack.a --no-whole- > > arch > > ive -lc -lm -lf95" > > $lapack_command > > You cannot do this in general: to be properly sharable, the object files > need to be compiled as position-independent code (-Kpic/-fpic), which > isn't usually the case in archive libraries. So I'd forget about this > and properly build PIC code and link it into a shared library. > > Rainer The code is built with the -fPIC option. For two of the libraries, this is certainly working OK. It has been done on Linux for ages with this code. Its just on SPARC, it was not done, but I think the person who implemented this code did not know what he was doing at all - even less than me. I'm reluctant to try to make changes to the source code and build system, as it is a huge package called ATLAS. It has a non-trivial build process, that runs timing tests on your hardware, to work out how best to built itself. Dave
From: Rainer Orth on 19 Jul 2010 04:10 "Dr. David Kirkby" <david.kirkby(a)onetel.net> writes: > The code is built with the -fPIC option. For two of the libraries, > this is certainly working OK. It has been done on Linux for ages with > this code. Its just on SPARC, it was not done, but I think the person > who implemented this code did not know what he was doing at all - even > less than me. Ok, than there shouldn't be a problem. Sun ld has -z allextract/-z defaultextract since at least Solaris 8. In recent Solaris 11 builds, it even understands the GNU ld equivalents --whole-archive/--no-whole-archive, so you should be fine. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University
|
Pages: 1 Prev: GNOME session file documentation? Next: How to use a shared account with RBAC? |