Hi Dmitry, On Wed, Nov 16, 2016 at 8:27 PM, Dmitry V. Levin <l...@altlinux.org> wrote: > 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. >
Thanks for the suggestion. I tried implementing it but got stuck. What I observe is that the second invocation of ST_WARN_CFLAGS is using cached results, which should not happen because the compiler can be different. Looking at the definition of gl_WARN_ADD, I think that the cache_id of the AC_CACHE_CHECK call in gl_COMPILER_OPTION_IF should contain CC or a similar variable, so that caching does not happen. I'm sending what I have for now below. commit 535960a637b2b8db85170ede95e8471abf9bd2e2 Author: Thomas De Schampheleire <thomas.de_schamphele...@nokia.com> Date: Thu Oct 13 15:40:31 2016 +0200 Makefile.am: don't confuse CFLAGS and CFLAGS_FOR_BUILD 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. diff --git a/Makefile.am b/Makefile.am index 69dd2be..460a1d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,6 +52,8 @@ AM_CPPFLAGS = -I$(builddir)/$(OS)/$(ARCH) \ -I$(srcdir)/$(OS) \ -I$(builddir) \ -I$(srcdir) +AM_CFLAGS_FOR_BUILD = $(WARN_CFLAGS_FOR_BUILD) +AM_CPPFLAGS_FOR_BUILD = $(AM_CPPFLAGS) include xlat/Makemodule.am @@ -793,9 +795,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)) diff --git a/configure.ac b/configure.ac index 61dcf15..a5f50ee 100644 --- a/configure.ac +++ b/configure.ac @@ -251,27 +251,7 @@ esac AC_DEFINE_UNQUOTED([ENABLE_ARM_OABI], [$enable_arm_oabi], [Define to 1 if you want OABI support on ARM EABI.]) -gl_WARN_ADD([-Wall]) -gl_WARN_ADD([-Wempty-body]) -gl_WARN_ADD([-Wformat-security]) -gl_WARN_ADD([-Wignored-qualifiers]) -gl_WARN_ADD([-Winit-self]) -gl_WARN_ADD([-Wlogical-op]) -gl_WARN_ADD([-Wmissing-parameter-type]) -gl_WARN_ADD([-Wnested-externs]) -gl_WARN_ADD([-Wold-style-declaration]) -gl_WARN_ADD([-Wold-style-definition]) -gl_WARN_ADD([-Wsign-compare]) -gl_WARN_ADD([-Wtype-limits]) -gl_WARN_ADD([-Wwrite-strings]) -AC_ARG_ENABLE([gcc-Werror], - [AS_HELP_STRING([--enable-gcc-Werror], [turn on gcc's -Werror option])], - [case $enableval in - yes) gl_WARN_ADD([-Werror]) ;; - no) ;; - *) AC_MSG_ERROR([bad value $enableval for gcc-Werror option]) ;; - esac] -) +st_WARN_CFLAGS AC_SUBST([WARN_CFLAGS]) AC_C_BIGENDIAN diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4 index 77fd346..5520553 100644 --- a/m4/ax_prog_cc_for_build.m4 +++ b/m4/ax_prog_cc_for_build.m4 @@ -57,6 +57,7 @@ pushdef([CPP], CPP_FOR_BUILD)dnl pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl +pushdef([WARN_CFLAGS], WARN_CFLAGS_FOR_BUILD)dnl pushdef([host], build)dnl pushdef([host_alias], build_alias)dnl pushdef([host_cpu], build_cpu)dnl @@ -80,6 +81,8 @@ AC_PROG_CC AC_PROG_CPP AC_EXEEXT +st_WARN_CFLAGS + ac_tool_prefix=$save_ac_tool_prefix cross_compiling=$save_cross_compiling @@ -98,6 +101,7 @@ popdef([host_vendor])dnl popdef([host_cpu])dnl popdef([host_alias])dnl popdef([host])dnl +popdef([WARN_CFLAGS])dnl popdef([LDFLAGS])dnl popdef([CPPFLAGS])dnl popdef([CFLAGS])dnl @@ -122,4 +126,5 @@ AC_SUBST(BUILD_OBJEXT)dnl AC_SUBST([CFLAGS_FOR_BUILD])dnl AC_SUBST([CPPFLAGS_FOR_BUILD])dnl AC_SUBST([LDFLAGS_FOR_BUILD])dnl +AC_SUBST([WARN_CFLAGS_FOR_BUILD])dnl ]) diff --git a/m4/st_WARN_CFLAGS.m4 b/m4/st_WARN_CFLAGS.m4 new file mode 100644 index 0000000..6034714 --- /dev/null +++ b/m4/st_WARN_CFLAGS.m4 @@ -0,0 +1,23 @@ +AC_DEFUN([st_WARN_CFLAGS], [dnl +gl_WARN_ADD([-Wall]) +gl_WARN_ADD([-Wempty-body]) +gl_WARN_ADD([-Wformat-security]) +gl_WARN_ADD([-Wignored-qualifiers]) +gl_WARN_ADD([-Winit-self]) +gl_WARN_ADD([-Wlogical-op]) +gl_WARN_ADD([-Wmissing-parameter-type]) +gl_WARN_ADD([-Wnested-externs]) +gl_WARN_ADD([-Wold-style-declaration]) +gl_WARN_ADD([-Wold-style-definition]) +gl_WARN_ADD([-Wsign-compare]) +gl_WARN_ADD([-Wtype-limits]) +gl_WARN_ADD([-Wwrite-strings]) +AC_ARG_ENABLE([gcc-Werror], + [AS_HELP_STRING([--enable-gcc-Werror], [turn on gcc's -Werror option])], + [case $enableval in + yes) gl_WARN_ADD([-Werror]) ;; + no) ;; + *) AC_MSG_ERROR([bad value $enableval for gcc-Werror option]) ;; + esac] +) +]) Any help is appreciated (or feel free to take over based on the above if you prefer). Thanks, Thomas ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today.http://sdm.link/xeonphi _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel