Skip to contentSkip to conversation

BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

PATCH New ANDY KENNEDY 4 participants 8 messages Nov 5, 2012 – Jan 14, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

The following changes LDFLAGS from += -static to += --static if building with BR2_PREFER_STATIC_LIB so that various components actually build statically.

---

package/Makefile.in 2012-11-05 10:45:45.000000000 -0600 renamed from package/Makefile.in 2012-08-31 03:49:41.000000000 -0500 +1 -1
diff -Naur a/package/Makefile.in b/package/Makefile.in
@@ -299,7 +299,7 @@
 
 ifeq ($(BR2_PREFER_STATIC_LIB),y)
 SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared
-TARGET_LDFLAGS += -static
+TARGET_LDFLAGS += --static
 else
 SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
 endif
#1 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

Quoted 5 lines · ANDY KENNEDY

The following changes LDFLAGS from += -static to += --static if building with BR2_PREFER_STATIC_LIB so that various components actually build statically.

Although I'm OK with this patch, I have been unable to reproduce the problem
and I'd like to know why it is going wrong with -static. Can you post a defconfig that I can rebuild and that exposes the problem?

Note: a few autobuilders with BR2_PREFER_STATIC_LIB enabled could be nice -
or maybe not, because many packages _will_break.

Regards,
Arnout

Quoted 19 lines

---
diff -Naur a/package/Makefile.in b/package/Makefile.in

package/Makefile.in 2012-11-05 10:45:45.000000000 -0600 renamed from package/Makefile.in 2012-08-31 03:49:41.000000000 -0500 +1 -1
@@ -299,7 +299,7 @@
 
  ifeq ($(BR2_PREFER_STATIC_LIB),y)
  SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared
-TARGET_LDFLAGS += -static
+TARGET_LDFLAGS += --static
  else
  SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
  endif

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

Quoted 3 lines · Arnout Vandecappelle

Although I'm OK with this patch, I have been unable to reproduce the problem
and I'd like to know why it is going wrong with -static. Can you post a defconfig that I can rebuild and that exposes the problem?

Yes, I also would like more details about why this is needed. I think the TARGET_LDFLAGS thing is currently quite confusing: some packages are using it as flags for gcc at the link stage, some other packages are using it as flags for ld directly. Maybe this is what should be clarified somehow?

Quoted 2 lines

Note: a few autobuilders with BR2_PREFER_STATIC_LIB enabled could be nice -
or maybe not, because many packages _will_break.

I intended to make my autobuilder script randomly select BR2_PREFER_STATIC_LIB, BR2_CCACHE and a few other "big" options, but until now, I had the feeling that the autobuilder results already provided enough failures to keep us busy :-)

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

In reply to Arnout Vandecappelle
Quoted 10 lines

Although I'm OK with this patch, I have been unable to reproduce the problem
and I'd like to know why it is going wrong with -static. Can you post a defconfig that I can rebuild and that exposes the problem?

Note: a few autobuilders with BR2_PREFER_STATIC_LIB enabled could be nice -
or maybe not, because many packages _will_break.

Regards,
Arnout

First off, I built again with a clean copy of BuildRoot (2012.08) and produced this output this time:

root at akennedy_lin:~/deleteme/buildroot-2012.08# find output/target/ \
-exec file {} \; 2>&1 | grep dynamic | awk -F: '{print $1}' output/target/usr/bin/ldd
output/target/usr/bin/htop
output/target/usr/bin/getconf
output/target/usr/sbin/kdump
output/target/usr/sbin/proftpd
output/target/sbin/ldconfig

Note that htop and proftpd got linked dynamically. The odd part is that kexec built static this time. What's up with that? I repeated this twice and kexec builds static every time. . . though I really thought I did this last week and it was dynamically linked. Perhaps I'm smokin' something. . . BTW, I have _NEVER_ been able to build kdump static through their build. I can reproduce it manually, but there seems to be no way to do it with their current Makefile.

Attached is the config file. You may want to change the primary download site as I have it set to ftp://localhost/pub/dl.

Andy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: buildroot-2012_08.config
Type: application/octet-stream
Size: 25887 bytes
Desc: buildroot-2012_08.config
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20121106/a48d4e15/attachment-0001.obj>

#4 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

Quoted 12 lines · ANDY KENNEDY
Quoted 9 lines
Quoted 9 lines

Although I'm OK with this patch, I have been unable to reproduce the problem
and I'd like to know why it is going wrong with -static. Can you post a defconfig that I can rebuild and that exposes the problem?

Note: a few autobuilders with BR2_PREFER_STATIC_LIB enabled could be nice -
or maybe not, because many packages _will_break.

Regards,
Arnout

First off, I built again with a clean copy of BuildRoot (2012.08) and produced this output this time:

Quoted 8 lines

root at akennedy_lin:~/deleteme/buildroot-2012.08# find output/target/ \
-exec file {} \; 2>&1 | grep dynamic | awk -F: '{print $1}' output/target/usr/bin/ldd
output/target/usr/bin/htop
output/target/usr/bin/getconf
output/target/usr/sbin/kdump
output/target/usr/sbin/proftpd
output/target/sbin/ldconfig

I finally understand what's going on - it's exactly what Andy said in his
first mail :-)

libtool interpret -static as linking statically with libraries that will not
be installed to the libdir; you have to pass it -all-static to force static linking. Or, as Andy proposes, pass --static, which libtool passes on blindly to gcc. gcc and (GNU) ld both interpret --static the same as -static (although this isn't documented).

Therefore, this gets my

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#5 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

In reply to ANDY KENNEDY

All,

I just pulled the latest snapshot (buildroot-20130114.tar.bz2), did a quick grep to see if the patch was applied:

buildroot/package# grep static * Makefile.in:SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared Makefile.in:TARGET_LDFLAGS += -static Makefile.in:SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
pkg-autotools.mk: --enable-shared --disable-static \

and see that it wasn't. Is it on anyone's tree right now or did it get lost in the shuffle?

Thanks!
Andy

Quoted 26 lines

-----Original Message-----
From: ANDY KENNEDY
Sent: Monday, November 05, 2012 10:55 AM
To: 'buildroot at busybox.net'
Subject: [PATCH] BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

The following changes LDFLAGS from += -static to += --static if building with BR2_PREFER_STATIC_LIB so that various components actually build statically.

---
diff -Naur a/package/Makefile.in b/package/Makefile.in

package/Makefile.in 2012-11-05 10:45:45.000000000 -0600 renamed from package/Makefile.in 2012-08-31 03:49:41.000000000 -0500 +1 -1
@@ -299,7 +299,7 @@
 
 ifeq ($(BR2_PREFER_STATIC_LIB),y)
 SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared
-TARGET_LDFLAGS += -static
+TARGET_LDFLAGS += --static
 else
 SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
 endif
#6 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"ANDY" == ANDY KENNEDY <[email protected]> writes:

ANDY> All,
ANDY> I just pulled the latest snapshot (buildroot-20130114.tar.bz2), did a ANDY> quick grep to see if the patch was applied:

ANDY> buildroot/package# grep static *
ANDY> Makefile.in:SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared ANDY> Makefile.in:TARGET_LDFLAGS += -static
ANDY> Makefile.in:SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared
ANDY> pkg-autotools.mk: --enable-shared --disable-static \

ANDY> and see that it wasn't. Is it on anyone's tree right now or did it ANDY> get lost in the shuffle?

Committed now with Arnout's explanation about why it is needed. Please consider documenting WHY a change is needed rather than just what the change is to get this kind of patches merged faster in the future.

Signature · 1 line
Bye, Peter Korsgaard
#7 lore raw

PATCH 1/1 BR2_PREFER_STATIC_LIB and LDFLAGS+= -static

Quoted 4 lines

Committed now with Arnout's explanation about why it is needed. Please consider documenting WHY a change is needed rather than just what the change is to get this kind of patches merged faster in the future.

My bad. I'll try to be more verbose next time!

Andy

Quoted 3 lines

--
Bye, Peter Korsgaard