Message ID | 96b2a4ff48578b7b105581529d2aa6bebd8ad622.1693583721.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | introduce stub directory to storing empty/stub headers | expand |
Hi Oleksii, > On 1 Sep 2023, at 18:02, Oleksii Kurochko <oleksii.kurochko@gmail.com> wrote: > > Some headers are shared between individual architectures or are empty. > To avoid duplication of these headers, asm-generic is introduced. > > With the following patch, an architecture uses generic headers > mentioned in the file arch/$(ARCH)/include/asm/Kbuild. Kbuild refers to "Kernel build" I guess. I am ok to keep that name to keep things simpler when compared to Linux scripts but it would be good to mention that in the commit message for future reference. > > To use a generic header is needed to add to > arch/$(ARCH)/include/asm/Kbuild : > generic-y += <name-of-header-file.h> > > For each mentioned header in arch/$(ARCH)/include/asm/Kbuild, > kbuild will generate the necessary wrapper in > arch/$(ARCH)/include/generated/asm. > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > --- > Changes in V4: > - introduce asm-generic support > - update commit message > --- > Changes in V3: > - Rename stubs dir to asm-generic > --- > Changes in V2: > - Nothing changed. > --- > xen/Makefile | 10 +++++++++- > xen/arch/arm/include/asm/Kbuild | 1 + > xen/arch/ppc/include/asm/Kbuild | 1 + > xen/arch/riscv/include/asm/Kbuild | 1 + > xen/arch/x86/include/asm/Kbuild | 1 + > xen/scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++ > 6 files changed, 36 insertions(+), 1 deletion(-) > create mode 100644 xen/arch/arm/include/asm/Kbuild > create mode 100644 xen/arch/ppc/include/asm/Kbuild > create mode 100644 xen/arch/riscv/include/asm/Kbuild > create mode 100644 xen/arch/x86/include/asm/Kbuild > create mode 100644 xen/scripts/Makefile.asm-generic > > diff --git a/xen/Makefile b/xen/Makefile > index f57e5a596c..698d6ddeb8 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -438,6 +438,7 @@ ifdef building_out_of_srctree > endif > CFLAGS += -I$(srctree)/include > CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include > +CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include/generated Why are we generating files in the source tree ? Shouldn't we keep it unmodified ? > > # Note that link order matters! > ALL_OBJS-y := common/built_in.o > @@ -580,6 +581,7 @@ _clean: > rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf $(TARGET).efi.stripped > rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h > rm -f .banner .allconfig.tmp include/xen/compile.h > + rm -rf arch/*/include/generated > You must use the same as for CFLAGS here so $(srctree) would be needed. (or something else depending on the fix for previous comment) > .PHONY: _distclean > _distclean: clean > @@ -589,7 +591,7 @@ $(TARGET).gz: $(TARGET) > gzip -n -f -9 < $< > $@.new > mv $@.new $@ > > -$(TARGET): outputmakefile FORCE > +$(TARGET): outputmakefile asm-generic FORCE > $(Q)$(MAKE) $(build)=tools > $(Q)$(MAKE) $(build)=. include/xen/compile.h > $(Q)$(MAKE) $(build)=include all > @@ -667,6 +669,12 @@ endif # need-sub-make > PHONY += FORCE > FORCE: > > +# Support for using generic headers in asm-generic > +PHONY += asm-generic > +asm-generic: > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ > + obj=arch/$(SRCARCH)/include/generated/asm > + > # Declare the contents of the PHONY variable as phony. We keep that > # information in a variable so we can use it in if_changed and friends. > .PHONY: $(PHONY) > diff --git a/xen/arch/arm/include/asm/Kbuild b/xen/arch/arm/include/asm/Kbuild > new file mode 100644 > index 0000000000..a4e40e534e > --- /dev/null > +++ b/xen/arch/arm/include/asm/Kbuild > @@ -0,0 +1 @@ > +# SPDX-License-Identifier: GPL-2.0-only > diff --git a/xen/arch/ppc/include/asm/Kbuild b/xen/arch/ppc/include/asm/Kbuild > new file mode 100644 > index 0000000000..a4e40e534e > --- /dev/null > +++ b/xen/arch/ppc/include/asm/Kbuild > @@ -0,0 +1 @@ > +# SPDX-License-Identifier: GPL-2.0-only > diff --git a/xen/arch/riscv/include/asm/Kbuild b/xen/arch/riscv/include/asm/Kbuild > new file mode 100644 > index 0000000000..a4e40e534e > --- /dev/null > +++ b/xen/arch/riscv/include/asm/Kbuild > @@ -0,0 +1 @@ > +# SPDX-License-Identifier: GPL-2.0-only > diff --git a/xen/arch/x86/include/asm/Kbuild b/xen/arch/x86/include/asm/Kbuild > new file mode 100644 > index 0000000000..a4e40e534e > --- /dev/null > +++ b/xen/arch/x86/include/asm/Kbuild > @@ -0,0 +1 @@ > +# SPDX-License-Identifier: GPL-2.0-only > diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic > new file mode 100644 > index 0000000000..0aac3f50b8 > --- /dev/null > +++ b/xen/scripts/Makefile.asm-generic > @@ -0,0 +1,23 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# include/asm-generic contains a lot of files that are used > +# verbatim by several architectures. > +# > +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild > +# and for each file listed in this file with generic-y creates > +# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) > + > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > +include $(kbuild-file) > + > +include scripts/Kbuild.include > + > +# Create output directory if not already present > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > + > +quiet_cmd_wrap = WRAP $@ > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > + > +all: $(patsubst %, $(obj)/%, $(generic-y)) > + > +$(obj)/%.h: > + $(call cmd,wrap) In fact i think your files are not generated in the srctree so this will break if you use out of tree compilation. Cheers Bertrand > -- > 2.41.0 >
Hi Bertrand, On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: > Hi Oleksii, > > > On 1 Sep 2023, at 18:02, Oleksii Kurochko > > <oleksii.kurochko@gmail.com> wrote: > > > > Some headers are shared between individual architectures or are > > empty. > > To avoid duplication of these headers, asm-generic is introduced. > > > > With the following patch, an architecture uses generic headers > > mentioned in the file arch/$(ARCH)/include/asm/Kbuild. > > Kbuild refers to "Kernel build" I guess. > I am ok to keep that name to keep things simpler when compared to > Linux scripts but it would be good to mention that in the commit > message for future reference. Sure. I'll add that Kbuild refers to "Kernel build" > > > > > To use a generic header is needed to add to > > arch/$(ARCH)/include/asm/Kbuild : > > generic-y += <name-of-header-file.h> > > > > For each mentioned header in arch/$(ARCH)/include/asm/Kbuild, > > kbuild will generate the necessary wrapper in > > arch/$(ARCH)/include/generated/asm. > > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > --- > > Changes in V4: > > - introduce asm-generic support > > - update commit message > > --- > > Changes in V3: > > - Rename stubs dir to asm-generic > > --- > > Changes in V2: > > - Nothing changed. > > --- > > xen/Makefile | 10 +++++++++- > > xen/arch/arm/include/asm/Kbuild | 1 + > > xen/arch/ppc/include/asm/Kbuild | 1 + > > xen/arch/riscv/include/asm/Kbuild | 1 + > > xen/arch/x86/include/asm/Kbuild | 1 + > > xen/scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++ > > 6 files changed, 36 insertions(+), 1 deletion(-) > > create mode 100644 xen/arch/arm/include/asm/Kbuild > > create mode 100644 xen/arch/ppc/include/asm/Kbuild > > create mode 100644 xen/arch/riscv/include/asm/Kbuild > > create mode 100644 xen/arch/x86/include/asm/Kbuild > > create mode 100644 xen/scripts/Makefile.asm-generic > > > > diff --git a/xen/Makefile b/xen/Makefile > > index f57e5a596c..698d6ddeb8 100644 > > --- a/xen/Makefile > > +++ b/xen/Makefile > > @@ -438,6 +438,7 @@ ifdef building_out_of_srctree > > endif > > CFLAGS += -I$(srctree)/include > > CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include > > +CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include/generated > > Why are we generating files in the source tree ? > Shouldn't we keep it unmodified ? I think you are right. I got myself confused because I do not use out-of-tree compilation so for me it looked like $(srctree). It would be better to use $(objtree) instead. > > > > > # Note that link order matters! > > ALL_OBJS-y := common/built_in.o > > @@ -580,6 +581,7 @@ _clean: > > rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf > > $(TARGET).efi.stripped > > rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h > > rm -f .banner .allconfig.tmp include/xen/compile.h > > + rm -rf arch/*/include/generated > > > > You must use the same as for CFLAGS here so $(srctree) would be > needed. > (or something else depending on the fix for previous comment) Thanks. I'll change to the value mentioned in CFLAGS. > > > .PHONY: _distclean > > _distclean: clean > > @@ -589,7 +591,7 @@ $(TARGET).gz: $(TARGET) > > gzip -n -f -9 < $< > $@.new > > mv $@.new $@ > > > > -$(TARGET): outputmakefile FORCE > > +$(TARGET): outputmakefile asm-generic FORCE > > $(Q)$(MAKE) $(build)=tools > > $(Q)$(MAKE) $(build)=. include/xen/compile.h > > $(Q)$(MAKE) $(build)=include all > > @@ -667,6 +669,12 @@ endif # need-sub-make > > PHONY += FORCE > > FORCE: > > > > +# Support for using generic headers in asm-generic > > +PHONY += asm-generic > > +asm-generic: > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ > > + obj=arch/$(SRCARCH)/include/generated/asm > > + > > # Declare the contents of the PHONY variable as phony. We keep > > that > > # information in a variable so we can use it in if_changed and > > friends. > > .PHONY: $(PHONY) > > diff --git a/xen/arch/arm/include/asm/Kbuild > > b/xen/arch/arm/include/asm/Kbuild > > new file mode 100644 > > index 0000000000..a4e40e534e > > --- /dev/null > > +++ b/xen/arch/arm/include/asm/Kbuild > > @@ -0,0 +1 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > diff --git a/xen/arch/ppc/include/asm/Kbuild > > b/xen/arch/ppc/include/asm/Kbuild > > new file mode 100644 > > index 0000000000..a4e40e534e > > --- /dev/null > > +++ b/xen/arch/ppc/include/asm/Kbuild > > @@ -0,0 +1 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > diff --git a/xen/arch/riscv/include/asm/Kbuild > > b/xen/arch/riscv/include/asm/Kbuild > > new file mode 100644 > > index 0000000000..a4e40e534e > > --- /dev/null > > +++ b/xen/arch/riscv/include/asm/Kbuild > > @@ -0,0 +1 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > diff --git a/xen/arch/x86/include/asm/Kbuild > > b/xen/arch/x86/include/asm/Kbuild > > new file mode 100644 > > index 0000000000..a4e40e534e > > --- /dev/null > > +++ b/xen/arch/x86/include/asm/Kbuild > > @@ -0,0 +1 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > diff --git a/xen/scripts/Makefile.asm-generic > > b/xen/scripts/Makefile.asm-generic > > new file mode 100644 > > index 0000000000..0aac3f50b8 > > --- /dev/null > > +++ b/xen/scripts/Makefile.asm-generic > > @@ -0,0 +1,23 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +# include/asm-generic contains a lot of files that are used > > +# verbatim by several architectures. > > +# > > +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild > > +# and for each file listed in this file with generic-y creates > > +# a small wrapper file in $(obj) > > (arch/$(SRCARCH)/include/generated/asm) > > + > > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > > +include $(kbuild-file) > > + > > +include scripts/Kbuild.include > > + > > +# Create output directory if not already present > > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > > + > > +quiet_cmd_wrap = WRAP $@ > > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > > + > > +all: $(patsubst %, $(obj)/%, $(generic-y)) > > + > > +$(obj)/%.h: > > + $(call cmd,wrap) > > In fact i think your files are not generated in the srctree so this > will break if you use out of tree compilation. Why not? They will be generated in $obj which equal to obj=arch/$(SRCARCH)/include/generated/asm ( in my case ). Anyway I think that obj should be equal to what is mentioned in CFLAGS. ~ Oleksii
Hi Oleksii, > On 5 Sep 2023, at 15:37, Oleksii <oleksii.kurochko@gmail.com> wrote: > > Hi Bertrand, > > On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: >> Hi Oleksii, >> >>> On 1 Sep 2023, at 18:02, Oleksii Kurochko >>> <oleksii.kurochko@gmail.com> wrote: >>> >>> Some headers are shared between individual architectures or are >>> empty. >>> To avoid duplication of these headers, asm-generic is introduced. >>> >>> With the following patch, an architecture uses generic headers >>> mentioned in the file arch/$(ARCH)/include/asm/Kbuild. >> >> Kbuild refers to "Kernel build" I guess. >> I am ok to keep that name to keep things simpler when compared to >> Linux scripts but it would be good to mention that in the commit >> message for future reference. > Sure. I'll add that Kbuild refers to "Kernel build" >> >>> >>> To use a generic header is needed to add to >>> arch/$(ARCH)/include/asm/Kbuild : >>> generic-y += <name-of-header-file.h> >>> >>> For each mentioned header in arch/$(ARCH)/include/asm/Kbuild, >>> kbuild will generate the necessary wrapper in >>> arch/$(ARCH)/include/generated/asm. >>> >>> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> >>> --- >>> Changes in V4: >>> - introduce asm-generic support >>> - update commit message >>> --- >>> Changes in V3: >>> - Rename stubs dir to asm-generic >>> --- >>> Changes in V2: >>> - Nothing changed. >>> --- >>> xen/Makefile | 10 +++++++++- >>> xen/arch/arm/include/asm/Kbuild | 1 + >>> xen/arch/ppc/include/asm/Kbuild | 1 + >>> xen/arch/riscv/include/asm/Kbuild | 1 + >>> xen/arch/x86/include/asm/Kbuild | 1 + >>> xen/scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++ >>> 6 files changed, 36 insertions(+), 1 deletion(-) >>> create mode 100644 xen/arch/arm/include/asm/Kbuild >>> create mode 100644 xen/arch/ppc/include/asm/Kbuild >>> create mode 100644 xen/arch/riscv/include/asm/Kbuild >>> create mode 100644 xen/arch/x86/include/asm/Kbuild >>> create mode 100644 xen/scripts/Makefile.asm-generic >>> >>> diff --git a/xen/Makefile b/xen/Makefile >>> index f57e5a596c..698d6ddeb8 100644 >>> --- a/xen/Makefile >>> +++ b/xen/Makefile >>> @@ -438,6 +438,7 @@ ifdef building_out_of_srctree >>> endif >>> CFLAGS += -I$(srctree)/include >>> CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include >>> +CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include/generated >> >> Why are we generating files in the source tree ? >> Shouldn't we keep it unmodified ? > I think you are right. > I got myself confused because I do not use out-of-tree compilation so > for me it looked like $(srctree). > > It would be better to use $(objtree) instead. Ack >> >>> >>> # Note that link order matters! >>> ALL_OBJS-y := common/built_in.o >>> @@ -580,6 +581,7 @@ _clean: >>> rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf >>> $(TARGET).efi.stripped >>> rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h >>> rm -f .banner .allconfig.tmp include/xen/compile.h >>> + rm -rf arch/*/include/generated >>> >> >> You must use the same as for CFLAGS here so $(srctree) would be >> needed. >> (or something else depending on the fix for previous comment) > Thanks. I'll change to the value mentioned in CFLAGS. > >> >>> .PHONY: _distclean >>> _distclean: clean >>> @@ -589,7 +591,7 @@ $(TARGET).gz: $(TARGET) >>> gzip -n -f -9 < $< > $@.new >>> mv $@.new $@ >>> >>> -$(TARGET): outputmakefile FORCE >>> +$(TARGET): outputmakefile asm-generic FORCE >>> $(Q)$(MAKE) $(build)=tools >>> $(Q)$(MAKE) $(build)=. include/xen/compile.h >>> $(Q)$(MAKE) $(build)=include all >>> @@ -667,6 +669,12 @@ endif # need-sub-make >>> PHONY += FORCE >>> FORCE: >>> >>> +# Support for using generic headers in asm-generic >>> +PHONY += asm-generic >>> +asm-generic: >>> + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ >>> + obj=arch/$(SRCARCH)/include/generated/asm >>> + >>> # Declare the contents of the PHONY variable as phony. We keep >>> that >>> # information in a variable so we can use it in if_changed and >>> friends. >>> .PHONY: $(PHONY) >>> diff --git a/xen/arch/arm/include/asm/Kbuild >>> b/xen/arch/arm/include/asm/Kbuild >>> new file mode 100644 >>> index 0000000000..a4e40e534e >>> --- /dev/null >>> +++ b/xen/arch/arm/include/asm/Kbuild >>> @@ -0,0 +1 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> diff --git a/xen/arch/ppc/include/asm/Kbuild >>> b/xen/arch/ppc/include/asm/Kbuild >>> new file mode 100644 >>> index 0000000000..a4e40e534e >>> --- /dev/null >>> +++ b/xen/arch/ppc/include/asm/Kbuild >>> @@ -0,0 +1 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> diff --git a/xen/arch/riscv/include/asm/Kbuild >>> b/xen/arch/riscv/include/asm/Kbuild >>> new file mode 100644 >>> index 0000000000..a4e40e534e >>> --- /dev/null >>> +++ b/xen/arch/riscv/include/asm/Kbuild >>> @@ -0,0 +1 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> diff --git a/xen/arch/x86/include/asm/Kbuild >>> b/xen/arch/x86/include/asm/Kbuild >>> new file mode 100644 >>> index 0000000000..a4e40e534e >>> --- /dev/null >>> +++ b/xen/arch/x86/include/asm/Kbuild >>> @@ -0,0 +1 @@ >>> +# SPDX-License-Identifier: GPL-2.0-only >>> diff --git a/xen/scripts/Makefile.asm-generic >>> b/xen/scripts/Makefile.asm-generic >>> new file mode 100644 >>> index 0000000000..0aac3f50b8 >>> --- /dev/null >>> +++ b/xen/scripts/Makefile.asm-generic >>> @@ -0,0 +1,23 @@ >>> +# SPDX-License-Identifier: GPL-2.0 >>> +# include/asm-generic contains a lot of files that are used >>> +# verbatim by several architectures. >>> +# >>> +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild >>> +# and for each file listed in this file with generic-y creates >>> +# a small wrapper file in $(obj) >>> (arch/$(SRCARCH)/include/generated/asm) >>> + >>> +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild >>> +include $(kbuild-file) >>> + >>> +include scripts/Kbuild.include >>> + >>> +# Create output directory if not already present >>> +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) >>> + >>> +quiet_cmd_wrap = WRAP $@ >>> +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ >>> + >>> +all: $(patsubst %, $(obj)/%, $(generic-y)) >>> + >>> +$(obj)/%.h: >>> + $(call cmd,wrap) >> >> In fact i think your files are not generated in the srctree so this >> will break if you use out of tree compilation. > Why not? They will be generated in $obj which equal to > obj=arch/$(SRCARCH)/include/generated/asm ( in my case ). Right they are generated in the build tree but if it is not the same as srctree it will not work due to CFLAGS. > > Anyway I think that obj should be equal to what is mentioned in CFLAGS. We generate other files like asm-offsets.h and it could in fact be that both srctree and build tree are already in include path. There is in makefile a rule already removing asm-offsets.h which is generated and this one does not use a prefix so we should follow this standard in fact. So we should not use any prefix (srctree or obj) i think. @anthony: any suggestion here ? Bertrand > > ~ Oleksii
On Tue, 2023-09-05 at 14:10 +0000, Bertrand Marquis wrote: > Hi Oleksii, > > > On 5 Sep 2023, at 15:37, Oleksii <oleksii.kurochko@gmail.com> > > wrote: > > > > Hi Bertrand, > > > > On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: > > > Hi Oleksii, > > > > > > > On 1 Sep 2023, at 18:02, Oleksii Kurochko > > > > <oleksii.kurochko@gmail.com> wrote: > > > > > > > > Some headers are shared between individual architectures or are > > > > empty. > > > > To avoid duplication of these headers, asm-generic is > > > > introduced. > > > > > > > > With the following patch, an architecture uses generic headers > > > > mentioned in the file arch/$(ARCH)/include/asm/Kbuild. > > > > > > Kbuild refers to "Kernel build" I guess. > > > I am ok to keep that name to keep things simpler when compared to > > > Linux scripts but it would be good to mention that in the commit > > > message for future reference. > > Sure. I'll add that Kbuild refers to "Kernel build" > > > > > > > > > > > To use a generic header is needed to add to > > > > arch/$(ARCH)/include/asm/Kbuild : > > > > generic-y += <name-of-header-file.h> > > > > > > > > For each mentioned header in arch/$(ARCH)/include/asm/Kbuild, > > > > kbuild will generate the necessary wrapper in > > > > arch/$(ARCH)/include/generated/asm. > > > > > > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > > > --- > > > > Changes in V4: > > > > - introduce asm-generic support > > > > - update commit message > > > > --- > > > > Changes in V3: > > > > - Rename stubs dir to asm-generic > > > > --- > > > > Changes in V2: > > > > - Nothing changed. > > > > --- > > > > xen/Makefile | 10 +++++++++- > > > > xen/arch/arm/include/asm/Kbuild | 1 + > > > > xen/arch/ppc/include/asm/Kbuild | 1 + > > > > xen/arch/riscv/include/asm/Kbuild | 1 + > > > > xen/arch/x86/include/asm/Kbuild | 1 + > > > > xen/scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++ > > > > 6 files changed, 36 insertions(+), 1 deletion(-) > > > > create mode 100644 xen/arch/arm/include/asm/Kbuild > > > > create mode 100644 xen/arch/ppc/include/asm/Kbuild > > > > create mode 100644 xen/arch/riscv/include/asm/Kbuild > > > > create mode 100644 xen/arch/x86/include/asm/Kbuild > > > > create mode 100644 xen/scripts/Makefile.asm-generic > > > > > > > > diff --git a/xen/Makefile b/xen/Makefile > > > > index f57e5a596c..698d6ddeb8 100644 > > > > --- a/xen/Makefile > > > > +++ b/xen/Makefile > > > > @@ -438,6 +438,7 @@ ifdef building_out_of_srctree > > > > endif > > > > CFLAGS += -I$(srctree)/include > > > > CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include > > > > +CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include/generated > > > > > > Why are we generating files in the source tree ? > > > Shouldn't we keep it unmodified ? > > I think you are right. > > I got myself confused because I do not use out-of-tree compilation > > so > > for me it looked like $(srctree). > > > > It would be better to use $(objtree) instead. > > Ack > > > > > > > > > > > > # Note that link order matters! > > > > ALL_OBJS-y := common/built_in.o > > > > @@ -580,6 +581,7 @@ _clean: > > > > rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf > > > > $(TARGET).efi.stripped > > > > rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h > > > > rm -f .banner .allconfig.tmp include/xen/compile.h > > > > + rm -rf arch/*/include/generated > > > > > > > > > > You must use the same as for CFLAGS here so $(srctree) would be > > > needed. > > > (or something else depending on the fix for previous comment) > > Thanks. I'll change to the value mentioned in CFLAGS. > > > > > > > > > .PHONY: _distclean > > > > _distclean: clean > > > > @@ -589,7 +591,7 @@ $(TARGET).gz: $(TARGET) > > > > gzip -n -f -9 < $< > $@.new > > > > mv $@.new $@ > > > > > > > > -$(TARGET): outputmakefile FORCE > > > > +$(TARGET): outputmakefile asm-generic FORCE > > > > $(Q)$(MAKE) $(build)=tools > > > > $(Q)$(MAKE) $(build)=. include/xen/compile.h > > > > $(Q)$(MAKE) $(build)=include all > > > > @@ -667,6 +669,12 @@ endif # need-sub-make > > > > PHONY += FORCE > > > > FORCE: > > > > > > > > +# Support for using generic headers in asm-generic > > > > +PHONY += asm-generic > > > > +asm-generic: > > > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ > > > > + obj=arch/$(SRCARCH)/include/generated/asm > > > > + > > > > # Declare the contents of the PHONY variable as phony. We keep > > > > that > > > > # information in a variable so we can use it in if_changed and > > > > friends. > > > > .PHONY: $(PHONY) > > > > diff --git a/xen/arch/arm/include/asm/Kbuild > > > > b/xen/arch/arm/include/asm/Kbuild > > > > new file mode 100644 > > > > index 0000000000..a4e40e534e > > > > --- /dev/null > > > > +++ b/xen/arch/arm/include/asm/Kbuild > > > > @@ -0,0 +1 @@ > > > > +# SPDX-License-Identifier: GPL-2.0-only > > > > diff --git a/xen/arch/ppc/include/asm/Kbuild > > > > b/xen/arch/ppc/include/asm/Kbuild > > > > new file mode 100644 > > > > index 0000000000..a4e40e534e > > > > --- /dev/null > > > > +++ b/xen/arch/ppc/include/asm/Kbuild > > > > @@ -0,0 +1 @@ > > > > +# SPDX-License-Identifier: GPL-2.0-only > > > > diff --git a/xen/arch/riscv/include/asm/Kbuild > > > > b/xen/arch/riscv/include/asm/Kbuild > > > > new file mode 100644 > > > > index 0000000000..a4e40e534e > > > > --- /dev/null > > > > +++ b/xen/arch/riscv/include/asm/Kbuild > > > > @@ -0,0 +1 @@ > > > > +# SPDX-License-Identifier: GPL-2.0-only > > > > diff --git a/xen/arch/x86/include/asm/Kbuild > > > > b/xen/arch/x86/include/asm/Kbuild > > > > new file mode 100644 > > > > index 0000000000..a4e40e534e > > > > --- /dev/null > > > > +++ b/xen/arch/x86/include/asm/Kbuild > > > > @@ -0,0 +1 @@ > > > > +# SPDX-License-Identifier: GPL-2.0-only > > > > diff --git a/xen/scripts/Makefile.asm-generic > > > > b/xen/scripts/Makefile.asm-generic > > > > new file mode 100644 > > > > index 0000000000..0aac3f50b8 > > > > --- /dev/null > > > > +++ b/xen/scripts/Makefile.asm-generic > > > > @@ -0,0 +1,23 @@ > > > > +# SPDX-License-Identifier: GPL-2.0 > > > > +# include/asm-generic contains a lot of files that are used > > > > +# verbatim by several architectures. > > > > +# > > > > +# This Makefile reads the file > > > > arch/$(SRCARCH)/include/asm/Kbuild > > > > +# and for each file listed in this file with generic-y creates > > > > +# a small wrapper file in $(obj) > > > > (arch/$(SRCARCH)/include/generated/asm) > > > > + > > > > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > > > > +include $(kbuild-file) > > > > + > > > > +include scripts/Kbuild.include > > > > + > > > > +# Create output directory if not already present > > > > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > > > > + > > > > +quiet_cmd_wrap = WRAP $@ > > > > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > > > > + > > > > +all: $(patsubst %, $(obj)/%, $(generic-y)) > > > > + > > > > +$(obj)/%.h: > > > > + $(call cmd,wrap) > > > > > > In fact i think your files are not generated in the srctree so > > > this > > > will break if you use out of tree compilation. > > Why not? They will be generated in $obj which equal to > > obj=arch/$(SRCARCH)/include/generated/asm ( in my case ). > > Right they are generated in the build tree but if it is not the same > as srctree it will not work due to CFLAGS. > > > > > Anyway I think that obj should be equal to what is mentioned in > > CFLAGS. > > We generate other files like asm-offsets.h and it could in fact be > that > both srctree and build tree are already in include path. > > There is in makefile a rule already removing asm-offsets.h which is > generated > and this one does not use a prefix so we should follow this standard > in fact. > > So we should not use any prefix (srctree or obj) i think. I think you are right. Lets avoid usage of srctree/obj. ~ Oleksii
Hello Bertrand On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: > > diff --git a/xen/scripts/Makefile.asm-generic > > b/xen/scripts/Makefile.asm-generic > > new file mode 100644 > > index 0000000000..0aac3f50b8 > > --- /dev/null > > +++ b/xen/scripts/Makefile.asm-generic > > @@ -0,0 +1,23 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > +# include/asm-generic contains a lot of files that are used > > +# verbatim by several architectures. > > +# > > +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild > > +# and for each file listed in this file with generic-y creates > > +# a small wrapper file in $(obj) > > (arch/$(SRCARCH)/include/generated/asm) > > + > > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > > +include $(kbuild-file) > > + > > +include scripts/Kbuild.include > > + > > +# Create output directory if not already present > > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > > + > > +quiet_cmd_wrap = WRAP $@ > > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > > + > > +all: $(patsubst %, $(obj)/%, $(generic-y)) > > + > > +$(obj)/%.h: > > + $(call cmd,wrap) > > In fact i think your files are not generated in the srctree so this > will break if you use out of tree compilation. I checked that and in both cases it generated in correct place. First case: $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 ./automation/scripts/containerize make XEN_TARGET_ARCH=riscv64 -C xen build $ ls -la xen/arch/riscv/include/generated/asm/vm_event.h -rw-r--r--. 1 ok ok 34 вер 6 14:32 xen/arch/riscv/include/generated/asm/vm_event.h Second case: ( out-of-tree ) $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 ./automation/scripts/containerize make O=xen_build XEN_TARGET_ARCH=riscv64 -C xen build V=1 $ ls -la xen/xen_build/arch/riscv/include/generated/asm/vm_event.h -rw-r--r--. 1 ok ok 34 вер 6 14:34 xen/xen_build/arch/riscv/include/generated/asm/vm_event.h Could you please clarify if there's somithing I might have overlooked? ~ Oleksii
On 01.09.2023 18:02, Oleksii Kurochko wrote: > --- /dev/null > +++ b/xen/scripts/Makefile.asm-generic > @@ -0,0 +1,23 @@ > +# SPDX-License-Identifier: GPL-2.0 While this is what the Linux file presently says, you still want to add "-only", which is merely the newer name for the same thing. > +# include/asm-generic contains a lot of files that are used > +# verbatim by several architectures. > +# > +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild > +# and for each file listed in this file with generic-y creates > +# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) > + > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > +include $(kbuild-file) > + > +include scripts/Kbuild.include > + > +# Create output directory if not already present > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > + > +quiet_cmd_wrap = WRAP $@ > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > + > +all: $(patsubst %, $(obj)/%, $(generic-y)) > + > +$(obj)/%.h: > + $(call cmd,wrap) You've removed quite a bit of functionality, comparing with the Linux original. May I ask why that is? What they have all makes sense to me, and looks to be useful down the road. Jan
On Wed, 2023-09-06 at 14:16 +0200, Jan Beulich wrote: > On 01.09.2023 18:02, Oleksii Kurochko wrote: > > --- /dev/null > > +++ b/xen/scripts/Makefile.asm-generic > > @@ -0,0 +1,23 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > While this is what the Linux file presently says, you still want to > add > "-only", which is merely the newer name for the same thing. > > > +# include/asm-generic contains a lot of files that are used > > +# verbatim by several architectures. > > +# > > +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild > > +# and for each file listed in this file with generic-y creates > > +# a small wrapper file in $(obj) > > (arch/$(SRCARCH)/include/generated/asm) > > + > > +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild > > +include $(kbuild-file) > > + > > +include scripts/Kbuild.include > > + > > +# Create output directory if not already present > > +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) > > + > > +quiet_cmd_wrap = WRAP $@ > > +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ > > + > > +all: $(patsubst %, $(obj)/%, $(generic-y)) > > + > > +$(obj)/%.h: > > + $(call cmd,wrap) > > You've removed quite a bit of functionality, comparing with the Linux > original. May I ask why that is? What they have all makes sense to > me, > and looks to be useful down the road. I decided to take only minimum needed now but if you think it would be better to use the latest Linux's Makefile.asm-generic then I will update it in the next patch version. ~ Oleksii
On 06.09.2023 14:28, Oleksii wrote: > On Wed, 2023-09-06 at 14:16 +0200, Jan Beulich wrote: >> On 01.09.2023 18:02, Oleksii Kurochko wrote: >>> --- /dev/null >>> +++ b/xen/scripts/Makefile.asm-generic >>> @@ -0,0 +1,23 @@ >>> +# SPDX-License-Identifier: GPL-2.0 >> >> While this is what the Linux file presently says, you still want to >> add >> "-only", which is merely the newer name for the same thing. >> >>> +# include/asm-generic contains a lot of files that are used >>> +# verbatim by several architectures. >>> +# >>> +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild >>> +# and for each file listed in this file with generic-y creates >>> +# a small wrapper file in $(obj) >>> (arch/$(SRCARCH)/include/generated/asm) >>> + >>> +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild >>> +include $(kbuild-file) >>> + >>> +include scripts/Kbuild.include >>> + >>> +# Create output directory if not already present >>> +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) >>> + >>> +quiet_cmd_wrap = WRAP $@ >>> +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ >>> + >>> +all: $(patsubst %, $(obj)/%, $(generic-y)) >>> + >>> +$(obj)/%.h: >>> + $(call cmd,wrap) >> >> You've removed quite a bit of functionality, comparing with the Linux >> original. May I ask why that is? What they have all makes sense to >> me, >> and looks to be useful down the road. > I decided to take only minimum needed now but if you think it would be > better to use the latest Linux's Makefile.asm-generic then I will > update it in the next patch version. Unless there are things getting in the way, I indeed think it would be better to take the whole thing largely verbatim (a few edits are unavoidable afaict). Jan
Hi Oleksii, > On 6 Sep 2023, at 13:37, Oleksii <oleksii.kurochko@gmail.com> wrote: > > Hello Bertrand > > On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: >>> diff --git a/xen/scripts/Makefile.asm-generic >>> b/xen/scripts/Makefile.asm-generic >>> new file mode 100644 >>> index 0000000000..0aac3f50b8 >>> --- /dev/null >>> +++ b/xen/scripts/Makefile.asm-generic >>> @@ -0,0 +1,23 @@ >>> +# SPDX-License-Identifier: GPL-2.0 >>> +# include/asm-generic contains a lot of files that are used >>> +# verbatim by several architectures. >>> +# >>> +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild >>> +# and for each file listed in this file with generic-y creates >>> +# a small wrapper file in $(obj) >>> (arch/$(SRCARCH)/include/generated/asm) >>> + >>> +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild >>> +include $(kbuild-file) >>> + >>> +include scripts/Kbuild.include >>> + >>> +# Create output directory if not already present >>> +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) >>> + >>> +quiet_cmd_wrap = WRAP $@ >>> +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ >>> + >>> +all: $(patsubst %, $(obj)/%, $(generic-y)) >>> + >>> +$(obj)/%.h: >>> + $(call cmd,wrap) >> >> In fact i think your files are not generated in the srctree so this >> will break if you use out of tree compilation. > I checked that and in both cases it generated in correct place. > > First case: > $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 > ./automation/scripts/containerize make XEN_TARGET_ARCH=riscv64 -C xen > build > > $ ls -la xen/arch/riscv/include/generated/asm/vm_event.h > -rw-r--r--. 1 ok ok 34 вер 6 14:32 > xen/arch/riscv/include/generated/asm/vm_event.h > > Second case: ( out-of-tree ) > $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 > ./automation/scripts/containerize make O=xen_build > XEN_TARGET_ARCH=riscv64 -C xen build V=1 > > $ ls -la xen/xen_build/arch/riscv/include/generated/asm/vm_event.h > -rw-r--r--. 1 ok ok 34 вер 6 14:34 > xen/xen_build/arch/riscv/include/generated/asm/vm_event.h > > Could you please clarify if there's somithing I might have overlooked? No I do not think you did. So obj is empty I would guess. Anyway you just need to make sure that CFLAGS is coherent with what you generate. So if you generate in $(obj) you need to make sure you use the same in CFLAGS i would say. @anthony: any advice here ? Cheers Bertrand > > ~ Oleksii > > >
On Wed, Sep 06, 2023 at 02:40:29PM +0200, Jan Beulich wrote: > On 06.09.2023 14:28, Oleksii wrote: > > On Wed, 2023-09-06 at 14:16 +0200, Jan Beulich wrote: > >> You've removed quite a bit of functionality, comparing with the Linux > >> original. May I ask why that is? What they have all makes sense to > >> me, > >> and looks to be useful down the road. > > I decided to take only minimum needed now but if you think it would be > > better to use the latest Linux's Makefile.asm-generic then I will > > update it in the next patch version. > > Unless there are things getting in the way, I indeed think it would be > better to take the whole thing largely verbatim (a few edits are > unavoidable afaict). Yes, I think it would be useful as well to take most of the file from Linux. At least, this would include the "$(unwanted)" variable, which is used to remove old wrapper when an header is removed from "generic-y". But instead of the "-include $(kbuild-file)", could you include "$(src)/Makefile" instead like we do in "Rules.mk"? We don't have $(kbuild-file) macro anyway, and I don't see the point in using files name "Kbuild" when "Makefile" works and is enough. Thanks,
On Wed, 2023-09-06 at 16:06 +0100, Anthony PERARD wrote: > On Wed, Sep 06, 2023 at 02:40:29PM +0200, Jan Beulich wrote: > > On 06.09.2023 14:28, Oleksii wrote: > > > On Wed, 2023-09-06 at 14:16 +0200, Jan Beulich wrote: > > > > You've removed quite a bit of functionality, comparing with the > > > > Linux > > > > original. May I ask why that is? What they have all makes sense > > > > to > > > > me, > > > > and looks to be useful down the road. > > > I decided to take only minimum needed now but if you think it > > > would be > > > better to use the latest Linux's Makefile.asm-generic then I will > > > update it in the next patch version. > > > > Unless there are things getting in the way, I indeed think it would > > be > > better to take the whole thing largely verbatim (a few edits are > > unavoidable afaict). > > Yes, I think it would be useful as well to take most of the file from > Linux. At least, this would include the "$(unwanted)" variable, which > is > used to remove old wrapper when an header is removed from "generic- > y". > But instead of the "-include $(kbuild-file)", could you include > "$(src)/Makefile" instead like we do in "Rules.mk"? We don't have > $(kbuild-file) macro anyway, and I don't see the point in using files > name "Kbuild" when "Makefile" works and is enough. > Thank you for your feedback. I'll take into account your suggestions in the next patch version. ~ Oleksii
On Wed, Sep 06, 2023 at 01:03:32PM +0000, Bertrand Marquis wrote: > > On 6 Sep 2023, at 13:37, Oleksii <oleksii.kurochko@gmail.com> wrote: > > On Mon, 2023-09-04 at 13:39 +0000, Bertrand Marquis wrote: > >>> diff --git a/xen/scripts/Makefile.asm-generic > >>> b/xen/scripts/Makefile.asm-generic > >>> new file mode 100644 > >>> index 0000000000..0aac3f50b8 > >>> --- /dev/null > >>> +++ b/xen/scripts/Makefile.asm-generic > >>> + > >>> +$(obj)/%.h: > >>> + $(call cmd,wrap) > >> > >> In fact i think your files are not generated in the srctree so this > >> will break if you use out of tree compilation. > > I checked that and in both cases it generated in correct place. > > > > First case: > > $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 > > ./automation/scripts/containerize make XEN_TARGET_ARCH=riscv64 -C xen > > build > > > > $ ls -la xen/arch/riscv/include/generated/asm/vm_event.h > > -rw-r--r--. 1 ok ok 34 вер 6 14:32 > > xen/arch/riscv/include/generated/asm/vm_event.h > > > > Second case: ( out-of-tree ) > > $ CONTAINER_NO_PULL=1 CONTAINER=riscv64 > > ./automation/scripts/containerize make O=xen_build > > XEN_TARGET_ARCH=riscv64 -C xen build V=1 > > > > $ ls -la xen/xen_build/arch/riscv/include/generated/asm/vm_event.h > > -rw-r--r--. 1 ok ok 34 вер 6 14:34 > > xen/xen_build/arch/riscv/include/generated/asm/vm_event.h > > > > Could you please clarify if there's somithing I might have overlooked? > > No I do not think you did. > > So obj is empty I would guess. > Anyway you just need to make sure that CFLAGS is coherent with what you generate. > So if you generate in $(obj) you need to make sure you use the same in CFLAGS i would say. > > @anthony: any advice here ? The use of $(obj) looks fine here. $(obj) is temporary and set for a single subdirectory. $(obj) is set by whatever is calling "Makefile.asm-generic", or "Rules.mk" is other cases. In this patch, you can see $(obj) been set in "xen/Makefile": $(MAKE) -f $(srctree)/scripts/Makefile.asm-generic obj=arch/$(SRCARCH)/include/generated/asm Another thing to know, `make` runs from the build directory, so in Oleksii second case, `make` is running in "xen/xen_build", so $(obj) point to a directory within the build directory. For the CFLAGS, we can use $(objtree) (even if it is just "."), which always point to the top directory of the build tree. I hope that clarifies things. Cheers,
On Fri, Sep 01, 2023 at 07:02:14PM +0300, Oleksii Kurochko wrote: > diff --git a/xen/Makefile b/xen/Makefile > index f57e5a596c..698d6ddeb8 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -667,6 +669,12 @@ endif # need-sub-make > PHONY += FORCE > FORCE: > > +# Support for using generic headers in asm-generic > +PHONY += asm-generic > +asm-generic: > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ > + obj=arch/$(SRCARCH)/include/generated/asm Could you introduce a $(asm-generic) macro in Kbuild.include like we already have for $(build) and $(clean)? As I think it would be nicer to have $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm in the main makefile. Also, could you move the rule "asm-generic" within the "!config-build" part of the Makefile? Somewhere around the rule for $(TARGET), maybe just after the rule "_distclean". Cheers,
On Wed, 2023-09-06 at 16:57 +0100, Anthony PERARD wrote: > On Fri, Sep 01, 2023 at 07:02:14PM +0300, Oleksii Kurochko wrote: > > diff --git a/xen/Makefile b/xen/Makefile > > index f57e5a596c..698d6ddeb8 100644 > > --- a/xen/Makefile > > +++ b/xen/Makefile > > @@ -667,6 +669,12 @@ endif # need-sub-make > > PHONY += FORCE > > FORCE: > > > > +# Support for using generic headers in asm-generic > > +PHONY += asm-generic > > +asm-generic: > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ > > + obj=arch/$(SRCARCH)/include/generated/asm > > Could you introduce a $(asm-generic) macro in Kbuild.include like we > already have for $(build) and $(clean)? As I think it would be nicer > to > have > $(Q)$(MAKE) $(asm- > generic)=arch/$(SRCARCH)/include/generated/asm > in the main makefile. > > Also, could you move the rule "asm-generic" within the "!config- > build" > part of the Makefile? Somewhere around the rule for $(TARGET), maybe > just after the rule "_distclean". > I pushed a new patch version tomorrow. I'll rework it based on your comments here. ~ Oleksii
diff --git a/xen/Makefile b/xen/Makefile index f57e5a596c..698d6ddeb8 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -438,6 +438,7 @@ ifdef building_out_of_srctree endif CFLAGS += -I$(srctree)/include CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include +CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include/generated # Note that link order matters! ALL_OBJS-y := common/built_in.o @@ -580,6 +581,7 @@ _clean: rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf $(TARGET).efi.stripped rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h rm -f .banner .allconfig.tmp include/xen/compile.h + rm -rf arch/*/include/generated .PHONY: _distclean _distclean: clean @@ -589,7 +591,7 @@ $(TARGET).gz: $(TARGET) gzip -n -f -9 < $< > $@.new mv $@.new $@ -$(TARGET): outputmakefile FORCE +$(TARGET): outputmakefile asm-generic FORCE $(Q)$(MAKE) $(build)=tools $(Q)$(MAKE) $(build)=. include/xen/compile.h $(Q)$(MAKE) $(build)=include all @@ -667,6 +669,12 @@ endif # need-sub-make PHONY += FORCE FORCE: +# Support for using generic headers in asm-generic +PHONY += asm-generic +asm-generic: + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ + obj=arch/$(SRCARCH)/include/generated/asm + # Declare the contents of the PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) diff --git a/xen/arch/arm/include/asm/Kbuild b/xen/arch/arm/include/asm/Kbuild new file mode 100644 index 0000000000..a4e40e534e --- /dev/null +++ b/xen/arch/arm/include/asm/Kbuild @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-only diff --git a/xen/arch/ppc/include/asm/Kbuild b/xen/arch/ppc/include/asm/Kbuild new file mode 100644 index 0000000000..a4e40e534e --- /dev/null +++ b/xen/arch/ppc/include/asm/Kbuild @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-only diff --git a/xen/arch/riscv/include/asm/Kbuild b/xen/arch/riscv/include/asm/Kbuild new file mode 100644 index 0000000000..a4e40e534e --- /dev/null +++ b/xen/arch/riscv/include/asm/Kbuild @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-only diff --git a/xen/arch/x86/include/asm/Kbuild b/xen/arch/x86/include/asm/Kbuild new file mode 100644 index 0000000000..a4e40e534e --- /dev/null +++ b/xen/arch/x86/include/asm/Kbuild @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0-only diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic new file mode 100644 index 0000000000..0aac3f50b8 --- /dev/null +++ b/xen/scripts/Makefile.asm-generic @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0 +# include/asm-generic contains a lot of files that are used +# verbatim by several architectures. +# +# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild +# and for each file listed in this file with generic-y creates +# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) + +kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild +include $(kbuild-file) + +include scripts/Kbuild.include + +# Create output directory if not already present +_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) + +quiet_cmd_wrap = WRAP $@ +cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ + +all: $(patsubst %, $(obj)/%, $(generic-y)) + +$(obj)/%.h: + $(call cmd,wrap)
Some headers are shared between individual architectures or are empty. To avoid duplication of these headers, asm-generic is introduced. With the following patch, an architecture uses generic headers mentioned in the file arch/$(ARCH)/include/asm/Kbuild. To use a generic header is needed to add to arch/$(ARCH)/include/asm/Kbuild : generic-y += <name-of-header-file.h> For each mentioned header in arch/$(ARCH)/include/asm/Kbuild, kbuild will generate the necessary wrapper in arch/$(ARCH)/include/generated/asm. Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> --- Changes in V4: - introduce asm-generic support - update commit message --- Changes in V3: - Rename stubs dir to asm-generic --- Changes in V2: - Nothing changed. --- xen/Makefile | 10 +++++++++- xen/arch/arm/include/asm/Kbuild | 1 + xen/arch/ppc/include/asm/Kbuild | 1 + xen/arch/riscv/include/asm/Kbuild | 1 + xen/arch/x86/include/asm/Kbuild | 1 + xen/scripts/Makefile.asm-generic | 23 +++++++++++++++++++++++ 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 xen/arch/arm/include/asm/Kbuild create mode 100644 xen/arch/ppc/include/asm/Kbuild create mode 100644 xen/arch/riscv/include/asm/Kbuild create mode 100644 xen/arch/x86/include/asm/Kbuild create mode 100644 xen/scripts/Makefile.asm-generic