libtool and the missing link

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

libtool and the missing link

#1 Post by goingnuts »

Some programs uses libtool when compiling and linking after you have done the ./configure.

As example I pass the following to build binutils:

Code: Select all

LD="/usr/i386-linux-uclibc/bin/i386-uclibc-ld" CC="/usr/i386-linux-uclibc/bin/i386-uclibc-gcc -static"
CFLAGS="-pipe -Os -mtune=i386 -Wall -D_BSD_SOURCE -D_GNU_SOURCE" LDFLAGS="-static -Wl,--gc-sections,--sort-common,-s" ./configure --prefix=/usr/i386-linux-uclibc/usr --includedir=/usr/i386-linux-uclibc/usr/include --disable-nls --disable-shared --enable-static
...but no matter where I put the "-static" it never turns up in the final linking.

Below a part of the compiling process where the -"static" is present in the first block - but absolutely gone in the second part that actually creates the bin:

Code: Select all

/bin/sh ./libtool --tag=CC --mode=link /usr/i386-linux-uclibc/bin/i386-uclibc-gcc -static -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -pipe -Os -mtune=i386 -Wall -D_BSD_SOURCE -D_GNU_SOURCE  -static -Wl,--gc-sections,--sort-common,-s -L/usr/i386-linux-uclibc/usr/lib -o ar  arparse.o arlex.o ar.o not-ranlib.o arsup.o rename.o binemul.o emul_vanilla.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a -lfl  -lz -lm 

libtool: link: /usr/i386-linux-uclibc/bin/i386-uclibc-gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -pipe -Os -mtune=i386 -Wall -D_BSD_SOURCE -D_GNU_SOURCE -Wl,--gc-sections -Wl,--sort-common -Wl,-s -o ar arparse.o arlex.o ar.o not-ranlib.o arsup.o rename.o binemul.o emul_vanilla.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a -lfl  -lz -lm 
By just adding the "-static" to the last command the bin is build static with no problems...Is there a magic flag to be set?

UPDATE: It always help to clear ones mind posting questions...At least for binutils it works if "-Xcompiler -static" is included in LDFLAGS. I will test some other sources were I have the same problem: It works with conky-1.3.0, not with libiconv-1.6.1...

John Doe
Posts: 1681
Joined: Mon 01 Aug 2005, 04:46
Location: Michigan, US

#2 Post by John Doe »

I think you are after the following:

Code: Select all

export LDFLAGS+="-static"

John Doe
Posts: 1681
Joined: Mon 01 Aug 2005, 04:46
Location: Michigan, US

#3 Post by John Doe »

p.s. might be best to stay away from libiconv. I've messed up my system with that before. As best I remember, puppy likes the version that glibc installs.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#4 Post by technosaurus »

In my musl static tool chain I wrote a wrapper that use a for arg in $@ case... to look through $@ for -l* and grokked in my link time options there (also replaced -O[0-3] with -Os and added my goodies in ... saved me from a ton of CLI simulated 3rd button click frustration) - just named it gcc after mving gcc to gcc-real

Not at home right now, here is a link to my old one
http://www.murga-linux.com/puppy/viewto ... 32&#588232
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#5 Post by goingnuts »

Another way to fightstupid libtool when refusing to link static - Run

Code: Select all

find . -name "ltmain.sh" -print | xargs sed -i 's/-all-static)/-all-static|-static)/g'
before ./configure.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#6 Post by amigo »

./configure --all-static ... is what you need for binutils. But, yes libtool can be a bitch to get doing what you want...

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#7 Post by Karl Godt »

If using unpatched source there is a chance that 10-50% of the source Makefile[.ini|.am] have some bugs
that result in gcc lines missing some $(LDFLAGS) variable .

Using outside shared libraries may also result in missing $(SOME_LIB_A_LDFLAGS) variables additionally in some Makefile .

Since many Source Code tarballs use several subdirectories with each it's own Makefile, you'll probably need to check each subdirectory' Makefile .

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#8 Post by goingnuts »

I am not sure all gcc-version accepts the "--all-static".

I use

Code: Select all

find . -name "Makefile" -print | xargs sed -i 's/prefix = \/usr\/local/prefix = \/usr/g' 
after runnig ./configure to address the various missing settings.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#9 Post by Karl Godt »

No, --all-static is rejected by cc1 gcc --version 4.2.2

Just did a compile of bc-1.06.95 source as

Code: Select all

./configure CFLAGS='--static'  
:

bash-3.2# file /root/Downloads/COMPILE/bc-1.06.95/bc/bc
/root/Downloads/COMPILE/bc-1.06.95/bc/bc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0,
statically linked, not stripped
bash-3.2# ls -s !$
ls -s /root/Downloads/COMPILE/bc-1.06.95/bc/bc
600 /root/Downloads/COMPILE/bc-1.06.95/bc/bc*


bc is rarely used --
Makefile seems ok to pass --static parameter.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#10 Post by amigo »

--all-static is an option to the configure script for binutils -not a gcc option -or more accurately an option to the linker (ld).

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#11 Post by Karl Godt »

GLIBC source is also such a candidate, that needs investigation about some parameters and Makefile to compile.

If these main core programs would be an easy task, not many Distros would build onto other Distro's efforts to create the basic environment.
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

Post Reply