Hi,

On Tue, Oct 18, 2016 at 01:42:44PM +0200, Thomas De Schampheleire wrote:
> From: Thomas De Schampheleire <thomas.de_schamphele...@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_schamphele...@nokia.com>

Good catch.  Unfortunately, the change you propose also strips all
WARN_CFLAGS from the build of ioctlsort executable, which is certainly
not what we want.

The correct fix is going to be more complex, e.g.
- move all gl_WARN_ADD/WARN_CFLAGS related code from configure.ac to a
  separate m4 macro, say st_WARN_CFLAGS;
- call st_WARN_CFLAGS in configure.ac;
- modify AX_PROG_CC_FOR_BUILD to
  + pushdef WARN_CFLAGS to WARN_CFLAGS_FOR_BUILD,
  + call st_WARN_CFLAGS,
  + popdef WARN_CFLAGS back,
  + AC_SUBST WARN_CFLAGS_FOR_BUILD;
- add WARN_CFLAGS_FOR_BUILD to AM_CFLAGS_FOR_BUILD.

> --- 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))

-- 
ldv

Attachment: pgp5CemMB5Cal.pgp
Description: PGP signature

------------------------------------------------------------------------------
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to