diff mbox

binutils build failed when CT_STATIC_TOOLCHAIN is enabled

Message ID 20140618074837.GC24738@nagra.com
State Changes Requested
Headers show

Commit Message

goodmenlinux@gmail.com June 18, 2014, 7:48 a.m. UTC
Hi, all

   I want a static toolchain (to copy and use it anywhere).
But failed when build the binutils:
    ct-ng binutils_for_host:

    It need flex static libs. On my machine, flex only has shared libs, so I 
tried to build a static lib manually (Why not include the flex in the "Companion tools"?)

    After that step, binutils keeps failed to built:
It has something to do with libtool. I spend some time to find the root cause, and here is
my discovering:

    The cmdline to build the ranlib is:
/bin/sh ./libtool --tag=CC   --mode=link ../../../buildtools/bin/x86_64-build_unknown-linux-gnu-gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -O2 -g -pipe   -static-libstdc++ -static-libgcc -static -all-static -o ranlib ar.o is-ranlib.o arparse.o arlex.o arsup.o rename.o binemul.o emul_vanilla.o bucomm.o version.o filemode.o ../bfd/libbfd.la ../libiberty/libiberty.a -lfl  -lz

   The -lfl is expanded to /usr/lib/libfl.so, so the linker complain that.
I have checked the libtool script, and found that the following option
      -all-static
      -static
      -static-libtool-libs
is processed in a strange way. If any one of those three option appears firstly in the cmdline, all others
will be neglected. Our LDFLAGS is ".... -static -all-static -o", so the -static option takes the real effect,
and the -all-static has no useage actually! that is the cause of the failure.

     I have changed the /usr/lib/ct-ng.hg+default-99029fac116b/scripts/build/binutils/binutils.sh
     line 223:
            extra_make_flags+=("LDFLAGS=-static -all-static")
     to 
            extra_make_flags+=("LDFLAGS=-all-static -static")

And the binutils built OK.

The patch is attached for the maintainer for reference.

Thanks for all the maintainers and hackers!
--
For unsubscribe information see http://sourceware.org/lists.html#faq
diff mbox

Patch

diff -r 99029fac116b scripts/build/binutils/binutils.sh
--- a/scripts/build/binutils/binutils.sh	Mon May 12 00:09:31 2014 +0200
+++ b/scripts/build/binutils/binutils.sh	Wed Jun 18 15:47:16 2014 +0800
@@ -220,7 +220,7 @@ 
         "${CT_BINUTILS_EXTRA_CONFIG_ARRAY[@]}"
 
     if [ "${static_build}" = "y" ]; then
-        extra_make_flags+=("LDFLAGS=-static -all-static")
+        extra_make_flags+=("LDFLAGS=-all-static -static")
         CT_DoLog EXTRA "Prepare binutils for static build"
         CT_DoExecLog ALL make ${JOBSFLAGS} configure-host
     fi