Skip to contentSkip to conversation

multipath-tools: arrange compilation options for binaries

PATCH In review Xose Vazquez Perez 2 participants 6 messages Mar 17, 2017 – Mar 24, 2017 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multipath-tools: arrange compilation options for binaries

Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/Makefile       | 2 +-
 mpathpersist/Makefile | 2 +-
 multipath/Makefile    | 2 +-
 multipathd/Makefile   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
kpartx/Makefile +1 -1
index 9441a2b..2e81284 100644
@@ -19,7 +19,7 @@ EXEC = kpartx
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-	$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install: $(EXEC) $(EXEC).8
mpathpersist/Makefile +1 -1
index 47043bb..27e921e 100644
@@ -12,7 +12,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-	$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS) $(CFLAGS) $(LIBDEPS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
multipath/Makefile +1 -1
index cad34bf..421490c 100644
@@ -15,7 +15,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-	$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 	$(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
 
multipathd/Makefile +1 -1
index d57f6d5..a3fad61 100644
@@ -29,7 +29,7 @@ EXEC = multipathd
 all : $(EXEC)
 
 $(EXEC): $(OBJS)
-	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
Signature · 1 line
2.12.0
#1 lore raw

Merged,
Thanks.

On Fri, Mar 17, 2017 at 11:40 PM, Xose Vazquez Perez <[email protected]

Quoted 68 lines

wrote:

Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/Makefile       | 2 +-
 mpathpersist/Makefile | 2 +-
 multipath/Makefile    | 2 +-
 multipathd/Makefile   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
kpartx/Makefile +1 -1
index 9441a2b..2e81284 100644
@@ -19,7 +19,7 @@ EXEC = kpartx
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install: $(EXEC) $(EXEC).8
mpathpersist/Makefile +1 -1
index 47043bb..27e921e 100644
@@ -12,7 +12,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS) $(CFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
multipath/Makefile +1 -1
index cad34bf..421490c 100644
@@ -15,7 +15,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
        $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
 
multipathd/Makefile +1 -2
index d57f6d5..a3fad61 100644
@@ -29,7 +29,7 @@ EXEC = multipathd
 all : $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
--

2.12.0

#2 lore raw

And reverted:

From http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking
:

If object or library AA needs a symbol from library BB, then AA should come *before* library BB in the command-line invocation of the linker.

Quoted 73 lines · Christophe Varoqui

Merged,
Thanks.

Quoted 66 lines · Xose Vazquez Perez
Cc Christophe Varoqui <[email protected]>
Cc device-mapper development <[email protected]>
---
 kpartx/Makefile       | 2 +-
 mpathpersist/Makefile | 2 +-
 multipath/Makefile    | 2 +-
 multipathd/Makefile   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
kpartx/Makefile +1 -1
index 9441a2b..2e81284 100644
@@ -19,7 +19,7 @@ EXEC = kpartx
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install: $(EXEC) $(EXEC).8
mpathpersist/Makefile +1 -1
index 47043bb..27e921e 100644
@@ -12,7 +12,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS) $(CFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
multipath/Makefile +1 -1
index cad34bf..421490c 100644
@@ -15,7 +15,7 @@ OBJS = main.o
 all: $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
        $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
 
multipathd/Makefile +1 -2
index d57f6d5..a3fad61 100644
@@ -29,7 +29,7 @@ EXEC = multipathd
 all : $(EXEC)
 
 $(EXEC): $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC) $(LIBDEPS)
+       $(CC) $(CFLAGS) $(LDFLAGS) $(LIBDEPS) $(OBJS) -o $(EXEC)
        $(GZIP) $(EXEC).8 > $(EXEC).8.gz
 
 install:
--

2.12.0

#4 lore raw

Yes indeed, the build really failed on my box.

Toolchain versions :
* gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)
* GNU ld (GNU Binutils for Ubuntu) 2.26.1

make log :

cc -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fPIC -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -I../libmultipath -I../libmpathcmd -lpthread -ldevmapper -ldl -L../libmultipath -lmultipath -ludev -L../libmpathcmd -lmpathcmd main.o -o multipath
main.o: In function `get_dm_mpvec':
/home/cvaroqui/multipath-tools/multipath/main.c:209: undefined reference to dm_get_maps' /home/cvaroqui/multipath-tools/multipath/main.c:228: undefined reference to dm_get_map' /home/cvaroqui/multipath-tools/multipath/main.c:229: undefined reference to `dlog'
/home/cvaroqui/multipath-tools/multipath/main.c:230: undefined reference to dm_get_status' /home/cvaroqui/multipath-tools/multipath/main.c:231: undefined reference to dlog'
/home/cvaroqui/multipath-tools/multipath/main.c:233: undefined reference to `disassemble_map'
...
<snip: many more reference errors>
...
collect2: error: ld returned 1 exit status
Makefile:18: recipe for target 'multipath' failed
make[1]: *** [multipath] Error 1
make[1]: Leaving directory '/home/cvaroqui/multipath-tools/multipath' Makefile:46: recipe for target 'recurse' failed
make: *** [recurse] Error 2

Quoted 14 lines · Xose Vazquez Perez
Quoted 3 lines · Christophe Varoqui

And reverted:
hh
From http://eli.thegreenplace.net/2013/07/09/library-order-in-

static-linking:

Quoted 2 lines

If object or library AA needs a symbol from library BB, then AA

should

Quoted 1 line

come /before/ library BB in the command-line invocation of the

linker.

Did you get a toolchain error?

#5 lore raw
Quoted 5 lines · Christophe Varoqui

Yes indeed, the build really failed on my box.

Toolchain versions :
* gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)
* GNU ld (GNU Binutils for Ubuntu) 2.26.1

In Fedora 25, with these packages, it's built flawlessly:
kernel-4.10.5
binutils-2.26.1
glibc-2.24
make-4.1
gcc-6.3.1
clang-3.9.1

Quoted 7 lines
Quoted 6 lines

And reverted:
hh
From http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking <http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking>:

If object or library AA needs a symbol from library BB, then AA should come /before/ library BB in the command-line invocation of the linker.

Maybe this limitation was fixed in newer releases.