Skip to contentSkip to conversation

lmbench: fix build with libtirpc

PATCH Superseded Baruch Siach 2 participants 3 messages Mar 6, 2015

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lmbench: fix build with libtirpc

When linking with an external libtirpc, -ltirpc must come after lmbench.a in the linker command line. Use LDLIBS for that.

Fixes:
http://autobuild.buildroot.net/results/89e/89ee35561d3a49f38e9a747ed78a5846be4764c8/
http://autobuild.buildroot.net/results/409/4097b1c2585db2de517a8741174c02177aabee00/

and more.

---
v2:
Rebase on current master (Fabio Porcedda)

---
 package/lmbench/0001-allow-ldlibs-override.patch | 19 +++++++++++++++++++
 package/lmbench/lmbench.mk                       |  8 +++++---
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 package/lmbench/0001-allow-ldlibs-override.patch
package/lmbench/0001-allow-ldlibs-override.patch new file +19 -0
new file mode 100644
index 000000000000..8085e7e90a4c
@@ -0,0 +1,19 @@
+Allow LDLIBS override
+
+The real make runs from the scripts/build script. Teach this script accept
+override value set in an environment variable.
+
+Signed-off-by: Baruch Siach <[email protected]>
+---
+diff -Nuar lmbench-3.0-a9.orig/scripts/build lmbench-3.0-a9/scripts/build
+--- lmbench-3.0-a9.orig/scripts/build	2006-06-27 19:25:18.000000000 +0300
++++ lmbench-3.0-a9/scripts/build	2015-02-24 09:59:30.302654994 +0200
+@@ -18,7 +18,7 @@
+ 
+ trap 'rm -f ${BASE}$$.s ${BASE}$$.c ${BASE}$$.o ${BASE}$$; exit 1' 1 2 15
+ 
+-LDLIBS=-lm
++LDLIBS="${LDLIBS} -lm"
+ 
+ # check for HP-UX's ANSI compiler
+ echo "main(int ac, char *av[]) { int i; }" > ${BASE}$$.c
package/lmbench/lmbench.mk +5 -3
index 59e750c5892f..224ec6983a66 100644
@@ -11,12 +11,11 @@ LMBENCH_LICENSE = lmbench license (based on GPLv2)
 LMBENCH_LICENSE_FILES = COPYING COPYING-2
 
 LMBENCH_CFLAGS = $(TARGET_CFLAGS)
-LMBENCH_LDLIBS = $(TARGET_LDFLAGS)
 
 ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
 LMBENCH_DEPENDENCIES += host-pkgconf libtirpc
 LMBENCH_CFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags libtirpc)
-LMBENCH_LDFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs libtirpc)
+LMBENCH_LDLIBS = $(shell $(PKG_CONFIG_HOST_BINARY) --libs libtirpc)
 endif
 
 define LMBENCH_CONFIGURE_CMDS
@@ -27,8 +26,11 @@ define LMBENCH_CONFIGURE_CMDS
 	touch $@
 endef
 
+# Note: there is a second stage 'make' invocation from the 'scripts/build'
+# script. So the variables override below don't take direct effect in
+# src/Makefile.
 define LMBENCH_BUILD_CMDS
-	$(MAKE) CFLAGS="$(LMBENCH_CFLAGS)" LDFLAGS="$(LMBENCH_LDFLAGS)" OS=$(ARCH) CC="$(TARGET_CC)" -C $(@D)/src
+	$(MAKE) CFLAGS="$(LMBENCH_CFLAGS)" LDLIBS="$(LMBENCH_LDLIBS)" OS=$(ARCH) CC="$(TARGET_CC)" -C $(@D)/src
 endef
 
 define LMBENCH_INSTALL_TARGET_CMDS
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/1 lmbench: fix build with libtirpc

On Fri, Mar 6, 2015 at 5:21 AM, Baruch Siach <[email protected]> wrote:
<snip>

Quoted 3 lines

+
+-LDLIBS=-lm
++LDLIBS="${LDLIBS} -lm"

Because we already do that for CFLAGS, instead of adding a patch just use sed:

define LMBENCH_CONFIGURE_CMDS

        $(call CONFIG_UPDATE,$(@D))
        sed -i 's/CFLAGS=/CFLAGS+=/g' $(@D)/src/Makefile
+       sed -i 's/LDLIBS=/LDLIBS+=/g' $(@D)/scripts/build
        sed -i '/cd .*doc/d' $(@D)/src/Makefile
        sed -i '/include/d' $(@D)/src/Makefile
        touch $@

endef

package/lmbench/lmbench.mk LMBENCH_LICENSE = lmbench license (based on GPLv2) · line 14

Quoted 11 lines

+ # check for HP-UX's ANSI compiler
+ echo "main(int ac, char *av[]) { int i; }" > ${BASE}$$.c

package/lmbench/lmbench.mk +0 -1
index 59e750c5892f..224ec6983a66 100644
@@ -11,12 +11,11 @@ LMBENCH_LICENSE = lmbench license (based on GPLv2)
 LMBENCH_LICENSE_FILES = COPYING COPYING-2
 
 LMBENCH_CFLAGS = $(TARGET_CFLAGS)
-LMBENCH_LDLIBS = $(TARGET_LDFLAGS)

Why you don't want to use the TARGET_LDFLAGS variable anymore? This change is not needed to fix this build failure.

BR

Signature · 1 line
Fabio Porcedda
#2 lore raw

PATCH v2 1/1 lmbench: fix build with libtirpc

Hi Fabio,

Quoted 8 lines · Fabio Porcedda

On Fri, Mar 6, 2015 at 5:21 AM, Baruch Siach <[email protected]> wrote:
<snip>

Quoted 3 lines

+
+-LDLIBS=-lm
++LDLIBS="${LDLIBS} -lm"

Because we already do that for CFLAGS, instead of adding a patch just use sed:

Quoted 8 lines

define LMBENCH_CONFIGURE_CMDS

        $(call CONFIG_UPDATE,$(@D))
        sed -i 's/CFLAGS=/CFLAGS+=/g' $(@D)/src/Makefile
+       sed -i 's/LDLIBS=/LDLIBS+=/g' $(@D)/scripts/build
        sed -i '/cd .*doc/d' $(@D)/src/Makefile
        sed -i '/include/d' $(@D)/src/Makefile
        touch $@

endef

Good point. Will do in v3.

Quoted 9 lines
Quoted 9 lines

+ # check for HP-UX's ANSI compiler
+ echo "main(int ac, char *av[]) { int i; }" > ${BASE}$$.c

package/lmbench/lmbench.mk +0 -0
index 59e750c5892f..224ec6983a66 100644
@@ -11,12 +11,11 @@ LMBENCH_LICENSE = lmbench license (based on GPLv2)
 LMBENCH_LICENSE_FILES = COPYING COPYING-2
 
Quoted 5 lines

package/lmbench/lmbench.mk LMBENCH_LICENSE = lmbench license (based on GPLv2) · line 14

Quoted 2 lines
package/lmbench/lmbench.mk +0 -1
 LMBENCH_CFLAGS = $(TARGET_CFLAGS)
-LMBENCH_LDLIBS = $(TARGET_LDFLAGS)

Why you don't want to use the TARGET_LDFLAGS variable anymore? This change is not needed to fix this build failure.

The $(LMBENCH_LDLIBS) variable was not used before this patch, so this is just dead code removal. Since this patch uses this variable I think we should remove this in this patch to avoid unintended side effects.

Thanks for reviewing,
baruch

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 -