Message ID | 20170615173715.40882-2-mka@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
2017-06-16 2:37 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>: > cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines > whether an option is supported or not. This is fine for options used to > build the kernel itself, however some components like the x86 boot code > use a different set of flags. > > Add the new macro __cc-option which is a more generic version of > cc-option with additional parameters. One parameter is the compiler > with which the check should be performed, the other the compiler options > to be used instead KBUILD_C*FLAGS. > > Refactor cc-option and hostcc-option to use __cc-option and move > hostcc-option to scripts/Kbuild.include. > > Suggested-by: Arnd Bergmann <arnd@arndb.de> > Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Hi Matthias,
[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.12-rc5 next-20170616]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/kbuild-Add-__cc-option-macro/20170616-082252
config: sh-sh7710voipgw_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All errors (new ones prefixed by >>):
{standard input}: Assembler messages:
>> {standard input}:672: Error: invalid operands for opcode
{standard input}:673: Error: opcode not valid for this cpu variant
{standard input}:674: Error: opcode not valid for this cpu variant
{standard input}:675: Error: invalid operands for opcode
{standard input}:1900: Error: invalid operands for opcode
{standard input}:1901: Error: opcode not valid for this cpu variant
{standard input}:1902: Error: opcode not valid for this cpu variant
{standard input}:1903: Error: invalid operands for opcode
{standard input}:2067: Error: invalid operands for opcode
{standard input}:2068: Error: opcode not valid for this cpu variant
{standard input}:2069: Error: opcode not valid for this cpu variant
{standard input}:2070: Error: invalid operands for opcode
{standard input}:2570: Error: invalid operands for opcode
{standard input}:2571: Error: opcode not valid for this cpu variant
{standard input}:2572: Error: opcode not valid for this cpu variant
{standard input}:2573: Error: invalid operands for opcode
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Matthias, Sorry, the code I suggested introduced a slight behavior change. With this patch, cc-option adds a space before the returned option. Please see line 46 of arch/sh/Makefile. ifeq ($(cflags-y),) Now cflags-y contains a space, so this conditional is now evaluated as false, which was actually true without the patch. This is the cause of the build error. Could you remove whitespaces before $(1) and $(2) in cc-option? Also, please fix hostcc-option as well. Thanks! 2017-06-18 15:58 GMT+09:00 kbuild test robot <lkp@intel.com>: > Hi Matthias, > > [auto build test ERROR on tip/auto-latest] > [also build test ERROR on v4.12-rc5 next-20170616] > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > url: https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/kbuild-Add-__cc-option-macro/20170616-082252 > config: sh-sh7710voipgw_defconfig (attached as .config) > compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 > reproduce: > wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > make.cross ARCH=sh > > All errors (new ones prefixed by >>): > > {standard input}: Assembler messages: >>> {standard input}:672: Error: invalid operands for opcode > {standard input}:673: Error: opcode not valid for this cpu variant > {standard input}:674: Error: opcode not valid for this cpu variant > {standard input}:675: Error: invalid operands for opcode > {standard input}:1900: Error: invalid operands for opcode > {standard input}:1901: Error: opcode not valid for this cpu variant > {standard input}:1902: Error: opcode not valid for this cpu variant > {standard input}:1903: Error: invalid operands for opcode > {standard input}:2067: Error: invalid operands for opcode > {standard input}:2068: Error: opcode not valid for this cpu variant > {standard input}:2069: Error: opcode not valid for this cpu variant > {standard input}:2070: Error: invalid operands for opcode > {standard input}:2570: Error: invalid operands for opcode > {standard input}:2571: Error: opcode not valid for this cpu variant > {standard input}:2572: Error: opcode not valid for this cpu variant > {standard input}:2573: Error: invalid operands for opcode > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Masahiro, El Mon, Jun 19, 2017 at 11:00:42AM +0900 Masahiro Yamada ha dit: > Sorry, the code I suggested introduced a slight behavior change. > > With this patch, cc-option adds a space before the returned option. > > > Please see line 46 of arch/sh/Makefile. > > ifeq ($(cflags-y),) > > > Now cflags-y contains a space, so > this conditional is now evaluated as false, > which was actually true without the patch. > This is the cause of the build error. Thanks for looking into this, I also didn't realize that the extra space could be an issue. > Could you remove whitespaces before $(1) and $(2) in cc-option? > > Also, please fix hostcc-option as well. Sure, I'll send out a new version soon. > 2017-06-18 15:58 GMT+09:00 kbuild test robot <lkp@intel.com>: > > Hi Matthias, > > > > [auto build test ERROR on tip/auto-latest] > > [also build test ERROR on v4.12-rc5 next-20170616] > > [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] > > > > url: https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/kbuild-Add-__cc-option-macro/20170616-082252 > > config: sh-sh7710voipgw_defconfig (attached as .config) > > compiler: sh4-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 > > reproduce: > > wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > > chmod +x ~/bin/make.cross > > # save the attached .config to linux build tree > > make.cross ARCH=sh > > > > All errors (new ones prefixed by >>): > > > > {standard input}: Assembler messages: > >>> {standard input}:672: Error: invalid operands for opcode > > {standard input}:673: Error: opcode not valid for this cpu variant > > {standard input}:674: Error: opcode not valid for this cpu variant > > {standard input}:675: Error: invalid operands for opcode > > {standard input}:1900: Error: invalid operands for opcode > > {standard input}:1901: Error: opcode not valid for this cpu variant > > {standard input}:1902: Error: opcode not valid for this cpu variant > > {standard input}:1903: Error: invalid operands for opcode > > {standard input}:2067: Error: invalid operands for opcode > > {standard input}:2068: Error: opcode not valid for this cpu variant > > {standard input}:2069: Error: opcode not valid for this cpu variant > > {standard input}:2070: Error: invalid operands for opcode > > {standard input}:2570: Error: invalid operands for opcode > > {standard input}:2571: Error: opcode not valid for this cpu variant > > {standard input}:2572: Error: opcode not valid for this cpu variant > > {standard input}:2573: Error: invalid operands for opcode > > > > --- > > 0-DAY kernel test infrastructure Open Source Technology Center > > https://lists.01.org/pipermail/kbuild-all Intel Corporation > > > -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Makefile b/Makefile index 83f6d9972cab..b234bba6d652 100644 --- a/Makefile +++ b/Makefile @@ -303,7 +303,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ HOSTCC = gcc HOSTCXX = g++ -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 +HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 HOSTCXXFLAGS = -O2 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 61f87a99bf0a..5001bf9b6579 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -108,6 +108,11 @@ as-option = $(call try-run,\ as-instr = $(call try-run,\ printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) +# __cc-option +# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) +__cc-option = $(call try-run,\ + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) + # Do not attempt to build with gcc plugins during cc-option tests. # (And this uses delayed resolution so the flags will be up to date.) CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) @@ -115,8 +120,13 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # cc-option # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) -cc-option = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) +cc-option = $(call __cc-option, $(CC), $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),\ + $(1), $(2)) + +# hostcc-option +# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586) +hostcc-option = $(call __cc-option, $(HOSTCC),\ + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS), $(1), $(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 45b5b1aaedbd..9cfd5c84d76f 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -20,12 +20,6 @@ # Will compile qconf as a C++ program, and menu as a C program. # They are linked as C++ code to the executable qconf -# hostcc-option -# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586) - -hostcc-option = $(call try-run,\ - $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) - __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines whether an option is supported or not. This is fine for options used to build the kernel itself, however some components like the x86 boot code use a different set of flags. Add the new macro __cc-option which is a more generic version of cc-option with additional parameters. One parameter is the compiler with which the check should be performed, the other the compiler options to be used instead KBUILD_C*FLAGS. Refactor cc-option and hostcc-option to use __cc-option and move hostcc-option to scripts/Kbuild.include. Suggested-by: Arnd Bergmann <arnd@arndb.de> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Matthias Kaehlcke <mka@chromium.org> --- Changes in v3: - Changed the name of the new macro to __cc-option - Removed existing hostcc-option macro from scripts/Makefile.host - Added HOST_EXTRACFLAGS to hostcc-option - Updated commit message Makefile | 2 +- scripts/Kbuild.include | 14 ++++++++++++-- scripts/Makefile.host | 6 ------ 3 files changed, 13 insertions(+), 9 deletions(-)