openssh: fix static linking
PATCH 1/1 openssh: fix static linking
When BR2_PREFER_STATIC_LIB is set, openssl is a static library, openssh attempts to build dynamically as the LDFLAGS are dropped out of this build. If PREFER_STATIC is set, add back in --static to the LDFLAGS of openssh to make the linker happy.
---
package/openssh/openssh.mk +9 -1
@@ -6,10 +6,18 @@ OPENSSH_VERSION = 6.5p1 OPENSSH_SITE = http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable -OPENSSH_CONF_ENV = LD="$(TARGET_CC)" LDFLAGS="$(TARGET_CFLAGS)" +OPENSSH_CONF_ENV = LD="$(TARGET_CC)" OPENSSH_CONF_OPT = --disable-lastlog --disable-utmp \ --disable-utmpx --disable-wtmp --disable-wtmpx --disable-strip +OPENSSH_LDFLAGS_FOR_CONF = $(TARGET_CFLAGS) + +ifeq ($(BR2_PREFER_STATIC_LIB),y) +OPENSSH_LDFLAGS_FOR_CONF += --static +endif + +OPENSSH_CONFIGURE_ENV += LDFLAGS="$(OPENSSH_LDFLAGS_FOR_CONF)" + OPENSSH_DEPENDENCIES = zlib openssl ifeq ($(BR2_PACKAGE_LINUX_PAM),y)
PATCH 1/1 openssh: fix static linking
Hi Andy,
Quoted 16 lines · ANDY KENNEDY
When
BR2_PREFER_STATIC_LIBis set, openssl is a static library, openssh attempts to build dynamically as the LDFLAGS are dropped out of this build. IfPREFER_STATICis set, add back in --static to the LDFLAGS of openssh to make the linker happy.Signed-off-by Andy Kennedy <[email protected]>---
diff -Naura/package/openssh/openssh.mkb/package/openssh/openssh.mkpackage/openssh/openssh.mk +1
-1@@ -6,10 +6,18 @@ OPENSSH_VERSION = 6.5p1 OPENSSH_SITE = http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable -OPENSSH_CONF_ENV = LD="$(TARGET_CC)" LDFLAGS="$(TARGET_CFLAGS)" +OPENSSH_CONF_ENV = LD="$(TARGET_CC)"
package/openssh/openssh.mk line 19
Quoted 10 lines
package/openssh/openssh.mk +7
-0OPENSSH_CONF_OPT = --disable-lastlog --disable-utmp \ --disable-utmpx --disable-wtmp --disable-wtmpx --disable-strip +OPENSSH_LDFLAGS_FOR_CONF = $(TARGET_CFLAGS) + +ifeq ($(BR2_PREFER_STATIC_LIB),y) +OPENSSH_LDFLAGS_FOR_CONF += --static +endif + +OPENSSH_CONFIGURE_ENV += LDFLAGS="$(OPENSSH_LDFLAGS_FOR_CONF)"
Shouldn't this be OPENSSH_CONF_ENV? Have you tested this?
baruch
Quoted 4 lines
package/openssh/openssh.mk +1
-0+ OPENSSH_DEPENDENCIES = zlib openssl ifeq ($(BR2_PACKAGE_LINUX_PAM),y)
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/1 openssh: fix static linking
Quoted 9 lines
package/openssh/openssh.mk line 19
Quoted 5 lines
package/openssh/openssh.mk +2
-1-OPENSSH_CONF_ENV = LD="$(TARGET_CC)" LDFLAGS="$(TARGET_CFLAGS)" +OPENSSH_CONF_ENV = LD="$(TARGET_CC)" OPENSSH_CONF_OPT = --disable-lastlog --disable-utmp \ +OPENSSH_CONFIGURE_ENV += LDFLAGS="$(OPENSSH_LDFLAGS_FOR_CONF)"Shouldn't this be
OPENSSH_CONF_ENV? Have you tested this?baruch
Yes, and yes. Hmmm, that's strange. Kinda makes me wonder why that worked at all. Made that modification and retesting.
Like I said in the other thread, this works about once out of three times anyway. So, maybe I didn't do what I thought I did.
I assume that the LDFLAGS=$(TARGET_CFLAGS) are needed, and that it _could_ break the build on other platforms. I don't understand why that would have worked for this particular platform I'm on.
I'll resubmit when I verify the fix.
Andy
PATCH 1/1 openssh: fix static linking
In reply to ANDY KENNEDYHello,
Quoted 6 lines · ANDY KENNEDY
When
BR2_PREFER_STATIC_LIBis set, openssl is a static library, openssh attempts to build dynamically as the LDFLAGS are dropped out of this build. IfPREFER_STATICis set, add back in --static to the LDFLAGS of openssh to make the linker happy.Signed-off-by Andy Kennedy <[email protected]>
Sorry, but it does not make sense, because:
ifeq ($(BR2_PREFER_STATIC_LIB),y) SHARED_STATIC_LIBS_OPTS = --enable-static --disable-shared TARGET_CFLAGS += -staticTARGET_CXXFLAGS += -staticTARGET_LDFLAGS += -static
elseSHARED_STATIC_LIBS_OPTS = --enable-static --enable-shared endif
So, TARGET_CFLAGS does have -static.
Please make sure to test your patches against the latest master. I'm sure you're again testing against 2014.02, and there has been quite a few changes since then in terms of static library support.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 openssh: fix static linking
Quoted 10 lines
ifeq ($(BR2_PREFER_STATIC_LIB),y)
SHARED_STATIC_LIBS_OPTS= --enable-static --disable-sharedTARGET_CFLAGS+= -staticTARGET_CXXFLAGS+= -staticTARGET_LDFLAGS+= -static
elseSHARED_STATIC_LIBS_OPTS= --enable-static --enable-shared endifSo,
TARGET_CFLAGSdoes have -static.
OOOHHHH!! Maybe that is the problem. I changed this a few years back:
-static gets eaten by autoconf. --static doesn't. I wonder if that has been the problem the whole time?
Quoted 4 lines
Please make sure to test your patches against the latest master. I'm sure you're again testing against 2014.02, and there has been quite a few changes since then in terms of static library support.
Yeah, I hear ya. I'll get to it eventually. I've done too much testing with 2014.02 and we're getting ready for a release.
I'll bump that rev later and may have to go through all this again.
Till then, I'll quit submitting patches until I'm at tip again :).
Andy
PATCH 1/1 openssh: fix static linking
Dear ANDY KENNEDY,
Quoted 5 lines · ANDY KENNEDY
OOOHHHH!! Maybe that is the problem. I changed this a few years back:
-static gets eaten by autoconf. --static doesn't. I wonder if that has been the problem the whole time?
Yes, but we reverted this change. Now we're back to using -static instead of --static. And we've patched libtool so that -static is actually understood as -all-static. See commits 8d764327a697a2572bba96878972c1a469f864f3 and 5d66a9b1fb67cf009fe4f15028c02a8386109dc5, as well as 97703978ac870ce2b14ad144f8e082de82aa2c64.
Quoted 6 lines
Yeah, I hear ya. I'll get to it eventually. I've done too much testing with 2014.02 and we're getting ready for a release.
I'll bump that rev later and may have to go through all this again.
Till then, I'll quit submitting patches until I'm at tip again :).
Yes, before sending patches, please test them on top of the latest master. Patches against 2014.02 are generally a bit useless, due to the fairly high rate of changes occurring these days in Buildroot.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com