Patch created by John L. Poole 3/1/2018 Referencing Gentoo Bugs: #602052 - app-emulation/xen-4.8.2-r1 GRUB_PLATFORMS="efi-64" fails to build: Makefile:141: recipe for target fails #649048 - app-emulation/xen-4.9.1-r1 fails to compile of UEFI motherboard The method for creating this patch was the same as I used for the patch for 4.8.2-r1 available in Bug #602052. I went in and hand edited three lines adding a flag "-b coff-x86-64". Commentator Pat Erley on Bug #602052 at 2017-01-08 08:02:56 UTC https://bugs.gentoo.org/602052#c19 noted my choice of coff-x86-64 vs. PE. I have no justification for choosing coff-x86-64; it was the first I tried and using it allowed me to move forward. I leave the merits of using PE vs. coff-x86-64 for someone else to devine. If I recall correctly, I used that patch (https://bugs.gentoo.org/attachment.cgi?id=455684) in a portage overlay ("Portage Overlay"). That is more cumbersome, in my opinion and adds complexity to emerge updates because I have something custom lurking on my system that could be interfering with an upgrade. This time, I am using the feature of user patches ("User Patches") by placing a patch under: /etc/portage/patches/app-emulation/xen Emerge kept dying saying that it could not find the files. So with some midnight oil, I determined that the call to patch uses the "-p1" parameter which strips off the first forward slash. When I tried to use the same form as in the previous patch for xen-4.8.2-r1, namely specifying the file path with "xen/arch...", emerge kept failing at the patch point because "patch" claimed it could not find the file. I created a study re: patching and have shared it at: https://forums.gentoo.org/viewtopic-t-1077806.html as "Sample Patch Study" In order for this patch to succeed in a User Patches mode, I had to prefix "xen/arch..." with a forward slash, "/", as you can see below. Then when emerge tried to apply this patch with the "-p1" flag, the patch succeeded. WARNING: I suspect this patch will not work in the Portage Overlay method because of the presence of the forward slash, so don't use this patch for a Portage Overlay approach. However, you may be able to simply modify this patch to work for a Portage Overlay by simply removing the two forward slash characters. The real heart of the matter appears to be with binutils determining there is an ambiguity and croaking. Until that is fixed, this patch approach seems to be the only way to build Xen on a EFI based system. For improvements on the form of this patch: see scholarly and quirky: https://dev.gentoo.org/~vapier/clean-patches Bug #649048 was marked as a duplicate, but since this patch is using the User Patches approach instead of Bug #602052 Portage Overlay approach, I'm placing this patch in Bug #649048. --- /xen/arch/x86/Makefile_ORIGINAL 2018-02-28 21:23:49.632816030 -0800 +++ /xen/arch/x86/Makefile 2018-02-28 21:30:58.474793635 -0800 @@ -177,20 +177,20 @@ $(TARGET).efi: prelink-efi.o $(note_file) efi.lds efi/relocs-dummy.o $(BASEDIR)/common/symbols-dummy.o efi/mkreloc $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ $(guard) $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< efi/relocs-dummy.o \ - $(BASEDIR)/common/symbols-dummy.o $(note_file) -o $(@D)/.$(@F).$(base).0 &&) : + $(BASEDIR)/common/symbols-dummy.o -b coff-x86-64 $(note_file) -o $(@D)/.$(@F).$(base).0 &&) : $(guard) efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).0) >$(@D)/.$(@F).0r.S $(guard) $(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).0 \ | $(guard) $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0s.S $(guard) $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ $(guard) $(LD) $(call EFI_LDFLAGS,$(base)) -T efi.lds -N $< \ - $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o $(note_file) -o $(@D)/.$(@F).$(base).1 &&) : + $(@D)/.$(@F).0r.o $(@D)/.$(@F).0s.o -b coff-x86-64 $(note_file) -o $(@D)/.$(@F).$(base).1 &&) : $(guard) efi/mkreloc $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(@D)/.$(@F).$(base).1) >$(@D)/.$(@F).1r.S $(guard) $(NM) -pa --format=sysv $(@D)/.$(@F).$(VIRT_BASE).1 \ | $(guard) $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1s.S $(guard) $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(guard) $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T efi.lds -N $< \ - $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o $(note_file) -o $@ + $(@D)/.$(@F).1r.o $(@D)/.$(@F).1s.o -b coff-x86-64 $(note_file) -o $@ if $(guard) false; then rm -f $@; echo 'EFI support disabled'; \ else $(NM) -pa --format=sysv $(@D)/$(@F) \ | $(BASEDIR)/tools/symbols --xensyms --sysv --sort >$(@D)/$(@F).map; fi