[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC XEN PATCH 17/23] convert arch/x86/boot/Makefile to kbuild


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Wed, 23 Oct 2019 17:48:31 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@xxxxxxxxxx; spf=Pass smtp.mailfrom=anthony.perard@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 23 Oct 2019 17:10:58 +0000
  • Ironport-sdr: NUHm0shS0X5MEjsNC/5JnyrZJ6VBgdPZgh92ZH1Qp7112qH07SrB3vC5Q/5yE8E6tNsGv1E2J7 PHhZiJ7v85czJPI+6YSZxao3+gR/TaA4+J1zvy2syqzxgS8M021QedTNPdGgbtWzuikbzz0l2O ntlVpUbhXmcBX8vmmjA7Lz3ltugOg3YCc3ZbwmcFb7yb63RYgDIfzT+6jonVJZcfFYw62htjip iIygpdWOKPZy2uf8PEY4d2D6gz6Beo/LgcDpz8B7sAM4KZZIkGt/mHSaWYiWvutwthJb9yHVNm eW8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Sources of *FLAGS for 32bit build:
    - Config.mk
    - config/x86_32.mk
    - deleted build32.mk
---
 xen/arch/x86/boot/Makefile   | 72 +++++++++++++++++++++++++++++-------
 xen/arch/x86/boot/build32.mk | 40 --------------------
 2 files changed, 58 insertions(+), 54 deletions(-)
 delete mode 100644 xen/arch/x86/boot/build32.mk

diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile
index 9b31bfcbfb8a..fe6344aa0022 100644
--- a/xen/arch/x86/boot/Makefile
+++ b/xen/arch/x86/boot/Makefile
@@ -1,20 +1,64 @@
-obj-bin-y += head.o
+# Add -Iinclude so cc-option calls can work properly. (The current CFLAGS want
+# to include a header which includes <generated/autoconf.h>)
+KBUILD_CFLAGS += $(LINUXINCLUDE)
+# Prepare CFLAGS to have 32bit build for the deps of head.S
+CFLAGS_S_c     := -m32 -march=i686
+CFLAGS_S_c     += -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
+CFLAGS_S_c     += $(call cc-option,-Wdeclaration-after-statement)
+CFLAGS_S_c     += $(call cc-disable-warning,unused-but-set-variable)
+CFLAGS_S_c     += $(call cc-disable-warning,unused-local-typedefs)
 
-DEFS_H_DEPS = defs.h $(BASEDIR)/include/xen/stdbool.h
+EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all
+EMBEDDED_EXTRA_CFLAGS += -fno-exceptions
+CFLAGS_S_c += $(foreach o,$(EMBEDDED_EXTRA_CFLAGS),$(call cc-option,$(o)))
+CFLAGS_S_c += -Werror -fno-asynchronous-unwind-tables -fno-builtin -g0 
-msoft-float
+CFLAGS_S_c := $(filter-out -flto,$(CFLAGS_S_c))
+CFLAGS_S_c += -fpic
+LDFLAGS_emulation_OpenBSD := _obsd
+LDFLAGS_emulation_FreeBSD := _fbsd
+LDFLAGS_S_c := -melf_i386$(LDFLAGS_emulation_$(XEN_OS)) -N -T 
$(srctree)/$(src)/build32.lds
 
-CMDLINE_DEPS = $(DEFS_H_DEPS) video.h
+head-deps := cmdline.S reloc.S
+targets += $(foreach o,$(head-deps), \
+               $(foreach sfx,o lnk bin S, \
+                       $(patsubst %.S,%.$(sfx),$(o))))
 
-RELOC_DEPS = $(DEFS_H_DEPS) \
-            $(BASEDIR)/include/generated/autoconf.h \
-            $(BASEDIR)/include/xen/kconfig.h \
-            $(BASEDIR)/include/xen/multiboot.h \
-            $(BASEDIR)/include/xen/multiboot2.h \
-            $(BASEDIR)/include/public/arch-x86/hvm/start_info.h
+$(addprefix $(obj)/,$(head-deps:.S=.o)): KBUILD_CFLAGS := $(CFLAGS_S_c)
+$(addprefix $(obj)/,$(head-deps:.S=.lnk)): KBUILD_LDFLAGS := $(LDFLAGS_S_c)
 
-head.o: cmdline.S reloc.S
+$(obj)/head.o: $(addprefix $(obj)/,$(head-deps))
+obj-y := head.o
 
-cmdline.S: cmdline.c $(CMDLINE_DEPS)
-       $(MAKE) -f build32.mk $@ CMDLINE_DEPS="$(CMDLINE_DEPS)"
+# NB. awk invocation is a portable alternative to 'head -n -1'
+quiet_cmd_sed_S_bin = UPD     $@
+define cmd_sed_S_bin
+       (od -v -t x $< | tr -s ' ' | awk 'NR > 1 {print s} {s=$$0}' | \
+       sed 's/ /,0x/g' | sed 's/,0x$$//' | sed 's/^[0-9]*,/ .long /') >$@
+endef
+$(addprefix $(obj)/,cmdline.S reloc.S): $(obj)/%.S: $(obj)/%.bin FORCE
+       $(call if_changed,sed_S_bin)
 
-reloc.S: reloc.c $(RELOC_DEPS)
-       $(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)"
+# Drop .got.plt during conversion to plain binary format.
+# Please check build32.lds for more details.
+quiet_cmd_check_obj_got_plt = CHECK $@
+define cmd_check_obj_got_plt
+       set -e; \
+       $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | \
+               while read idx name sz rest; do \
+                       case "$$name" in \
+                       .got.plt) \
+                               test $$sz != 0c || continue; \
+                               echo "Error: non-empty $$name: 0x$$sz" >&2; \
+                               exit $$(expr $$idx + 1);; \
+                       esac; \
+               done
+endef
+quiet_cmd_check_obj_drop_got_plt = OBJCOPY $@
+cmd_check_obj_drop_got_plt = $(cmd_check_obj_got_plt); $(cmd_objcopy)
+
+OBJCOPYFLAGS :=  -O binary -R .got.plt
+$(obj)/%.bin: $(obj)/%.lnk FORCE
+       $(call if_changed,check_obj_drop_got_plt)
+
+$(obj)/%.lnk: $(obj)/%.o FORCE
+       $(call if_changed,ld)
diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk
deleted file mode 100644
index 48c7407c002f..000000000000
--- a/xen/arch/x86/boot/build32.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-override XEN_TARGET_ARCH=x86_32
-CFLAGS =
-include $(XEN_ROOT)/Config.mk
-
-$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
-
-CFLAGS += -Werror -fno-asynchronous-unwind-tables -fno-builtin -g0 -msoft-float
-CFLAGS += -I$(XEN_ROOT)/xen/include
-CFLAGS := $(filter-out -flto,$(CFLAGS)) 
-
-# NB. awk invocation is a portable alternative to 'head -n -1'
-%.S: %.bin
-       (od -v -t x $< | tr -s ' ' | awk 'NR > 1 {print s} {s=$$0}' | \
-       sed 's/ /,0x/g' | sed 's/,0x$$//' | sed 's/^[0-9]*,/ .long /') >$@
-
-# Drop .got.plt during conversion to plain binary format.
-# Please check build32.lds for more details.
-%.bin: %.lnk
-       $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | \
-               while read idx name sz rest; do \
-                       case "$$name" in \
-                       .got.plt) \
-                               test $$sz != 0c || continue; \
-                               echo "Error: non-empty $$name: 0x$$sz" >&2; \
-                               exit $$(expr $$idx + 1);; \
-                       esac; \
-               done
-       $(OBJCOPY) -O binary -R .got.plt $< $@
-
-%.lnk: %.o
-       $(LD) $(LDFLAGS_DIRECT) -N -T build32.lds -o $@ $<
-
-%.o: %.c
-       $(CC) $(CFLAGS) -c -fpic $< -o $@
-
-cmdline.o: cmdline.c $(CMDLINE_DEPS)
-
-reloc.o: reloc.c $(RELOC_DEPS)
-
-.PRECIOUS: %.bin %.lnk
-- 
Anthony PERARD

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.