extensions: fix linking against -lip6tc
PATCH 1/1 extensions: fix linking against -lip6tc
The current build forgets to specify a path to find libip6tc which means it either fails (if there is no libip6tc in the system), or links against an old version (if there is one in the system).
References: https://bugs.gentoo.org/449262
--- extensions/GNUmakefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
extensions/GNUmakefile.in +1 -1
@@ -101,7 +101,7 @@ libxt_state.so: libxt_conntrack.so ln -fs $< $@ # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD -ip6t_NETMAP_LIBADD = -lip6tc +ip6t_NETMAP_LIBADD = -L../libiptc/.libs -lip6tc xt_RATEEST_LIBADD = -lm xt_statistic_LIBADD = -lm
Signature · 1 line
1.8.0
Pablo Neira Ayuso
maintainerHi Mike,
Quoted 3 lines · Mike Frysinger
The current build forgets to specify a path to find libip6tc which means it either fails (if there is no libip6tc in the system), or links against an old version (if there is one in the system).
We already got a similar patch fix for that issue:
http://patchwork.ozlabs.org/patch/208133/
Can you give it a try and check if it also fixes the problem for you?
Thanks.
Quoted 7 lines · On Sunday 30 December 2012 18:38:28 Pablo Neira Ayuso wrote:
Hi Mike,
Quoted 3 lines · Mike Frysinger
The current build forgets to specify a path to find libip6tc which means it either fails (if there is no libip6tc in the system), or links against an old version (if there is one in the system).
Quoted 5 lines
We already got a similar patch fix for that issue:
http://patchwork.ozlabs.org/patch/208133/
Can you give it a try and check if it also fixes the problem for you?
adding an -L path to the non-.libs/ subdir doesn't make sense when the existing code (the -lxtables stuff) only uses .libs/.
really the best thing would to stop grubbing around in libtool internals and use libtool to link considering it was used to generate the other libraries in the first place.
-mike
PATCH 1/1 build: resolve link failure for ip6t_NETMAP
Link stage of libip6t_NETMAP failed since recently.
CCLD libip6t_NETMAP.so/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
cannot find -lip6tc
libip6t_NETMAP.c uses the "ipv6_prefix_length" function from libip6tc.so; "-lip6tc" is used in the Makefile, but, the directory to it is not specified.
Why does the link succeed for some people? Because /usr/lib(64)/libip6tc.so satisfies -lip6tc, but not all environments, especially those without iptables development files, have that file, hence this link error can happen.
By suggestion of Mike Frysinger, this patch uses libtool to produce and link the plugins.
---
Like this? We cannot really get rid of mentioning .libs without involving libltdl, and there I really do not want to go.
If you ask me, we should just move ipv6_prefix_length into libxtables.
extensions/GNUmakefile.in | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
extensions/GNUmakefile.in +10 -6
@@ -33,6 +33,7 @@ AM_VERBOSE_CXX = @echo " CXX " $@; AM_VERBOSE_CXXLD = @echo " CXXLD " $@; AM_VERBOSE_AR = @echo " AR " $@; AM_VERBOSE_GEN = @echo " GEN " $@; +AM_VERBOSE_NULL = @ endif #
@@ -75,7 +76,7 @@ install: ${targets_install} if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi; clean: - rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c; + rm -f *.la *.o *.lo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c; rm -f .*.d .*.dd; distclean: clean
@@ -89,11 +90,14 @@ init%.o: init%.c # # Shared libraries # -lib%.so: lib%.oo - ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD}; +lib%.so: lib%.la + ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@; -lib%.oo: ${srcdir}/lib%.c - ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; +lib%.la: lib%.lo + ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< -L../libxtables -lxtables ${$*_LIBADD} -rpath ${xtlibdir}; + +lib%.lo: ${srcdir}/lib%.c + ${AM_VERBOSE_CC} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=compile ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<; libxt_NOTRACK.so: libxt_CT.so ln -fs $< $@
@@ -101,7 +105,7 @@ libxt_state.so: libxt_conntrack.so ln -fs $< $@ # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD -ip6t_NETMAP_LIBADD = -lip6tc +ip6t_NETMAP_LIBADD = ../libiptc/libip6tc.la xt_RATEEST_LIBADD = -lm xt_statistic_LIBADD = -lm
Signature · 1 line
1.7.10.4
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
Quoted 2 lines · On Monday 31 December 2012 00:54:06 Jan Engelhardt wrote:
Like this? We cannot really get rid of mentioning .libs without involving libltdl, and there I really do not want to go.
why ? are the modules run directly out of the build tree, or you just need to install them ? libtool --mode=install can install an .la file ...
extensions/GNUmakefile.in init%.o: init%.c · line 94
Quoted 1 line
extensions/GNUmakefile.in +1
-0+ ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@;
i'm not sure why a lot of these rules have trailing semi-colons. they're pointless.
Quoted 3 lines
(quoted diff) +1
-0+ ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< -L../libxtables -lxtables ${$*_LIBADD} -rpath ${xtlibdir};
should be ../libxtables/libxtables.la rather than -L/-l for libxtables
Quoted 4 lines
libxt_NOTRACK.so: libxt_CT.so
ln -fs $< $@
libxt_state.so: libxt_conntrack.so
ln -fs $< $@
these two rules could use your new $AM_VERBOSE_NULL
otherwise, this is an improvement imo over the existing code -mike
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
Quoted 5 lines · Mike Frysinger
Quoted 2 lines · On Monday 31 December 2012 00:54:06 Jan Engelhardt wrote:
Like this? We cannot really get rid of mentioning .libs without involving libltdl, and there I really do not want to go.
why ? are the modules run directly out of the build tree,
Yes, one can run them out of the build tree; by using ./configure --with-xtlibdir=$PWD/extensions
Quoted 4 lines
extensions/GNUmakefile.in init%.o: init%.c · line 94
Quoted 1 line
extensions/GNUmakefile.in +1
-0+ ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@;i'm not sure why a lot of these rules have trailing semi-colons. they're pointless.
Hm must be a habit of doing other programming languages.
Quoted 16 lines
Quoted 3 lines
(quoted diff) +1
-0+ ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< -L../libxtables -lxtables ${$*_LIBADD} -rpath ${xtlibdir};
should be ../libxtables/libxtables.la rather than -L/-l for libxtables
Quoted 4 lines
libxt_NOTRACK.so: libxt_CT.so
ln -fs $< $@
libxt_state.so: libxt_conntrack.so
ln -fs $< $@these two rules could use your new $AM_VERBOSE_NULL
otherwise, this is an improvement imo over the existing code -mike
PATCH 1/1 build: resolve link failure for ip6t_NETMAP
Link stage of libip6t_NETMAP failed since recently.
CCLD libip6t_NETMAP.so/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
cannot find -lip6tc
libip6t_NETMAP.c uses the "ipv6_prefix_length" function from libip6tc.so; "-lip6tc" is used in the Makefile, but, the directory to it is not specified.
Why does the link succeed for some people? Because /usr/lib(64)/libip6tc.so satisfies -lip6tc, but not all environments, especially those without iptables development files, have that file, hence this link error can happen.
By suggestion of Mike Frysinger, this patch uses libtool to produce and link the plugins.
---
* use of ../libxtables/libxtables.la
extensions/GNUmakefile.in | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
extensions/GNUmakefile.in +12 -8
@@ -33,6 +33,7 @@ AM_VERBOSE_CXX = @echo " CXX " $@; AM_VERBOSE_CXXLD = @echo " CXXLD " $@; AM_VERBOSE_AR = @echo " AR " $@; AM_VERBOSE_GEN = @echo " GEN " $@; +AM_VERBOSE_NULL = @ endif #
@@ -75,7 +76,7 @@ install: ${targets_install} if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi; clean: - rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c; + rm -f *.la *.o *.lo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c; rm -f .*.d .*.dd; distclean: clean
@@ -89,19 +90,22 @@ init%.o: init%.c # # Shared libraries # -lib%.so: lib%.oo - ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD}; +lib%.so: lib%.la + ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@ -lib%.oo: ${srcdir}/lib%.c - ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; +lib%.la: lib%.lo + ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir} + +lib%.lo: ${srcdir}/lib%.c + ${AM_VERBOSE_CC} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=compile ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $< libxt_NOTRACK.so: libxt_CT.so - ln -fs $< $@ + ${AM_VERBOSE_GEN} ln -fs $< $@ libxt_state.so: libxt_conntrack.so - ln -fs $< $@ + ${AM_VERBOSE_GEN} ln -fs $< $@ # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD -ip6t_NETMAP_LIBADD = -lip6tc +ip6t_NETMAP_LIBADD = ../libiptc/libip6tc.la xt_RATEEST_LIBADD = -lm xt_statistic_LIBADD = -lm
Signature · 1 line
1.7.10.4
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
-mike
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
Quoted 1 line · Mike Frysinger
Acked-by Mike Frysinger <[email protected]>
Applied, thanks for your feedback Mike.
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
In reply to Jan EngelhardtHi,
On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
[...]
Quoted 2 lines
extensions/GNUmakefile.in +0
-0
[...]
extensions/GNUmakefile.in install: ${targets_install} · line 76
Quoted 2 lines
extensions/GNUmakefile.in +0
-0@@ -75,7 +76,7 @@ install: ${targets_install} if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
No, this is a regression. If ${targets_install} shared objects are made by libtool, they are intermediate files not expected to be installed by hand (due to funny RPATHs and so on), so they have to be installed by libtool --mode=install.
Something like
for f in $^; do ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 $${f/.so/.la} "${DESTDIR}${xtlibdir}/"; donewould work.
[...]
extensions/GNUmakefile.in init%.o: init%.c · line 97
Quoted 13 lines
extensions/GNUmakefile.in +4
-4@@ -89,19 +90,22 @@ init%.o: init%.c # # Shared libraries # -lib%.so: lib%.oo - ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD}; +lib%.so: lib%.la + ${AM_VERBOSE_NULL} ln -fs .libs/$@ $@ -lib%.oo: ${srcdir}/lib%.c - ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<; +lib%.la: lib%.lo + ${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir}
Please also add -avoid-version along with -module, otherwise it produces (and --mode=install installs) useless symlinks.
Signature · 1 line
ldv
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
Quoted 15 lines · Dmitry V. Levin
Hi,
On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
[...]Quoted 2 lines
extensions/GNUmakefile.in +0
-0[...]
extensions/GNUmakefile.in install: ${targets_install} · line 76
Quoted 2 lines
extensions/GNUmakefile.in +0
-0@@ -75,7 +76,7 @@ install: ${targets_install} if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;No, this is a regression. If ${targets_install} shared objects are made by libtool, they are intermediate files not expected to be installed by hand (due to funny RPATHs and so on), so they have to be installed by libtool --mode=install.
Quoted 3 lines
Something like
for f in $^; do ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 $${f/.so/.la} "${DESTDIR}${xtlibdir}/"; donewould work.
No, it didn't work because of ${pfx_symlinks} modules which are not libtool files. I've managed to build it with a more complex yet reliable rule:
for f in $^; do la="$${f/.so/.la}"; if test -f "$$la"; then ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 "$$la" "${DESTDIR}${xtlibdir}/"; elif test -L "$$f"; then cp -a "$$f" "${DESTDIR}${xtlibdir}/"; else exit 1; fi || exit; doneSignature · 1 line
ldv
Re: [PATCH] build: resolve link failure for ip6t_NETMAP
In reply to Dmitry V. LevinQuoted 5 lines · Dmitry V. Levin
On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
[...]Quoted 2 lines
extensions/GNUmakefile.in +0
-0[...]
Quoted 7 lines
extensions/GNUmakefile.in install: ${targets_install} · line 76
Quoted 2 lines
extensions/GNUmakefile.in +0
-0@@ -75,7 +76,7 @@ install: ${targets_install} if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;No, this is a regression. If ${targets_install} shared objects are made by libtool, they are intermediate files not expected to be installed by Please also add -avoid-version along with -module, otherwise it produces (and --mode=install installs) useless symlinks.
Already posted patches for those -
http://marc.info/?l=netfilter-devel&m=135783093113355&w=2