[PATCH 4 of 8 v6] make: move config system and version.h from hypervisor core to root

已查看 5 次
跳至第一个未读帖子

Henning Schild

未读,
2017年4月12日 07:38:212017/4/12
收件人 jailho...@googlegroups.com、Jan Kiszka、Ralf Ramsauer、Henning Schild
Move it up one level so the hypervisor core can make use of it
itself.

Signed-off-by: Henning Schild <henning...@siemens.com>
Tested-by: Ralf Ramsauer <ralf.r...@oth-regensburg.de>

diff --git a/Kbuild b/Kbuild
--- a/Kbuild
+++ b/Kbuild
@@ -1,7 +1,7 @@
#
# Jailhouse, a Linux-based partitioning hypervisor
#
-# Copyright (c) Siemens AG, 2013-2015
+# Copyright (c) Siemens AG, 2013-2017
#
# Authors:
# Jan Kiszka <jan.k...@siemens.com>
@@ -11,12 +11,40 @@
# the COPYING file in the top-level directory.
#

+define filechk_config_mk
+( \
+ echo "\$$(foreach config,\$$(filter CONFIG_%, \
+ \$$(.VARIABLES)), \$$(eval undefine \$$(config)))"; \
+ if [ -f $(src)/hypervisor/include/jailhouse/config.h ]; then \
+ sed -e "/^#define \([^[:space:]]*\)[[:space:]]*1/!d" \
+ -e "s/^#define \([^[:space:]]*\)[[:space:]]*1/\1=y/"\
+ $(src)/hypervisor/include/jailhouse/config.h; \
+ fi \
+)
+endef
+
+FILE_CONFIG_MK := $(obj)/hypervisor/include/generated/config.mk
+export FILE_CONFIG_MK
+$(FILE_CONFIG_MK): $(src)/Makefile FORCE
+ $(call filechk,config_mk)
+
+define filechk_version
+ $(src)/scripts/gen_version_h $(src)/
+endef
+
+FILE_VERSION_H := $(obj)/hypervisor/include/generated/version.h
+export FILE_VERSION_H
+$(FILE_VERSION_H): $(src)/Makefile FORCE
+ $(call filechk,version)
+
+FORCE:
+
subdir-y := driver hypervisor configs inmates tools

subdir-ccflags-y := -Werror

-# inmates build depends on generated config.mk of the hypervisor,
-# and the driver needs version.h from there
-$(obj)/inmates $(obj)/driver: $(obj)/hypervisor
+# directory dependencies on generated files
+$(obj)/driver $(obj)/hypervisor: $(FILE_VERSION_H)
+$(obj)/hypervisor $(obj)/inmates $(obj)/driver: $(FILE_CONFIG_MK)

-clean-dirs := Documentation/generated
+clean-dirs := Documentation/generated hypervisor/include/generated
diff --git a/driver/Makefile b/driver/Makefile
--- a/driver/Makefile
+++ b/driver/Makefile
@@ -20,7 +20,7 @@ jailhouse-y := cell.o main.o sysfs.o
jailhouse-$(CONFIG_PCI) += pci.o
jailhouse-$(CONFIG_OF) += vpci_template.dtb.o

-$(obj)/main.o: $(obj)/../hypervisor/include/generated/version.h
+$(obj)/main.o: $(FILE_VERSION_H)

targets += vpci_template.dtb vpci_template.dtb.S

diff --git a/hypervisor/Makefile b/hypervisor/Makefile
--- a/hypervisor/Makefile
+++ b/hypervisor/Makefile
@@ -1,7 +1,7 @@
#
# Jailhouse, a Linux-based partitioning hypervisor
#
-# Copyright (c) Siemens AG, 2013-2016
+# Copyright (c) Siemens AG, 2013-2017
# Copyright (c) Valentine Sinitsyn, 2014
#
# Authors:
@@ -35,26 +35,7 @@ GCOV_PROFILE := n
CORE_OBJECTS = setup.o printk.o paging.o control.o lib.o mmio.o pci.o ivshmem.o
CORE_OBJECTS += uart.o uart-8250.o

-define filechk_config_mk
-( \
- echo "\$$(foreach config,\$$(filter CONFIG_%, \
- \$$(.VARIABLES)), \$$(eval undefine \$$(config)))"; \
- if [ -f $(src)/include/jailhouse/config.h ]; then \
- sed -e "/^#define \([^[:space:]]*\)[[:space:]]*1/!d" \
- -e "s/^#define \([^[:space:]]*\)[[:space:]]*1/\1=y/" \
- $(src)/include/jailhouse/config.h; \
- fi \
-)
-endef
-
-$(obj)/include/generated/config.mk: Makefile FORCE
- $(call filechk,config_mk)
-
-define filechk_version
- $(src)/../scripts/gen_version_h $(src)/..
-endef
-
-clean-dirs := include/generated arch/$(SRCARCH)/include/generated
+clean-dirs := arch/$(SRCARCH)/include/generated

define sed-y
"/^=>/{s:=>#\(.*\):/* \1 */:; \
@@ -91,17 +72,13 @@ targets := $(defines-file) arch/$(SRCARC
$(Q)mkdir -p $(dir $@)
$(call cmd,defines)

-$(obj)/include/generated/version.h: $(src)/Makefile FORCE
- $(call filechk,version)
-
$(foreach co,$(CORE_OBJECTS),\
$(eval $(obj)/$(co): $(obj)/$(defines-file)))

-$(obj)/setup.o: $(obj)/include/generated/version.h
+$(obj)/setup.o: $(FILE_VERSION_H)

-arch-builtin: $(obj)/$(defines-file) $(obj)/include/generated/config.mk FORCE
- $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH) \
- CONFIG_MK=$(obj)/include/generated/config.mk
+arch-builtin: $(obj)/$(defines-file) FORCE
+ $(Q)$(MAKE) $(build)=$(obj)/arch/$(SRCARCH)

always :=

diff --git a/hypervisor/arch/arm-common/Kbuild b/hypervisor/arch/arm-common/Kbuild
--- a/hypervisor/arch/arm-common/Kbuild
+++ b/hypervisor/arch/arm-common/Kbuild
@@ -1,7 +1,7 @@
#
# Jailhouse, a Linux-based partitioning hypervisor
#
-# Copyright (c) Siemens AG, 2013-2016
+# Copyright (c) Siemens AG, 2013-2017
#
# Authors:
# Jan Kiszka <jan.k...@siemens.com>
@@ -10,7 +10,7 @@
# the COPYING file in the top-level directory.
#

-include $(CONFIG_MK)
+include $(FILE_CONFIG_MK)

GCOV_PROFILE := n

Jan Kiszka

未读,
2017年4月13日 02:01:242017/4/13
收件人 Henning Schild、jailho...@googlegroups.com、Ralf Ramsauer
On 2017-04-12 13:38, Henning Schild wrote:
> Move it up one level so the hypervisor core can make use of it
> itself.
>
> Signed-off-by: Henning Schild <henning...@siemens.com>
> Tested-by: Ralf Ramsauer <ralf.r...@oth-regensburg.de>
>

[side note: didn't you patch hg to produce diffstats?]
I would rather prefer GENERATED_CONFIG_MK and, for consistency,
GENERATED_VERSION_H. Leave a note on the changelog about this renaming
such as

"Rename CONFIG_MK var at this chance to avoid confusing it to be a
tunable itself. Chose a consistent name for VERSION_H as well."


> +$(FILE_CONFIG_MK): $(src)/Makefile FORCE
> + $(call filechk,config_mk)
> +
> +define filechk_version
> + $(src)/scripts/gen_version_h $(src)/
> +endef
> +
> +FILE_VERSION_H := $(obj)/hypervisor/include/generated/version.h
> +export FILE_VERSION_H
> +$(FILE_VERSION_H): $(src)/Makefile FORCE
> + $(call filechk,version)
> +
> +FORCE:
> +
> subdir-y := driver hypervisor configs inmates tools
>
> subdir-ccflags-y := -Werror
>
> -# inmates build depends on generated config.mk of the hypervisor,
> -# and the driver needs version.h from there
> -$(obj)/inmates $(obj)/driver: $(obj)/hypervisor
> +# directory dependencies on generated files
> +$(obj)/driver $(obj)/hypervisor: $(FILE_VERSION_H)
> +$(obj)/hypervisor $(obj)/inmates $(obj)/driver: $(FILE_CONFIG_MK)
>
> -clean-dirs := Documentation/generated
> +clean-dirs := Documentation/generated hypervisor/include/generated

Sorry, but there is still one cosmetic remaining: "make clean" checks
and generates the two files. I'm looking for a pattern that allows to
express the proper dependency without causing this, but maybe you have
an idea as well.

Yeah, surgeries on the build system are never simple...

Jan

--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

Jan Kiszka

未读,
2017年4月13日 05:30:192017/4/13
收件人 Henning Schild、jailho...@googlegroups.com、Ralf Ramsauer
Thought longer about it, but I couldn't find a good solution within the
kbuild system.

Things worked so far because we are breaking up the build in
hypervisor/Makefile so that the time of the architecture build is under
our control, but we can also define when the generated files are
produced (only on jailhouse*.bin build, not on other targets - such as
clean). We have to do the same now for all the directories that depend
on the generated files.

That is likely best done in the top-level Makefile, before we start
kbuild. And that will require importing the filechk macro, I suppose.

Henning Schild

未读,
2017年4月24日 04:42:552017/4/24
收件人 Jan Kiszka、jailho...@googlegroups.com、Ralf Ramsauer
Am Thu, 13 Apr 2017 08:01:23 +0200
schrieb Jan Kiszka <jan.k...@siemens.com>:

> On 2017-04-12 13:38, Henning Schild wrote:
> > Move it up one level so the hypervisor core can make use of it
> > itself.
> >
> > Signed-off-by: Henning Schild <henning...@siemens.com>
> > Tested-by: Ralf Ramsauer <ralf.r...@oth-regensburg.de>
> >
>
> [side note: didn't you patch hg to produce diffstats?]

Upstream was not happy with it, might try again some day. And i do not
want to carry around my own patches.

I guess the issues described in this thread are fixed in the series you
sent for 0.7?

Henning

Jan Kiszka

未读,
2017年4月24日 04:44:332017/4/24
收件人 Henning Schild、jailho...@googlegroups.com、Ralf Ramsauer
On 2017-04-24 10:43, Henning Schild wrote:
> Am Thu, 13 Apr 2017 08:01:23 +0200
> schrieb Jan Kiszka <jan.k...@siemens.com>:
>
>> On 2017-04-12 13:38, Henning Schild wrote:
>>> Move it up one level so the hypervisor core can make use of it
>>> itself.
>>>
>>> Signed-off-by: Henning Schild <henning...@siemens.com>
>>> Tested-by: Ralf Ramsauer <ralf.r...@oth-regensburg.de>
>>>
>>
>> [side note: didn't you patch hg to produce diffstats?]
>
> Upstream was not happy with it, might try again some day. And i do not
> want to carry around my own patches.

Too bad...

>
> I guess the issues described in this thread are fixed in the series you
> sent for 0.7?

They are supposed to. Cross-checking welcome.

Thanks,
回复全部
回复作者
转发
0 个新帖子