* [Buildroot] [PATCH v2] lz4: improve static only build support
@ 2018-04-20 4:52 Baruch Siach
2018-04-20 6:41 ` Thomas Petazzoni
2018-04-21 12:45 ` Thomas Petazzoni
0 siblings, 2 replies; 6+ messages in thread
From: Baruch Siach @ 2018-04-20 4:52 UTC (permalink / raw)
To: buildroot
The current method of supporting static only build, removal of all lines
that match the SHARED regex from lib/Makefile, is crude and fragile.
Instead, patch lib/Makefile to allow disable of shared libraries.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v2: Leave DESTDIR and PREFIX alone (Thomas P)
---
...ib-allow-to-disable-shared-libraries.patch | 59 +++++++++++++++++++
package/lz4/lz4.mk | 12 ++--
2 files changed, 64 insertions(+), 7 deletions(-)
create mode 100644 package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
diff --git a/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch b/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
new file mode 100644
index 000000000000..4f89e85577b3
--- /dev/null
+++ b/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
@@ -0,0 +1,59 @@
+From 95bde2a4ae4a92e984a5783ca1f09f44bf04fadb Mon Sep 17 00:00:00 2001
+From: Baruch Siach <baruch@tkos.co.il>
+Date: Thu, 19 Apr 2018 12:28:11 +0300
+Subject: [PATCH] lib: allow to disable shared libraries
+
+Just like BUILD_STATIC=no disables static libraries, BUILD_SHARED=no
+disabled shared libraries. This is useful to support toolchains that do
+not support shared libraries.
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+---
+Upstream status: https://github.com/lz4/lz4/pull/504
+
+ lib/Makefile | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/Makefile b/lib/Makefile
+index dd33f50351a8..976d57cd75ed 100644
+--- a/lib/Makefile
++++ b/lib/Makefile
+@@ -42,6 +42,7 @@ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
+ LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
+ LIBVER := $(shell echo $(LIBVER_SCRIPT))
+
++BUILD_SHARED:=yes
+ BUILD_STATIC:=yes
+
+ CPPFLAGS+= -DXXH_NAMESPACE=LZ4_
+@@ -92,6 +93,7 @@ ifeq ($(BUILD_STATIC),yes) # can be disabled on command line
+ endif
+
+ $(LIBLZ4): $(SRCFILES)
++ifeq ($(BUILD_SHARED),yes) # can be disabled on command line
+ @echo compiling dynamic library $(LIBVER)
+ ifneq (,$(filter Windows%,$(OS)))
+ @$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll\$@.dll
+@@ -102,6 +104,7 @@ else
+ @ln -sf $@ liblz4.$(SHARED_EXT_MAJOR)
+ @ln -sf $@ liblz4.$(SHARED_EXT)
+ endif
++endif
+
+ liblz4: $(LIBLZ4)
+
+@@ -159,9 +162,11 @@ ifeq ($(BUILD_STATIC),yes)
+ @$(INSTALL_DATA) liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a
+ @$(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(INCLUDEDIR)/lz4frame_static.h
+ endif
++ifeq ($(BUILD_SHARED),yes)
+ @$(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
+ @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR)
+ @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT)
++endif
+ @echo Installing headers in $(INCLUDEDIR)
+ @$(INSTALL_DATA) lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
+ @$(INSTALL_DATA) lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
+--
+2.17.0
+
diff --git a/package/lz4/lz4.mk b/package/lz4/lz4.mk
index c88329f7979e..a77f6b5f5fb5 100644
--- a/package/lz4/lz4.mk
+++ b/package/lz4/lz4.mk
@@ -11,10 +11,7 @@ LZ4_LICENSE = BSD-2-Clause (library), GPL-2.0+ (programs)
LZ4_LICENSE_FILES = lib/LICENSE programs/COPYING
ifeq ($(BR2_STATIC_LIBS),y)
-define LZ4_DISABLE_SHARED
- $(SED) '/SHARED/d' $(@D)/lib/Makefile
-endef
-LZ4_POST_PATCH_HOOKS += LZ4_DISABLE_SHARED
+LZ4_MAKE_OPTS += BUILD_SHARED=no
endif
define HOST_LZ4_BUILD_CMDS
@@ -27,17 +24,18 @@ define HOST_LZ4_INSTALL_CMDS
endef
define LZ4_BUILD_CMDS
- $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) lib lz4
+ $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) $(LZ4_MAKE_OPTS) \
+ -C $(@D) lib lz4
endef
define LZ4_INSTALL_STAGING_CMDS
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) DESTDIR=$(STAGING_DIR) \
- PREFIX=/usr install -C $(@D)
+ PREFIX=/usr $(LZ4_MAKE_OPTS) install -C $(@D)
endef
define LZ4_INSTALL_TARGET_CMDS
$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) DESTDIR=$(TARGET_DIR) \
- PREFIX=/usr install -C $(@D)
+ PREFIX=/usr $(LZ4_MAKE_OPTS) install -C $(@D)
endef
$(eval $(generic-package))
--
2.17.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v2] lz4: improve static only build support
2018-04-20 4:52 [Buildroot] [PATCH v2] lz4: improve static only build support Baruch Siach
@ 2018-04-20 6:41 ` Thomas Petazzoni
2018-04-21 21:05 ` Baruch Siach
2018-04-21 12:45 ` Thomas Petazzoni
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2018-04-20 6:41 UTC (permalink / raw)
To: buildroot
Hello,
On Fri, 20 Apr 2018 07:52:46 +0300, Baruch Siach wrote:
> The current method of supporting static only build, removal of all lines
> that match the SHARED regex from lib/Makefile, is crude and fragile.
> Instead, patch lib/Makefile to allow disable of shared libraries.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Thanks for the new version, I've applied, but I have one question below.
> ---
> v2: Leave DESTDIR and PREFIX alone (Thomas P)
> ---
> ...ib-allow-to-disable-shared-libraries.patch | 59 +++++++++++++++++++
> package/lz4/lz4.mk | 12 ++--
> 2 files changed, 64 insertions(+), 7 deletions(-)
> create mode 100644 package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
>
> diff --git a/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch b/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
> new file mode 100644
> index 000000000000..4f89e85577b3
> --- /dev/null
> +++ b/package/lz4/0002-lib-allow-to-disable-shared-libraries.patch
> @@ -0,0 +1,59 @@
> +From 95bde2a4ae4a92e984a5783ca1f09f44bf04fadb Mon Sep 17 00:00:00 2001
> +From: Baruch Siach <baruch@tkos.co.il>
> +Date: Thu, 19 Apr 2018 12:28:11 +0300
> +Subject: [PATCH] lib: allow to disable shared libraries
> +
> +Just like BUILD_STATIC=no disables static libraries, BUILD_SHARED=no
> +disabled shared libraries. This is useful to support toolchains that do
> +not support shared libraries.
Why aren't we using BUILD_STATIC=no when BR2_SHARED_LIBS=y, to disable
the build of the static library ?
Admittedly, it isn't a huge improvement, but for consistency it would
be good to do that.
Thanks again,
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v2] lz4: improve static only build support
2018-04-20 4:52 [Buildroot] [PATCH v2] lz4: improve static only build support Baruch Siach
2018-04-20 6:41 ` Thomas Petazzoni
@ 2018-04-21 12:45 ` Thomas Petazzoni
2018-04-21 20:50 ` Baruch Siach
1 sibling, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2018-04-21 12:45 UTC (permalink / raw)
To: buildroot
Hello,
On Fri, 20 Apr 2018 07:52:46 +0300, Baruch Siach wrote:
> The current method of supporting static only build, removal of all lines
> that match the SHARED regex from lib/Makefile, is crude and fragile.
> Instead, patch lib/Makefile to allow disable of shared libraries.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Not sure if it is due to this patch or the one bumping to 1.8.1.2, but
lz4 now fails to build in some configurations:
http://autobuild.buildroot.net/results/a8d/a8d956ff420f6a265c5c00b33646dbbc24ce2d48/build-end.log
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v2] lz4: improve static only build support
2018-04-21 12:45 ` Thomas Petazzoni
@ 2018-04-21 20:50 ` Baruch Siach
0 siblings, 0 replies; 6+ messages in thread
From: Baruch Siach @ 2018-04-21 20:50 UTC (permalink / raw)
To: buildroot
Hi Thomas,
On Sat, Apr 21, 2018 at 02:45:10PM +0200, Thomas Petazzoni wrote:
> On Fri, 20 Apr 2018 07:52:46 +0300, Baruch Siach wrote:
> > The current method of supporting static only build, removal of all lines
> > that match the SHARED regex from lib/Makefile, is crude and fragile.
> > Instead, patch lib/Makefile to allow disable of shared libraries.
> >
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>
> Not sure if it is due to this patch or the one bumping to 1.8.1.2, but
> lz4 now fails to build in some configurations:
>
> http://autobuild.buildroot.net/results/a8d/a8d956ff420f6a265c5c00b33646dbbc24ce2d48/build-end.log
Sees to be a parallel build issue caused by the version bump patch. I'll post
a patch.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v2] lz4: improve static only build support
2018-04-20 6:41 ` Thomas Petazzoni
@ 2018-04-21 21:05 ` Baruch Siach
2018-04-22 8:28 ` Thomas Petazzoni
0 siblings, 1 reply; 6+ messages in thread
From: Baruch Siach @ 2018-04-21 21:05 UTC (permalink / raw)
To: buildroot
Hi Thomas,
On Fri, Apr 20, 2018 at 08:41:43AM +0200, Thomas Petazzoni wrote:
> On Fri, 20 Apr 2018 07:52:46 +0300, Baruch Siach wrote:
> > +Just like BUILD_STATIC=no disables static libraries, BUILD_SHARED=no
> > +disabled shared libraries. This is useful to support toolchains that do
> > +not support shared libraries.
>
> Why aren't we using BUILD_STATIC=no when BR2_SHARED_LIBS=y, to disable
> the build of the static library ?
>
> Admittedly, it isn't a huge improvement, but for consistency it would
> be good to do that.
Many other packages build both shared and static libraries when
BR2_SHARED_LIBS=y. This particular case is easy enough to fix, though.
Is there any advantage to not building the static library when
BR2_SHARED_LIBS=y other than the small build time reduction?
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH v2] lz4: improve static only build support
2018-04-21 21:05 ` Baruch Siach
@ 2018-04-22 8:28 ` Thomas Petazzoni
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2018-04-22 8:28 UTC (permalink / raw)
To: buildroot
Hello Baruch,
On Sun, 22 Apr 2018 00:05:10 +0300, Baruch Siach wrote:
> > Admittedly, it isn't a huge improvement, but for consistency it would
> > be good to do that.
>
> Many other packages build both shared and static libraries when
> BR2_SHARED_LIBS=y.
Yes, I know. I don't know how strict we want to be about this. Probably
not too much because it doesn't matter that much.
> This particular case is easy enough to fix, though.
Yes, that's the point: for this package, it's super easy to fix, so
it's nice to do it.
> Is there any advantage to not building the static library when
> BR2_SHARED_LIBS=y other than the small build time reduction?
In some cases there is more than a "small build time reduction".
The object files that go in a shared library must be built with -fPIC.
Such object files can also be used in a static library, but the code is
not as optimized as it could be, and therefore object files that go in
a static library should ideally not be built with -fPIC. I believe some
packages (but not many) do build their object files twice, once with
-fPIC for the shared library, once without -fPIC for the static
library. This creates more than a "small build time reduction".
From the commit log of commit f1d3e09895b245da9d54bbaef36e5de95269034e:
For example, a static+shared build of libglib2 takes 1 minutes and 59
seconds, with a final build directory of 96 MB. A shared-only build of
libglib2 takes only 1 minutes and 31 seconds (almost a 25% reduction
of the build time), and the final build directory weights 89 MB (a
reduction of almost 8%).
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-04-22 8:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 4:52 [Buildroot] [PATCH v2] lz4: improve static only build support Baruch Siach
2018-04-20 6:41 ` Thomas Petazzoni
2018-04-21 21:05 ` Baruch Siach
2018-04-22 8:28 ` Thomas Petazzoni
2018-04-21 12:45 ` Thomas Petazzoni
2018-04-21 20:50 ` Baruch Siach
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.