Skip to contentSkip to conversation

build improvements/fixes after b41666f2c1

PATCH In review Roger Pau Monne 3 participants 9 messages Jun 26, 2019

lore
Share & tools
lore
#0 lore raw

cover build improvements/fixes after b41666f2c1

Hello,

The following fixes arise from the travis-ci fallout caused by b41666f2c1 ('config: don't hardcode toolchain binaries'). First patches aim to simplify and group together the place where toolchain binaries to be used by the build system. Last patch changes the travis-ci build script to accommodate the changes introduced by b41666f2c1.

Thanks, Roger.

Roger Pau Monne (5):
make: simplify setting HOST{CC/CXX}
kconfig: don't pass ARCH and SRCARCH on the sub-make call
kconfig: include default toolchain values
kconfig: disable non-literal format string warnings
travis: pass a correct CC/CXX if CROSS_COMPILE is defined

 Config.mk                          | 10 ----------
 config/StdGNU.mk                   |  4 ++++
 scripts/travis-build               |  8 ++++++++
 xen/Makefile                       | 10 +++++-----
 xen/tools/kconfig/Makefile.kconfig | 12 ++++++++----
 5 files changed, 25 insertions(+), 19 deletions(-)
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 1/5 make: simplify setting HOST{CC/CXX}

Infer the values of HOST{CC/CXX} from CC/CXX if unset, do this in StdGNU.mk, together with the rest of the toolchain variables.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 Config.mk        | 10 ----------
 config/StdGNU.mk |  4 ++++
 2 files changed, 4 insertions(+), 10 deletions(-)
Config.mk +0 -10
index 417039d7f6..1a1cc09881 100644
@@ -39,22 +39,12 @@ DESTDIR     ?= /
 # Allow phony attribute to be listed as dependency rather than fake target
 .PHONY: .phony
 
-# If we are not cross-compiling, default HOSTC{C/XX} to C{C/XX}
-ifeq ($(XEN_TARGET_ARCH), $(XEN_COMPILE_ARCH))
-HOSTCC ?= $(CC)
-HOSTCXX ?= $(CXX)
-endif
-
 # Use Clang/LLVM instead of GCC?
 clang ?= n
 ifeq ($(clang),n)
 gcc := y
-HOSTCC ?= gcc
-HOSTCXX ?= g++
 else
 gcc := n
-HOSTCC ?= clang
-HOSTCXX ?= clang++
 endif
 
 DEPS_INCLUDE = $(addsuffix .d2, $(basename $(wildcard $(DEPS))))
config/StdGNU.mk +4 -0
index 490ebdf23c..7b7dfe0440 100644
@@ -9,6 +9,10 @@ CC        ?= $(CROSS_COMPILE)gcc
 CXX       ?= $(CROSS_COMPILE)g++
 LD_LTO    ?= $(CROSS_COMPILE)ld
 endif
+
+HOSTCC    ?= $(CC)
+HOSTCXX   ?= $(CXX)
+
 CPP       ?= $(CC) -E
 AR        ?= $(CROSS_COMPILE)ar
 RANLIB    ?= $(CROSS_COMPILE)ranlib
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

PATCH 2/5 kconfig: don't pass ARCH and SRCARCH on the sub-make call

In reply to Roger Pau Monne

and instead export them from the top-level Xen makefile.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/Makefile | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/Makefile +5 -5
index c80914c31d..3e3d08d1cc 100644
@@ -21,8 +21,8 @@ MAKEFLAGS += -rR
 
 EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi
 
-ARCH=$(XEN_TARGET_ARCH)
-SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g')
+export ARCH=$(XEN_TARGET_ARCH)
+export SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g')
 
 # Don't break if the build process wasn't called from the top level
 # we need XEN_TARGET_ARCH to generate the proper config
@@ -267,14 +267,14 @@ kconfig := silentoldconfig oldconfig config menuconfig defconfig \
 	randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig))
 .PHONY: $(kconfig)
 $(kconfig):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
 
 include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG)
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" silentoldconfig
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" silentoldconfig
 
 # Allow people to just run `make` as before and not force them to configure
 $(KCONFIG_CONFIG):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig
 
 # Break the dependency chain for the first run
 include/config/auto.conf.cmd: ;
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH 3/5 kconfig: include default toolchain values

In reply to Roger Pau Monne

Include config/$(OS).mk which contains the default values for the toolchain variables. This removes the need to pass HOST{CC/CXX} as parameters from the high level make target.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Doug Goldstein <[email protected]>

---
 xen/Makefile                       | 6 +++---
 xen/tools/kconfig/Makefile.kconfig | 7 +++----
 2 files changed, 6 insertions(+), 7 deletions(-)
xen/Makefile +3 -3
index 3e3d08d1cc..620af7883c 100644
@@ -267,14 +267,14 @@ kconfig := silentoldconfig oldconfig config menuconfig defconfig \
 	randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig))
 .PHONY: $(kconfig)
 $(kconfig):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig $@
 
 include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG)
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" silentoldconfig
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig silentoldconfig
 
 # Allow people to just run `make` as before and not force them to configure
 $(KCONFIG_CONFIG):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig defconfig
 
 # Break the dependency chain for the first run
 include/config/auto.conf.cmd: ;
xen/tools/kconfig/Makefile.kconfig +3 -4
index dbd8912015..138bf3f1b7 100644
@@ -35,15 +35,14 @@ KBUILD_DEFCONFIG := $(ARCH)_defconfig
 # provide our shell
 CONFIG_SHELL := $(SHELL)
 
-# provide the host compiler
-HOSTCC ?= gcc
-HOSTCXX ?= g++
-
 # force target
 PHONY += FORCE
 
 FORCE:
 
+# Sets toolchain binaries to use
+include $(XEN_ROOT)/config/$(shell uname -s).mk
+
 # include the original Makefile and Makefile.host from Linux
 include $(src)/Makefile
 include $(src)/Makefile.host
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#4 lore raw

PATCH 4/5 kconfig: disable non-literal format string warnings

In reply to Roger Pau Monne

Kconfig makes heavy use of non-literals as format strings, disable compiler warnings since this is expected usage.

---
Cc: Doug Goldstein <[email protected]>

---
 xen/tools/kconfig/Makefile.kconfig | 5 +++++
 1 file changed, 5 insertions(+)
xen/tools/kconfig/Makefile.kconfig +5 -0
index 138bf3f1b7..763de37a14 100644
@@ -43,6 +43,11 @@ FORCE:
 # Sets toolchain binaries to use
 include $(XEN_ROOT)/config/$(shell uname -s).mk
 
+# Disable format warnings, kconfig makes heavy use of non-literal format
+# strings.
+HOSTCFLAGS += -Wno-format
+HOSTCXXFLAGS += -Wno-format
+
 # include the original Makefile and Makefile.host from Linux
 include $(src)/Makefile
 include $(src)/Makefile.host
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

Re: [Xen-devel] [PATCH 4/5] kconfig: disable non-literal format string warnings

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 26.06.19 at 15:55, <[email protected]> wrote:

Kconfig makes heavy use of non-literals as format strings, disable compiler warnings since this is expected usage.

I've never seen any with any version of gcc - are there more aspects to be mentioned here?

Quoted 6 lines

---
Cc: Doug Goldstein <[email protected]>

---
 xen/tools/kconfig/Makefile.kconfig | 5 +++++
 1 file changed, 5 insertions(+)

You Cc list looks to be too short for this change.

xen/tools/kconfig/Makefile.kconfig FORCE: · line 49

Quoted 10 lines
xen/tools/kconfig/Makefile.kconfig +4 -0
@@ -43,6 +43,11 @@ FORCE:
 # Sets toolchain binaries to use
 include $(XEN_ROOT)/config/$(shell uname -s).mk
 
+# Disable format warnings, kconfig makes heavy use of non-literal format
+# strings.
+HOSTCFLAGS += -Wno-format
+HOSTCXXFLAGS += -Wno-format

But this disables far more warnings than ones for non-literal format strings, at least afaict.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw

Re: [Xen-devel] [PATCH 4/5] kconfig: disable non-literal format string warnings

Quoted 6 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 26.06.19 at 15:55, <[email protected]> wrote:

Kconfig makes heavy use of non-literals as format strings, disable compiler warnings since this is expected usage.

I've never seen any with any version of gcc - are there more aspects to be mentioned here?

Oh, I've always seen them with clang. Not sure why gcc doesn't show such warnings.

clang -Wp,-MD,tools/kconfig/.conf.o.d -DCURSES_LOC="<ncurses.h>" -DLOCALE -DKBUILD_NO_NLS -c -o tools/kconfig/conf.o tools/kconfig/conf.c
tools/kconfig/conf.c:77:10: warning: format string is not a string literal (potentially insecure)

      [-Wformat-security]
                printf(_("aborted!\n\n"));
                       ^~~~~~~~~~~~~~~~~
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^~~~~~~~~~~~~
tools/kconfig/conf.c:77:10: note: treat the string as an argument to avoid this
                printf(_("aborted!\n\n"));
                       ^
                       "%s",
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^
tools/kconfig/conf.c:78:10: warning: format string is not a string literal (potentially insecure)
      [-Wformat-security]
                printf(_("Console input/output is redirected. "));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^~~~~~~~~~~~~
tools/kconfig/conf.c:78:10: note: treat the string as an argument to avoid this
                printf(_("Console input/output is redirected. "));
                       ^
                       "%s",
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^

[...]

Quoted 9 lines
Quoted 7 lines

---
Cc: Doug Goldstein <[email protected]>

---
 xen/tools/kconfig/Makefile.kconfig | 5 +++++
 1 file changed, 5 insertions(+)

You Cc list looks to be too short for this change.

That's what get_maintainer.pl has given me. Maybe the syntax in MAINTAINERS is not correct, or get_maintainer.pl needs adjustments.

Quoted 7 lines
Quoted 7 lines
xen/tools/kconfig/Makefile.kconfig +0 -0
@@ -43,6 +43,11 @@ FORCE:
 # Sets toolchain binaries to use
 include $(XEN_ROOT)/config/$(shell uname -s).mk
 
Quoted 7 lines

xen/tools/kconfig/Makefile.kconfig FORCE: · line 49

Quoted 4 lines
xen/tools/kconfig/Makefile.kconfig +4 -0
+# Disable format warnings, kconfig makes heavy use of non-literal format
+# strings.
+HOSTCFLAGS += -Wno-format
+HOSTCXXFLAGS += -Wno-format

But this disables far more warnings than ones for non-literal format strings, at least afaict.

Sorry, it should be -Wno-format-security. I think I dropped the -security part while copying.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw

Re: [Xen-devel] [PATCH 4/5] kconfig: disable non-literal format string warnings

Quoted 30 lines · Roger Pau Monné
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 26.06.19 at 15:55, <[email protected]> wrote:

Kconfig makes heavy use of non-literals as format strings, disable compiler warnings since this is expected usage.

I've never seen any with any version of gcc - are there more aspects to be mentioned here?

Oh, I've always seen them with clang. Not sure why gcc doesn't show such warnings.

clang -Wp,-MD,tools/kconfig/.conf.o.d -DCURSES_LOC="<ncurses.h>" -DLOCALE -DKBUILD_NO_NLS -c -o tools/kconfig/conf.o tools/kconfig/conf.c
tools/kconfig/conf.c:77:10: warning: format string is not a string literal (potentially insecure)

      [-Wformat-security]
                printf(_("aborted!\n\n"));
                       ^~~~~~~~~~~~~~~~~
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^~~~~~~~~~~~~
tools/kconfig/conf.c:77:10: note: treat the string as an argument to avoid this
                printf(_("aborted!\n\n"));
                       ^
                       "%s",
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^
tools/kconfig/conf.c:78:10: warning: format string is not a string literal (potentially insecure)
      [-Wformat-security]
                printf(_("Console input/output is redirected. "));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
Quoted 8 lines
                ^~~~~~~~~~~~~
tools/kconfig/conf.c:78:10: note: treat the string as an argument to avoid this
                printf(_("Console input/output is redirected. "));
                       ^
                       "%s",
tools/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^

Clang is correct and GCC is wrong.  This code is plain buggy.

Its trivial to arrange for gettext to return a string with a % in it.

These want fixing to "%s", _(), or to use puts().

It looks like Linux has dropped the use of gettext in the first place. Look like c/s 694c49a7c01cc87194be40cb26404b58b68c291c wants backporting.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

PATCH 5/5 travis: pass a correct CC/CXX if CROSS_COMPILE is defined

In reply to Roger Pau Monne

After b41666f2c1 Xen no longer overwrites the names of the build toolchain utilities required during the build process, and instead uses the values from the environment.

In that case, if the user wants to define CC or other variables to point to specific toolchain utilities to use it must also take into account that such variables must be prefixed with CROSS_COMPILE, since Xen will no longer do this.

Fixes b41666f2c1 ('config: don't hardcode toolchain binaries')

---
Cc: Doug Goldstein <[email protected]>

---
 scripts/travis-build | 8 ++++++++
 1 file changed, 8 insertions(+)
scripts/travis-build +8 -0
index 0cb15a89e4..a264e286b2 100755
@@ -1,6 +1,14 @@
 #!/bin/bash -ex
 
+# Set HOST{CC/CXX} in case we are cross building
+export HOSTCC=${CC}
+export HOSTCXX=${CXX}
+# Prefix environment CC/CXX with CROSS_COMPILE if present
+export CC=${CROSS_COMPILE}${CC}
+export CXX=${CROSS_COMPILE}${CXX}
+
 $CC --version
+[[ "${CC}" != "${HOSTCC}" ]] && $HOSTCC --version
 
 # random config or default config
 if [[ "${RANDCONFIG}" == "y" ]]; then
Signature · 7 lines
2.20.1 (Apple Git-117)


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel