Allow file to be built against static libs.
PATCH 1/1 Allow file to be built against static libs.
If selected "prefer static libs", file fails to build reporting:
relocation R_X86_64_32S against `zcalloc' can not be used when making a shared object; recompile with -fPIC
The suggested -fPIC doesn't work. The issue is that the default configure has --enable-shared --enable-static. This patch modifies the configure to disable shared when "prefer static libs" is selected.
Signed-off-by Andy Kennedy <[email protected]>
---
package/file/file.mk +5 -0
@@ -9,6 +9,11 @@ FILE_DEPENDENCIES = host-file zlib HOST_FILE_DEPENDENCIES = host-zlib +ifeq ($(BR2_PREFER_STATIC_LIB),y) +FILE_CONF_OPT = --disable-shared --enable-static +HOST_FILE_CONF_OPT = --disable-shared --enable-static +endif + define FILE_UNINSTALL_TARGET_CMDS $(MAKE) DESTDIR=$(TARGET_DIR) uninstall -C $(FILE_DIR) rm -f $(TARGET_DIR)/usr/lib/libmagic.*
PATCH 1/1 Allow file to be built against static libs.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"ANDY" == ANDY KENNEDY <[email protected]> writes:
ANDY> If selected "prefer static libs", file fails to build reporting:
ANDY> relocation R_X86_64_32S against `zcalloc' can not be used when making ANDY> a shared object; recompile with -fPIC
ANDY> The suggested -fPIC doesn't work. The issue is that the default ANDY> configure has --enable-shared --enable-static. This patch modifies ANDY> the configure to disable shared when "prefer static libs" is selected.
ANDY> FILE_DEPENDENCIES = host-file zlib
ANDY> HOST_FILE_DEPENDENCIES = host-zlib
ANDY> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
ANDY> +FILE_CONF_OPT = --disable-shared --enable-static ANDY> +HOST_FILE_CONF_OPT = --disable-shared --enable-static
We indeed force --enable-shared --disable-static for host builds, but that doesn't really matter. For target builds we use (see package/Makefile.in) --enable-static --enable-shared when PREFER_STATIC_LIB is enabled, so rather than something file specific, I think it would make more sense to set that to --enable-static --disable-shared instead.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 Allow file to be built against static libs.
Le Tue, 19 Jul 2011 22:22:56 +0200,
Peter Korsgaard <[email protected]> a ?crit :
Quoted 6 lines
We indeed force --enable-shared --disable-static for host builds, but that doesn't really matter. For target builds we use (see package/Makefile.in) --enable-static --enable-shared when
PREFER_STATIC_LIBis enabled, so rather than something file specific, I think it would make more sense to set that to --enable-static --disable-shared instead.
We have :
ifeq ($(BR2_PREFER_STATIC_LIB),y) SHARED_STATIC_LIBS_OPTS=--enable-static --disable-shared else
SHARED_STATIC_LIBS_OPTS=--enable-static --enable-shared endif
So it is already --enable-static --disable-shared when BR2_PREFER_STATIC_LIB=y. So, Andy, I think that your patch is basically a no-op, except for the host build of the file package, but it is totally incorrect to turn the host build of the file package to a static library depending on the value of BR2_PREFER_STATIC_LIB, which is limited to target packages only.
Regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 Allow file to be built against static libs.
In reply to Peter KorsgaardQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"Peter" == Peter Korsgaard <[email protected]> writes:
"ANDY" == ANDY KENNEDY <[email protected]> writes:
ANDY> If selected "prefer static libs", file fails to build reporting:
ANDY> relocation R_X86_64_32S against `zcalloc' can not be used when making ANDY> a shared object; recompile with -fPIC
ANDY> The suggested -fPIC doesn't work. The issue is that the default ANDY> configure has --enable-shared --enable-static. This patch modifies ANDY> the configure to disable shared when "prefer static libs" is selected.
ANDY> FILE_DEPENDENCIES = host-file zlib
ANDY> HOST_FILE_DEPENDENCIES = host-zlib
ANDY> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
ANDY> +FILE_CONF_OPT = --disable-shared --enable-static ANDY> +HOST_FILE_CONF_OPT = --disable-shared --enable-static
Peter> We indeed force --enable-shared --disable-static for host builds, but Peter> that doesn't really matter. For target builds we use (see Peter> package/Makefile.in) --enable-static --enable-shared when Peter> PREFER_STATIC_LIB is enabled, so rather than something file specific, I Peter> think it would make more sense to set that to --enable-static Peter> --disable-shared instead.
Ehh, drop that, I remembered wrong - We're already doing --enable-static --disable-shared.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 Allow file to be built against static libs.
Quoted 32 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"Peter" == Peter Korsgaard <[email protected]> writes:
"ANDY" == ANDY KENNEDY <[email protected]> writes:
ANDY> If selected "prefer static libs", file fails to build
reporting:
ANDY> relocationR_X86_64_32Sagainst `zcalloc' can not be used
when making
ANDY> a shared object; recompile with -fPIC
ANDY> The suggested -fPIC doesn't work. The issue is that the
default
ANDY> configure has --enable-shared --enable-static. This patch
modifies
ANDY> the configure to disable shared when "prefer static libs" is
selected.ANDY>
FILE_DEPENDENCIES= host-file zlib
ANDY>HOST_FILE_DEPENDENCIES= host-zlibANDY> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
ANDY> +FILE_CONF_OPT = --disable-shared --enable-static ANDY> +HOST_FILE_CONF_OPT = --disable-shared --enable-staticPeter> We indeed force --enable-shared --disable-static for host
builds, but
Peter> that doesn't really matter. For target builds we use (see Peter> package/Makefile.in) --enable-static --enable-shared when Peter>PREFER_STATIC_LIBis enabled, so rather than something file
specific, I
Peter> think it would make more sense to set that to --enable-
static
Peter> --disable-shared instead.
Quoted 2 lines
Ehh, drop that, I remembered wrong - We're already doing --enable- static --disable-shared.
Okay, well, sortta, but not really. I believe this to be the culprit:
#############################################################
#
# zlib # ############################################################# ZLIB_VERSION:=1.2.5 ZLIB_SOURCE:=zlib-$(ZLIB_VERSION).tar.bz2 ZLIB_SITE:=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/libpng ZLIB_INSTALL_STAGING=YES
ifeq ($(BR2_PREFER_STATIC_LIB),y)ZLIB_PIC :=ZLIB_SHARED := --static
elseZLIB_PIC := -fPICZLIB_SHARED := --shared
endif
I'm guessing this shouldn't be that way. I don't, however, really know how to fix this one up. I'm guessing that this needs to be something along the lines of:
ifeq ($(BR2_PREFER_STATIC_LIBZ),y)ZLIB_CONF_ENV = "LDFLAGS+=--static"
elseZLIB_CONF_ENV = "LDFLAGS+=-fPIC --shared"
endif
Or something like that. It appears, however, that the current state of the build makes ONLY a static libz if PREFER_STATIC_LIB is set.
So, file just happened to be the red herring.
Somebody who is more awake than I show me how to fix that puppy, please.
Andy
PATCH 1/1 Allow file to be built against static libs.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"ANDY" == ANDY KENNEDY <[email protected]> writes:
Ehh, drop that, I remembered wrong - We're already doing --enable- static --disable-shared.
ANDY> Okay, well, sortta, but not really. I believe this to be the culprit:
ANDY> #############################################################
ANDY> #
ANDY> # zlib
ANDY> #
ANDY> #############################################################
ANDY> ZLIB_VERSION:=1.2.5
ANDY> ZLIB_SOURCE:=zlib-$(ZLIB_VERSION).tar.bz2
ANDY> ZLIB_SITE:=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/libpng ANDY> ZLIB_INSTALL_STAGING=YES
ANDY> ifeq ($(BR2_PREFER_STATIC_LIB),y)
ANDY> ZLIB_PIC :=
ANDY> ZLIB_SHARED := --static
ANDY> else
ANDY> ZLIB_PIC := -fPIC
ANDY> ZLIB_SHARED := --shared
ANDY> endif
Yes, this is all fine. The problem is just that we link host stuff dynamically, but zlib was building the host version in the same was as the target one (so static if BR2_PREFER_STATIC_LIB), which would then break host-file when it tried to dynamically link to zlib.
I've fixed that now, thanks for reporting it.
Signature · 1 line
Bye, Peter Korsgaard