[oe] [meta-oe][PATCH 1/2] multipath-tools: fix building of shared objects

Patrick Ohly patrick.ohly at intel.com
Fri Jan 27 10:11:21 UTC 2017


When -pie is in CFLAGS, it overrides the -shared compiler
flag, leading to link errors (undefined main) for shared
objects. Parameters must be ordered so that -shared comes
last.

Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
---
 meta-oe/recipes-support/multipath-tools/files/shared-libs-avoid-linking-.so-as-executable.patch | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 meta-oe/recipes-support/multipath-tools/multipath-tools_git.bb                                  |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 meta-oe/recipes-support/multipath-tools/files/shared-libs-avoid-linking-.so-as-executable.patch

diff --git a/meta-oe/recipes-support/multipath-tools/files/shared-libs-avoid-linking-.so-as-executable.patch b/meta-oe/recipes-support/multipath-tools/files/shared-libs-avoid-linking-.so-as-executable.patch
new file mode 100644
index 0000000..ae6bb89
--- /dev/null
+++ b/meta-oe/recipes-support/multipath-tools/files/shared-libs-avoid-linking-.so-as-executable.patch
@@ -0,0 +1,49 @@
+From 4311856200480288494df8df737f71ea316592d0 Mon Sep 17 00:00:00 2001
+From: Patrick Ohly <patrick.ohly at intel.com>
+Date: Thu, 26 Jan 2017 15:28:34 +0100
+Subject: [PATCH] shared libs: avoid linking .so as executable
+
+When the OE build systems sets CFLAGS including -pie, gcc overrides
+the earlier -shared parameter and tries to link a binary, leading to
+errors about missing functions like main().
+
+Reordering the parameters so that -shared comes after CFLAGS
+fixes this.
+
+Upstream-Status: Inappropriate [OE specific, -pie shouldn't be in CFLAGS?!]
+
+Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
+---
+ libmpathpersist/Makefile | 2 +-
+ libmultipath/Makefile    | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libmpathpersist/Makefile b/libmpathpersist/Makefile
+index c4ec1c5..790692a 100644
+--- a/libmpathpersist/Makefile
++++ b/libmpathpersist/Makefile
+@@ -20,7 +20,7 @@ all: $(LIBS)
+ 
+ $(LIBS): 
+ 	$(CC) -Wall -fPIC -c $(CFLAGS) *.c 
+-	$(CC)  -shared $(LIBDEPS) -Wl,-soname=$@ $(CFLAGS) -o $@ $(OBJS)
++	$(CC) $(LIBDEPS) $(CFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS)
+ 	ln -s $(LIBS) $(DEVLIB)
+ 	$(GZIP) mpath_persistent_reserve_in.3 > mpath_persistent_reserve_in.3.gz	
+ 	$(GZIP) mpath_persistent_reserve_out.3 > mpath_persistent_reserve_out.3.gz	
+diff --git a/libmultipath/Makefile b/libmultipath/Makefile
+index fc0f3d6..2287d91 100644
+--- a/libmultipath/Makefile
++++ b/libmultipath/Makefile
+@@ -55,7 +55,7 @@ endif
+ all: $(LIBS)
+ 
+ $(LIBS): $(OBJS)
+-	$(CC) $(LDFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ $(CFLAGS) -o $@ $(OBJS) $(LIBDEPS)
++	$(CC) $(LDFLAGS) $(CFLAGS) $(SHARED_FLAGS) -Wl,-soname=$@ -o $@ $(OBJS) $(LIBDEPS)
+ 	ln -sf $@ $(DEVLIB)
+ 
+ install:
+-- 
+2.11.0
+
diff --git a/meta-oe/recipes-support/multipath-tools/multipath-tools_git.bb b/meta-oe/recipes-support/multipath-tools/multipath-tools_git.bb
index 6bd6118..2ab4dad 100644
--- a/meta-oe/recipes-support/multipath-tools/multipath-tools_git.bb
+++ b/meta-oe/recipes-support/multipath-tools/multipath-tools_git.bb
@@ -11,6 +11,7 @@ SRC_URI = "git://git.opensvc.com/multipath-tools/.git;protocol=http \
            file://always-use-libdevmapper-kpartx.patch \
            file://do-not-link-libmpathpersist-to-TMPDIR.patch \
            file://0001-multipathd.service-Error-fix.patch \
+           file://shared-libs-avoid-linking-.so-as-executable.patch \
            "
 # 0.5.0
 #
-- 
git-series 0.9.1



More information about the Openembedded-devel mailing list