xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars
@ 2019-09-05 14:48 Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 1/4] build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk Roger Pau Monne
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Roger Pau Monne @ 2019-09-05 14:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich, Doug Goldstein, Roger Pau Monne

Hello,

Current Xen build system will ignore any toolchain related variables on
the environment when building (ie: CC, LD, CXX...), and the only way to
set those is to assign them directly on the make command line (ie: make
CC=foo CXX=bar ...).

The following series attempts to fix this, by removing the hardcoding of
the toolchain variables previously done in StdGNU.mk.

Note that this has the side effect that the build system will no longer
prepend CROSS_COMPILE to the toolchain variables if those are already
set. So if you are building Xen and setting CROSS_COMPILE make sure
toolchain variables are unset, or if set they should contain
CROSS_COMPILE. The Travis CI script is updated in patch 3/4 in order to
comply with the above.

This is v2 because v1 was missing the first patch, rendering the whole
series useless. Apart from that there are no changes from v1.

The series can be found at:

git://xenbits.xen.org/people/royger/xen.git env_tools

Results from Travis and gitlab CI loops are at:

https://travis-ci.org/royger/xen/builds/581139388
https://gitlab.com/xen-project/people/royger/xen/pipelines/80440648

Thanks, Roger.

Roger Pau Monne (4):
  build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk
  kconfig: include default toolchain values
  build: allow picking the env values for compiler variables
  build: allow picking the env values for toolchain utilities

 Config.mk                          | 18 ----------
 config/StdGNU.mk                   | 53 ++++++++++++++++++++----------
 scripts/travis-build               |  8 +++++
 xen/Makefile                       |  6 ++--
 xen/tools/kconfig/Makefile.kconfig |  7 ++--
 5 files changed, 50 insertions(+), 42 deletions(-)

-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Xen-devel] [PATCH v2 1/4] build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk
  2019-09-05 14:48 [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars Roger Pau Monne
@ 2019-09-05 14:48 ` Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 2/4] kconfig: include default toolchain values Roger Pau Monne
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monne @ 2019-09-05 14:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich, Roger Pau Monne

This is a preparatory change for simplifying the setting of
HOST{CC/CXX} and allowing the Xen build system to pick the toolchain
variables from the environment.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
---
 Config.mk        | 18 ------------------
 config/StdGNU.mk | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/Config.mk b/Config.mk
index 0fa4591379..57a6c934b3 100644
--- a/Config.mk
+++ b/Config.mk
@@ -39,24 +39,6 @@ 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))))
 DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
 
diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 039274ea61..7a6159021b 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -1,14 +1,30 @@
+# Use Clang/LLVM instead of GCC?
+clang     ?= n
+
+# 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
+
 AS         = $(CROSS_COMPILE)as
 LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
+gcc       := n
 CC         = $(CROSS_COMPILE)clang
 CXX        = $(CROSS_COMPILE)clang++
 LD_LTO     = $(CROSS_COMPILE)llvm-ld
+HOSTCC    ?= clang
+HOSTCXX   ?= clang++
 else
+gcc       := y
 CC         = $(CROSS_COMPILE)gcc
 CXX        = $(CROSS_COMPILE)g++
 LD_LTO     = $(CROSS_COMPILE)ld
+HOSTCC    ?= gcc
+HOSTCXX   ?= g++
 endif
+
 CPP        = $(CC) -E
 AR         = $(CROSS_COMPILE)ar
 RANLIB     = $(CROSS_COMPILE)ranlib
-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Xen-devel] [PATCH v2 2/4] kconfig: include default toolchain values
  2019-09-05 14:48 [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 1/4] build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk Roger Pau Monne
@ 2019-09-05 14:48 ` Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 3/4] build: allow picking the env values for compiler variables Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 4/4] build: allow picking the env values for toolchain utilities Roger Pau Monne
  3 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monne @ 2019-09-05 14:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich, Doug Goldstein, 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 or to default them to
gcc/g++ if unset.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
Cc: Doug Goldstein <cardoe@cardoe.com>
---
 xen/Makefile                       | 6 +++---
 xen/tools/kconfig/Makefile.kconfig | 7 +++----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index c80914c31d..e9f700f9e7 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -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 ARCH=$(ARCH) SRCARCH=$(SRCARCH) $@
 
 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 ARCH=$(ARCH) SRCARCH=$(SRCARCH) 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 ARCH=$(ARCH) SRCARCH=$(SRCARCH) defconfig
 
 # Break the dependency chain for the first run
 include/config/auto.conf.cmd: ;
diff --git a/xen/tools/kconfig/Makefile.kconfig b/xen/tools/kconfig/Makefile.kconfig
index dbd8912015..138bf3f1b7 100644
--- a/xen/tools/kconfig/Makefile.kconfig
+++ b/xen/tools/kconfig/Makefile.kconfig
@@ -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
-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Xen-devel] [PATCH v2 3/4] build: allow picking the env values for compiler variables
  2019-09-05 14:48 [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 1/4] build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 2/4] kconfig: include default toolchain values Roger Pau Monne
@ 2019-09-05 14:48 ` Roger Pau Monne
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 4/4] build: allow picking the env values for toolchain utilities Roger Pau Monne
  3 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monne @ 2019-09-05 14:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Doug Goldstein, Tim Deegan,
	Julien Grall, Jan Beulich, Ian Jackson, Roger Pau Monne

Don't force the usage of the hardcoded compiler values if those are
already set on the environment. This allows the Xen build system to
correctly pick CC/CXX values present on the environment, and fixes the
usage of those by the Gitlab CI test system.

Note that without this fix the Xen build system will completely ignore
any CC or CXX values set on the environment, and the only way to pass
a different CC or CXX is to overwrite it on the make command line.

Due to this change, Travis CI needs to be updated in order to pass a
CC and CXX that also contains the CROSS_COMPILE path, since Xen will
no longer overwrite the CC or CXX value if those are set on the
environment.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
---
 config/StdGNU.mk     | 35 +++++++++++++++++++----------------
 scripts/travis-build |  8 ++++++++
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index 7a6159021b..b3072f5b13 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -1,28 +1,31 @@
 # Use Clang/LLVM instead of GCC?
 clang     ?= n
 
-# 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
-
 AS         = $(CROSS_COMPILE)as
 LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
 gcc       := n
-CC         = $(CROSS_COMPILE)clang
-CXX        = $(CROSS_COMPILE)clang++
-LD_LTO     = $(CROSS_COMPILE)llvm-ld
-HOSTCC    ?= clang
-HOSTCXX   ?= clang++
+DEF_CC     = clang
+DEF_CXX    = clang++
+LD_LTO    ?= $(CROSS_COMPILE)llvm-ld
 else
 gcc       := y
-CC         = $(CROSS_COMPILE)gcc
-CXX        = $(CROSS_COMPILE)g++
-LD_LTO     = $(CROSS_COMPILE)ld
-HOSTCC    ?= gcc
-HOSTCXX   ?= g++
+DEF_CC     = gcc
+DEF_CXX    = g++
+LD_LTO    ?= $(CROSS_COMPILE)ld
+endif
+
+CC        ?= $(CROSS_COMPILE)$(DEF_CC)
+CXX       ?= $(CROSS_COMPILE)$(DEF_CXX)
+
+# If we are not cross-compiling, default HOSTC{C/XX} to C{C/XX}
+# else use the default values if unset
+ifeq ($(XEN_TARGET_ARCH), $(XEN_COMPILE_ARCH))
+HOSTCC    ?= $(CC)
+HOSTCXX   ?= $(CXX)
+else
+HOSTCC    ?= $(DEF_CC)
+HOSTCXX   ?= $(DEF_CXX)
 endif
 
 CPP        = $(CC) -E
diff --git a/scripts/travis-build b/scripts/travis-build
index 0cb15a89e4..a264e286b2 100755
--- a/scripts/travis-build
+++ b/scripts/travis-build
@@ -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
-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Xen-devel] [PATCH v2 4/4] build: allow picking the env values for toolchain utilities
  2019-09-05 14:48 [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars Roger Pau Monne
                   ` (2 preceding siblings ...)
  2019-09-05 14:48 ` [Xen-devel] [PATCH v2 3/4] build: allow picking the env values for compiler variables Roger Pau Monne
@ 2019-09-05 14:48 ` Roger Pau Monne
  3 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monne @ 2019-09-05 14:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich, Roger Pau Monne

Don't force the usage of the hardcoded toolchain values if those are
already set on the environment.

Note that as part of the change the definition of AS and LD is moved
after the setting of compiler related variables.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wl@xen.org>
---
 config/StdGNU.mk | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/config/StdGNU.mk b/config/StdGNU.mk
index b3072f5b13..cab7369f12 100644
--- a/config/StdGNU.mk
+++ b/config/StdGNU.mk
@@ -1,8 +1,6 @@
 # Use Clang/LLVM instead of GCC?
 clang     ?= n
 
-AS         = $(CROSS_COMPILE)as
-LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
 gcc       := n
 DEF_CC     = clang
@@ -28,19 +26,21 @@ HOSTCC    ?= $(DEF_CC)
 HOSTCXX   ?= $(DEF_CXX)
 endif
 
-CPP        = $(CC) -E
-AR         = $(CROSS_COMPILE)ar
-RANLIB     = $(CROSS_COMPILE)ranlib
-NM         = $(CROSS_COMPILE)nm
-STRIP      = $(CROSS_COMPILE)strip
-OBJCOPY    = $(CROSS_COMPILE)objcopy
-OBJDUMP    = $(CROSS_COMPILE)objdump
-SIZEUTIL   = $(CROSS_COMPILE)size
+AS        ?= $(CROSS_COMPILE)as
+LD        ?= $(CROSS_COMPILE)ld
+CPP       ?= $(CC) -E
+AR        ?= $(CROSS_COMPILE)ar
+RANLIB    ?= $(CROSS_COMPILE)ranlib
+NM        ?= $(CROSS_COMPILE)nm
+STRIP     ?= $(CROSS_COMPILE)strip
+OBJCOPY   ?= $(CROSS_COMPILE)objcopy
+OBJDUMP   ?= $(CROSS_COMPILE)objdump
+SIZEUTIL  ?= $(CROSS_COMPILE)size
 
 # Allow git to be wrappered in the environment
 GIT        ?= git
 
-INSTALL      = install
+INSTALL     ?= install
 INSTALL_DIR  = $(INSTALL) -d -m0755 -p
 INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_PROG = $(INSTALL) -m0755 -p
-- 
2.22.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-05 14:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 14:48 [Xen-devel] [PATCH v2 0/4] build: honor toolchain related environment vars Roger Pau Monne
2019-09-05 14:48 ` [Xen-devel] [PATCH v2 1/4] build: set HOST{CC/CXX}, clang and gcc in StdGNU.mk Roger Pau Monne
2019-09-05 14:48 ` [Xen-devel] [PATCH v2 2/4] kconfig: include default toolchain values Roger Pau Monne
2019-09-05 14:48 ` [Xen-devel] [PATCH v2 3/4] build: allow picking the env values for compiler variables Roger Pau Monne
2019-09-05 14:48 ` [Xen-devel] [PATCH v2 4/4] build: allow picking the env values for toolchain utilities Roger Pau Monne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).