ibm-s390-linux / smc-tools

Tools for use with AF_SMC sockets
Eclipse Public License 1.0
19 stars 14 forks source link

libnl3 compiler flags not used when building with distro CFLAGS #1

Closed sharkcz closed 3 years ago

sharkcz commented 3 years ago

When building a distro package (on Fedora) using distro-wide compiler/linker flags, then the additional compiler flags for libnl3 are not passed to the compiler.

Provádění(%build): /bin/sh -e /var/tmp/rpm-tmp.2pFel2
+ umask 022
+ cd /home/dan/projects/fedora/smc-tools
+ cd smc-tools-1.5.0
+ /usr/bin/make -O -j32 V=1 VERBOSE=1 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection' 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' V=1
Makefile:101: "Warning: Skipping 31/32-bit library build because 31/32-bit build tools"
Makefile:102: "         are unavailable. SMC will not support 31/32 bit applications"
Makefile:103: "         unless the glibc devel package for the appropriate addressing"
Makefile:104: "         mode is installed and the preload libraries are rebuilt."
cc -DSMC_TOOLS_RELEASE=1.5.0 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -DSMCD -c smc.c -o smcd.o
In file included from smc.c:27:
libnetlink.h:23:10: fatal error: netlink/genl/genl.h: No such file or directory
   23 | #include <netlink/genl/genl.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:110: smcd.o] Error 1
sharkcz commented 3 years ago

A quick fix might look like

diff -up smc-tools-1.5.0/Makefile.fix smc-tools-1.5.0/Makefile
--- smc-tools-1.5.0/Makefile.fix    2021-02-25 13:44:00.974729646 +0100
+++ smc-tools-1.5.0/Makefile    2021-02-25 13:44:08.493815002 +0100
@@ -70,7 +70,7 @@ else
 SMC_PNET_CFLAGS = -I /usr/include/libnl3
 SMC_PNET_LFLAGS = -lnl-genl-3 -lnl-3
 endif
-CFLAGS += ${SMC_PNET_CFLAGS}
+ALL_CFLAGS += ${SMC_PNET_CFLAGS}

 ifeq ($(ARCHTYPE),s390x)
    MACHINE_OPT32="-m31"
diff -up smc-tools-1.5.0/Makefile.fix smc-tools-1.5.0/Makefile
--- smc-tools-1.5.0/Makefile.fix    2021-02-25 13:46:10.029015197 +0100
+++ smc-tools-1.5.0/Makefile    2021-02-25 13:46:13.448599150 +0100
@@ -82,7 +82,7 @@ util.o: util.c  util.h
    ${CCC} ${CFLAGS} -c util.c

 libnetlink.o: libnetlink.c  libnetlink.h
-   ${CCC} ${CFLAGS} ${LDFLAGS} -c libnetlink.c
+   ${CCC} ${ALL_CFLAGS} ${LDFLAGS} -c libnetlink.c

 smc-preload.o: smc-preload.c
    ${CCC} ${CFLAGS} -fPIC -c smc-preload.c
Stefan-Raspl commented 3 years ago

Thanks for pointing this out! Can you please try with this patch and report back?

index 427fc71..d7103d8 100644
--- a/Makefile
+++ b/Makefile
@@ -64,13 +64,13 @@ CFLAGS ?= -Wall -O3 -g
 ALL_CFLAGS = -DSMC_TOOLS_RELEASE=$(SMC_TOOLS_RELEASE) $(CFLAGS)

 ifneq ($(shell sh -c 'command -v pkg-config'),)
-SMC_PNET_CFLAGS = $(shell pkg-config --silence-errors --cflags libnl-genl-3.0)
-SMC_PNET_LFLAGS = $(shell pkg-config --silence-errors --libs libnl-genl-3.0)
+LIBNL_CFLAGS = $(shell pkg-config --silence-errors --cflags libnl-genl-3.0)
+LIBNL_LFLAGS = $(shell pkg-config --silence-errors --libs libnl-genl-3.0)
 else
-SMC_PNET_CFLAGS = -I /usr/include/libnl3
-SMC_PNET_LFLAGS = -lnl-genl-3 -lnl-3
+LIBNL_CFLAGS = -I /usr/include/libnl3
+LIBNL_LFLAGS = -lnl-genl-3 -lnl-3
 endif
-CFLAGS += ${SMC_PNET_CFLAGS}
+CFLAGS += ${LIBNL_CFLAGS}

 ifeq ($(ARCHTYPE),s390x)
        MACHINE_OPT32="-m31"
@@ -82,7 +82,7 @@ util.o: util.c  util.h
        ${CCC} ${CFLAGS} -c util.c

 libnetlink.o: libnetlink.c  libnetlink.h
-       ${CCC} ${CFLAGS} ${LDFLAGS} -c libnetlink.c
+       ${CCC} ${CFLAGS} ${LIBNL_CFLAGS} ${LDFLAGS} -c libnetlink.c

 smc-preload.o: smc-preload.c
        ${CCC} ${CFLAGS} -fPIC -c smc-preload.c
@@ -116,13 +116,13 @@ endif
        ${CCC} ${ALL_CFLAGS} -c $< -o $@

 smc: smc.o dev.o linkgroup.o libnetlink.o util.o
-       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${SMC_PNET_LFLAGS} -o $@
+       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${LIBNL_LFLAGS} -o $@

 smcd: smcd.o infod.o devd.o linkgroupd.o libnetlink.o util.o
-       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${SMC_PNET_LFLAGS} -o $@
+       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${LIBNL_LFLAGS} -o $@

 smcr: smcr.o infor.o devr.o linkgroupr.o libnetlink.o util.o
-       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${SMC_PNET_LFLAGS} -o $@
+       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${LIBNL_LFLAGS} -o $@

 smc_pnet: smc_pnet.c smctools_common.h
        @if [ ! -e /usr/include/libnl3/netlink/netlink.h ]; then \
@@ -135,10 +135,10 @@ smc_pnet: smc_pnet.c smctools_common.h
                printf "**************************************************************\n" >&2; \
                exit 1; \
        fi
-       ${CCC} ${ALL_CFLAGS} ${SMC_PNET_CFLAGS} ${LDFLAGS} -o $@ $< ${SMC_PNET_LFLAGS}
+       ${CCC} ${ALL_CFLAGS} ${LIBNL_CFLAGS} ${LDFLAGS} -o $@ $< ${LIBNL_LFLAGS}

 smcss: smcss.o libnetlink.o
-       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${SMC_PNET_LFLAGS} -o $@
+       ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $^ ${LIBNL_LFLAGS} -o $@
 #smcss: smcss.c smctools_common.h libnetlink.h
 #      ${CCC} ${ALL_CFLAGS} ${LDFLAGS} $< -o $@
sharkcz commented 3 years ago

@Stefan-Raspl could you send me the patch via email? Or make it a PR here? I have troubles applying it, probably due tabs vs spaces issues.

sharkcz commented 3 years ago

hm, it haven't help, same problem

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.sR33N5
+ umask 022
+ cd /builddir/build/BUILD
+ cd /builddir/build/BUILD
+ rm -rf smc-tools-1.5.0
+ /usr/bin/gzip -dc /builddir/build/SOURCES/smc-tools-1.5.0.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd smc-tools-1.5.0
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ /usr/bin/cat /builddir/build/SOURCES/smc-tools-1.5.0-makefile.patch
+ /usr/bin/patch -s --fuzz=0 --no-backup-if-mismatch
+ /usr/bin/cat /builddir/build/SOURCES/smc-tools-1.5.0-flags.patch
+ /usr/bin/patch -s --fuzz=0 --no-backup-if-mismatch
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.N2Ur9i
+ umask 022
+ cd /builddir/build/BUILD
+ cd smc-tools-1.5.0
+ /usr/bin/make -O -j64 V=1 VERBOSE=1 'CFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection' 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' V=1
Makefile:101: "Warning: Skipping 31/32-bit library build because 31/32-bit build tools"
Makefile:102: "         are unavailable. SMC will not support 31/32 bit applications"
Makefile:103: "         unless the glibc devel package for the appropriate addressing"
Makefile:104: "         mode is installed and the preload libraries are rebuilt."
cc -DSMC_TOOLS_RELEASE=1.5.0 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -DSMCD -c dev.c -o devd.o
In file included from dev.c:24:
libnetlink.h:23:10: fatal error: netlink/genl/genl.h: No such file or directory
   23 | #include <netlink/genl/genl.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:110: devd.o] Error 1
make: *** Waiting for unfinished jobs....
cc -DSMC_TOOLS_RELEASE=1.5.0 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -mcpu=power8 -mtune=power8 -fasynchronous-unwind-tables -fstack-clash-protection -DSMCD -c info.c -o infod.o
In file included from info.c:22:
libnetlink.h:23:10: fatal error: netlink/genl/genl.h: No such file or directory
   23 | #include <netlink/genl/genl.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:110: infod.o] Error 1
...

I'm invoking the compilation with %make_build CFLAGS="%{build_cflags}" LDFLAGS="%{build_ldflags}" V=1 where %{build_cflags } /%{build_ldflags} are the distro wide compiler/linker flags.

sharkcz commented 3 years ago

for the record, until there is an official solution, we went with https://src.fedoraproject.org/rpms/smc-tools/blob/rawhide/f/smc-tools-1.5.0-flags.patch provided by Stefan