Skip to contentSkip to conversation

locktes/rpcgen: tweak how we override compiler settings

PATCH In review Petr Vorel 3 participants 7 messages Jan 5, 2020 – Jan 20, 2020

Subsystems (2)
lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 locktes/rpcgen: tweak how we override compiler settings

From: Mike Frysinger <[email protected]>

Newer autotools will use both CFLAGS and <target>_CFLAGS when compiling the <target>. Adding the build settings to the target-specific flags no longer works as a way to compile build-time tools.

Instead, clobber the global flags. This triggers an automake warning, but the end result actually works (unlike the existing code).

---
Hi Steve,

this patch was sent by Mike in 2013 [1]. You had some objections about warnings it causes [2]. Although I understand it, I'd like it was merged, because it's needed (taken by distros: gentoo [3], buildroot [4]) and IMHO it cannot be implemented other way.

Also not sure, what should be changed in automake to avoid this tweek (I might ask upstream).

Kind regards,
Petr

[1] https://marc.info/?l=linux-nfs&m=136416341629788&w=2
[2] https://marc.info/?l=linux-nfs&m=136423027217638&w=2
[3] https://gitweb.gentoo.org/repo/gentoo.git/tree/net-fs/nfs-utils/files/nfs-utils-1.2.8-cross-build.patch
[4] https://git.busybox.net/buildroot/tree/package/nfs-utils/0001-Patch-taken-from-Gentoo.patch

 tools/locktest/Makefile.am | 7 +++----
 tools/rpcgen/Makefile.am   | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)
tools/locktest/Makefile.am +3 -4
index 3156815d..efe6fcdb 100644
@@ -1,12 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+CFLAGS=$(CFLAGS_FOR_BUILD)
+CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = testlk
 testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -4
index 8a9ec89c..3adeec15 100644
@@ -1,7 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+CFLAGS=$(CFLAGS_FOR_BUILD)
+CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = rpcgen
 rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,9 +11,6 @@ rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
 		 rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \
 		 rpc_scan.h rpc_util.h
 
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 rpcgen_LDADD=$(LIBTIRPC)
 
 MAINTAINERCLEANFILES = Makefile.in
Signature · 1 line
2.24.0
#1 lore raw
Quoted 23 lines · Petr Vorel

From: Mike Frysinger <[email protected]>

Newer autotools will use both CFLAGS and <target>_CFLAGS when compiling the <target>. Adding the build settings to the target-specific flags no longer works as a way to compile build-time tools.

Instead, clobber the global flags. This triggers an automake warning, but the end result actually works (unlike the existing code).

---
Hi Steve,

this patch was sent by Mike in 2013 [1]. You had some objections about warnings it causes [2]. Although I understand it, I'd like it was merged, because it's needed (taken by distros: gentoo [3], buildroot [4]) and IMHO it cannot be implemented other way.

Also not sure, what should be changed in automake to avoid this tweek (I might ask upstream).

Quoted 8 lines

Kind regards,
Petr

[1] https://marc.info/?l=linux-nfs&m=136416341629788&w=2
[2] https://marc.info/?l=linux-nfs&m=136423027217638&w=2
[3] https://gitweb.gentoo.org/repo/gentoo.git/tree/net-fs/nfs-utils/files/nfs-utils-1.2.8-cross-build.patch
[4] https://git.busybox.net/buildroot/tree/package/nfs-utils/0001-Patch-taken-from-Gentoo.patch

Yes I do remember the conversation.... So you are saying using AM_XXXX macros like the following patch does not take care of the problem?

tools/locktest/Makefile.am +3 -4
index 3156815..d5cf8da 100644
@@ -1,12 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = testlk
 testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -1
index 8a9ec89..4ef7278 100644
@@ -1,7 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD) ${TIRPC_CFLAGS}
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = rpcgen
 rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
#2 lore raw
Quoted 29 lines · Steve Dickson
Quoted 26 lines · Petr Vorel

From: Mike Frysinger <[email protected]>

Newer autotools will use both CFLAGS and <target>_CFLAGS when compiling the <target>. Adding the build settings to the target-specific flags no longer works as a way to compile build-time tools.

Instead, clobber the global flags. This triggers an automake warning, but the end result actually works (unlike the existing code).

---
Hi Steve,

this patch was sent by Mike in 2013 [1]. You had some objections about warnings it causes [2]. Although I understand it, I'd like it was merged, because it's needed (taken by distros: gentoo [3], buildroot [4]) and IMHO it cannot be implemented other way.

Also not sure, what should be changed in automake to avoid this tweek (I might ask upstream).

Kind regards,
Petr

Quoted 8 lines
Quoted 5 lines

[1] https://marc.info/?l=linux-nfs&m=136416341629788&w=2
[2] https://marc.info/?l=linux-nfs&m=136423027217638&w=2
[3] https://gitweb.gentoo.org/repo/gentoo.git/tree/net-fs/nfs-utils/files/nfs-utils-1.2.8-cross-build.patch
[4] https://git.busybox.net/buildroot/tree/package/nfs-utils/0001-Patch-taken-from-Gentoo.patch

Yes I do remember the conversation.... So you are saying using AM_XXXX macros like the following patch does not take care of the problem?

Actually try this one... the one that works! ;-)

tools/locktest/Makefile.am +3 -4
index 3156815..d5cf8da 100644
@@ -1,12 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = testlk
 testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -6
index 8a9ec89..84cafb2 100644
@@ -1,7 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD) ${TIRPC_CFLAGS}
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = rpcgen
 rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,11 +11,6 @@ rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
                 rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \
                 rpc_scan.h rpc_util.h
 
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
-rpcgen_LDADD=$(LIBTIRPC)
-
 MAINTAINERCLEANFILES = Makefile.in
 
 EXTRA_DIST = rpcgen.new.1
author
#3 lore raw

Hi Steve,

Quoted 39 lines

Actually try this one... the one that works! ;-)

tools/locktest/Makefile.am +3 -4
index 3156815..d5cf8da 100644
@@ -1,12 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = testlk
 testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -1
index 8a9ec89..84cafb2 100644
@@ -1,7 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD) ${TIRPC_CFLAGS}
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = rpcgen
 rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,11 +11,6 @@ rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
                 rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \

tools/rpcgen/Makefile.am rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ · line 16

Quoted 10 lines
tools/rpcgen/Makefile.am +0 -5
                 rpc_scan.h rpc_util.h
 
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
-rpcgen_LDADD=$(LIBTIRPC)
-
 MAINTAINERCLEANFILES = Makefile.in
 
 EXTRA_DIST = rpcgen.new.1

IMHO this one don't work for cross-compilation, tested on buildroot:

PATH="/br-test-pkg/br-arm-full-static/host/bin:/br-test-pkg/br-arm-full-static/host/sbin:/.common/bin/suse:/.local/bin:/.gem/ruby/2.2.0/bin:/bin/:~/.local/bin/:/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/home/pevik/.common/bin/suse:/home/pevik/bin/:~/.local/bin/:/home/pevik/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/X11R6/bin" /usr/bin/make -j9 -C /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/ make[1]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
Making all in tools
make[2]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools'
Making all in locktest
make[3]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest'
/usr/bin/gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/br-test-pkg/br-arm-full-static/host/include -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -c -o testlk.o testlk.c
/bin/sh ../../libtool --tag=CC --tag=CC --mode=link /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -L/br-test-pkg/br-arm-full-static/host/lib -Wl,-rpath,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o
libtool: link: /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -Wl,-rpath -Wl,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o -L/br-test-pkg/br-arm-full-static/host/lib
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:417: testlk] Error 1
make[3]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest'
make[2]: *** [Makefile:429: all-recursive] Error 1
make[2]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools'
make[1]: *** [Makefile:469: all-recursive] Error 1
make[1]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
make: *** [package/pkg-generic.mk:260: /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/.stamp_built] Error 2

I can send you more debug info, but IMHO Mike's patch is really needed.

Kind regards,
Petr

#4 lore raw
Quoted 54 lines · Petr Vorel

Hi Steve,

Quoted 39 lines

Actually try this one... the one that works! ;-)

tools/locktest/Makefile.am +3 -4
index 3156815..d5cf8da 100644
@@ -1,12 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = testlk
 testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -1
index 8a9ec89..84cafb2 100644
@@ -1,7 +1,9 @@
 ## Process this file with automake to produce Makefile.in
 
 CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD) ${TIRPC_CFLAGS}
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
 noinst_PROGRAMS = rpcgen
 rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,11 +11,6 @@ rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
                 rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \

tools/rpcgen/Makefile.am rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ · line 16

Quoted 10 lines
tools/rpcgen/Makefile.am +0 -5
                 rpc_scan.h rpc_util.h
 
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
-rpcgen_LDADD=$(LIBTIRPC)
-
 MAINTAINERCLEANFILES = Makefile.in
 
 EXTRA_DIST = rpcgen.new.1

IMHO this one don't work for cross-compilation, tested on buildroot:

Quoted 10 lines

PATH="/br-test-pkg/br-arm-full-static/host/bin:/br-test-pkg/br-arm-full-static/host/sbin:/.common/bin/suse:/.local/bin:/.gem/ruby/2.2.0/bin:/bin/:~/.local/bin/:/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/home/pevik/.common/bin/suse:/home/pevik/bin/:~/.local/bin/:/home/pevik/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/X11R6/bin" /usr/bin/make -j9 -C /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/ make[1]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
Making all in tools
make[2]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools'
Making all in locktest
make[3]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest'
/usr/bin/gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/br-test-pkg/br-arm-full-static/host/include -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -c -o testlk.o testlk.c
/bin/sh ../../libtool --tag=CC --tag=CC --mode=link /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -L/br-test-pkg/br-arm-full-static/host/lib -Wl,-rpath,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o
libtool: link: /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -Wl,-rpath -Wl,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o -L/br-test-pkg/br-arm-full-static/host/lib
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: cannot find -lc

Who/how is -lc getting specified? Maybe the problem is how $(LDFLAGS_FOR_BUILD) is being set?

Note... Giulio's patch is doing something similar
https://lore.kernel.org/linux-nfs/[email protected]/T/#u

Does something like that as well as setting the AM_XXX help the your cross-compile?

steved.

Quoted 14 lines

collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:417: testlk] Error 1
make[3]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest' make[2]: *** [Makefile:429: all-recursive] Error 1
make[2]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools' make[1]: *** [Makefile:469: all-recursive] Error 1
make[1]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
make: *** [package/pkg-generic.mk:260: /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/.stamp_built] Error 2

I can send you more debug info, but IMHO Mike's patch is really needed.

Kind regards,
Petr

#5 lore raw

Hi Steve, Petr,

Quoted 67 lines · Steve Dickson
Quoted 54 lines · Petr Vorel

Hi Steve,

Quoted 39 lines

Actually try this one... the one that works! ;-)

tools/locktest/Makefile.am +3 -4
index 3156815..d5cf8da 100644
@@ -1,12 +1,11 @@
  ## Process this file with automake to produce Makefile.in
 
  CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
  noinst_PROGRAMS = testlk
  testlk_SOURCES = testlk.c
-testlk_CFLAGS=$(CFLAGS_FOR_BUILD)
-testlk_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
-testlk_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
  MAINTAINERCLEANFILES = Makefile.in
tools/rpcgen/Makefile.am +3 -1
index 8a9ec89..84cafb2 100644
@@ -1,7 +1,9 @@
  ## Process this file with automake to produce Makefile.in
 
  CC=$(CC_FOR_BUILD)
-LIBTOOL = @LIBTOOL@ --tag=CC
+AM_CFLAGS=$(CFLAGS_FOR_BUILD) ${TIRPC_CFLAGS}
+AM_CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
 
  noinst_PROGRAMS = rpcgen
  rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
@@ -9,11 +11,6 @@ rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \
                  rpc_util.c rpc_sample.c rpc_output.h rpc_parse.h \

tools/rpcgen/Makefile.am rpcgen_SOURCES = rpc_clntout.c rpc_cout.c rpc_hout.c rpc_main.c \ · line 16

Quoted 10 lines
tools/rpcgen/Makefile.am +0 -5
                  rpc_scan.h rpc_util.h
 
-rpcgen_CFLAGS=$(CFLAGS_FOR_BUILD)
-rpcgen_CPPLAGS=$(CPPFLAGS_FOR_BUILD)
-rpcgen_LDFLAGS=$(LDFLAGS_FOR_BUILD)
-rpcgen_LDADD=$(LIBTIRPC)
-
  MAINTAINERCLEANFILES = Makefile.in
 
  EXTRA_DIST = rpcgen.new.1

IMHO this one don't work for cross-compilation, tested on buildroot:

Quoted 10 lines

PATH="/br-test-pkg/br-arm-full-static/host/bin:/br-test-pkg/br-arm-full-static/host/sbin:/.common/bin/suse:/.local/bin:/.gem/ruby/2.2.0/bin:/bin/:~/.local/bin/:/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/home/pevik/.common/bin/suse:/home/pevik/bin/:~/.local/bin/:/home/pevik/.common/bin/:~/.vim/bin/:/usr/sbin/:/sbin/:/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/X11R6/bin" /usr/bin/make -j9 -C /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/ make[1]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
Making all in tools
make[2]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools'
Making all in locktest
make[3]: Entering directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest'
/usr/bin/gcc -DHAVE_CONFIG_H -I. -I../../support/include -I/br-test-pkg/br-arm-full-static/host/include -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -c -o testlk.o testlk.c
/bin/sh ../../libtool --tag=CC --tag=CC --mode=link /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -L/br-test-pkg/br-arm-full-static/host/lib -Wl,-rpath,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o
libtool: link: /usr/bin/gcc -O2 -I/br-test-pkg/br-arm-full-static/host/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -Wl,-rpath -Wl,/br-test-pkg/br-arm-full-static/host/lib -static -o testlk testlk.o -L/br-test-pkg/br-arm-full-static/host/lib
/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: cannot find -lc

Quoted 6 lines

Who/how is -lc getting specified? Maybe the problem is how $(LDFLAGS_FOR_BUILD) is being set?

Note... Giulio's patch is doing something similar
https://lore.kernel.org/linux-nfs/[email protected]/T/#u

Does something like that as well as setting the AM_XXX help the your cross-compile?

IMHO tools/* utility must be built with cross-compiler too, not with /usr/bin/gcc. Buildroot provide host-nfs-utils for that, especially for rpcgen.

Please take a look at my WIP patch for bumping nfs-utils to latest in Buildroot:
https://github.com/giuliobenetti/buildroot/commit/12671eb21d62a5474dc476381015069382775668

and please note this line:
--with-rpcgen=$(HOST_DIR)/bin/rpcgen

that means that nfs-utils must use already host-nfs-utils/rpcgen instead of internal one to generate rpcs. This is why tools/* is not needed as host to build target. Indeed host-nfs-utils is built when nfs-utils is built. At least I understand this.

Can you Petr confirm that?
Because at this point the patch you're pointing is not needed.

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 18 lines

steved.

Quoted 14 lines

collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:417: testlk] Error 1
make[3]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools/locktest' make[2]: *** [Makefile:429: all-recursive] Error 1
make[2]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/tools' make[1]: *** [Makefile:469: all-recursive] Error 1
make[1]: Leaving directory '/br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4'
make: *** [package/pkg-generic.mk:260: /br-test-pkg/br-arm-full-static/build/nfs-utils-1.3.4/.stamp_built] Error 2

I can send you more debug info, but IMHO Mike's patch is really needed.

Kind regards,
Petr

author
#6 lore raw

Hi Giulio, Steve,

Quoted 16 lines
Quoted 4 lines

Note... Giulio's patch is doing something similar
https://lore.kernel.org/linux-nfs/[email protected]/T/#u

Does something like that as well as setting the AM_XXX help the your cross-compile?

IMHO tools/* utility must be built with cross-compiler too, not with /usr/bin/gcc. Buildroot provide host-nfs-utils for that, especially for rpcgen.

Please take a look at my WIP patch for bumping nfs-utils to latest in Buildroot:
https://github.com/giuliobenetti/buildroot/commit/12671eb21d62a5474dc476381015069382775668

and please note this line:
--with-rpcgen=$(HOST_DIR)/bin/rpcgen

Quoted 7 lines

that means that nfs-utils must use already host-nfs-utils/rpcgen instead of internal one to generate rpcs. This is why tools/* is not needed as host to build target. Indeed host-nfs-utils is built when nfs-utils is built. At least I understand this.

Can you Petr confirm that?
Because at this point the patch you're pointing is not needed.

Sorry, I overlooked this mail. Ack, it's correct for buildroot, as I already wrote yesterday.
But not sure if the patch isn't needed for Gentoo packaging.
I guess if needed, it still can be rebased and applied later.

Kind regards,
Petr