[PATCH] Makefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD

Thomas De Schampheleire patrickdepinguin at gmail.com
Tue Oct 18 11:42:44 UTC 2016


From: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>

Commit dc427d50d96b15c9a64d7e78d97ce4d194622a63 enabled a number of extra
warning flags through configure.ac. The configure script will determine
dynamically if CC supports these flags before adding them to WARN_CFLAGS.

ioctlsort is compiled with CC_FOR_BUILD, rather than CC. Nevertheless, the
flags passed to this compilation also include WARN_CFLAGS (through
AM_CFLAGS). This is incorrect: in a cross-compilation use case, CC and
CC_FOR_BUILD are not the same. The former is the cross-compiler,
the latter is the host compiler. Both may be of different versions and
support different warning flags.

In particular, this posed a problem when cross-compiling with a host
compiler gcc 4.1, which does not support all the new flags:

    /usr/bin/gcc -DHAVE_CONFIG_H   -I./linux/arm -I./linux/arm -I./linux
    -I./linux -I. -I. -I/host-sysroot/usr/include -Wall -Wempty-body
    -Wformat-security -Wignored-qualifiers -Winit-self -Wlogical-op
    -Wmissing-parameter-type -Wnested-externs -Wold-style-declaration
    -Wold-style-definition -Wsign-compare -Wtype-limits -Wwrite-strings -O2
    -I/host-sysroot/usr/include -DIOCTLSORT_INC=\"ioctls_all0.h\" -c -o
    ioctlsort0.o ./ioctlsort.c
    cc1: error: unrecognized command line option "-Wempty-body"
    cc1: error: unrecognized command line option "-Wignored-qualifiers"
    cc1: error: unrecognized command line option "-Wlogical-op"
    cc1: error: unrecognized command line option "-Wmissing-parameter-type"
    cc1: error: unrecognized command line option "-Wold-style-declaration"
    cc1: error: unrecognized command line option "-Wtype-limits"
    make[2]: *** [ioctlsort0.o] Error 1

Fix by introducing AM_C/CPP/LDFLAGS_FOR_BUILD which are empty by default.
Only AM_CPPFLAGS_FOR_BUILD actually needs to be filled for now, based on
AM_CPPFLAGS.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
---
 Makefile.am | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d1ad1fe..98dda88 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,6 +52,7 @@ AM_CPPFLAGS = -I$(builddir)/$(OS)/$(ARCH) \
 	      -I$(srcdir)/$(OS) \
 	      -I$(builddir) \
 	      -I$(srcdir)
+AM_CPPFLAGS_FOR_BUILD = $(AM_CPPFLAGS)
 
 include xlat/Makemodule.am
 
@@ -720,9 +721,9 @@ news-check: NEWS
 ioctlsort_CC = $(CC_FOR_BUILD)
 ioctlsort_DEFS = $(DEFS)
 ioctlsort_INCLUDES = $(DEFAULT_INCLUDES) $(INCLUDES)
-ioctlsort_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_FOR_BUILD)
-ioctlsort_CFLAGS = $(AM_CFLAGS) $(CFLAGS_FOR_BUILD)
-ioctlsort_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD)
+ioctlsort_CPPFLAGS = $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD)
+ioctlsort_CFLAGS = $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+ioctlsort_LDFLAGS = $(AM_LDFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD)
 
 ioctls_inc_h = $(wildcard $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h)
 ioctlent_h = $(patsubst $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%,ioctlent%,$(ioctls_inc_h))
-- 
2.7.3





More information about the Strace-devel mailing list