Skip to contentSkip to conversation

x86/efi: move the logic to detect PE build support

PATCH Superseded Roger Pau Monne 3 participants 9 messages Jul 13, 2018 – Jul 16, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/efi: move the logic to detect PE build support

So that it can be used by other components apart from the efi specific code.

This is required so that the conditional used to define the efi symbol in the linker script can be removed and instead the definition of the efi symbol can be guarded using the preprocessor.

The motivation behind this change is to be able to build Xen using lld (the LLVM linker), that at least on version 6.0.0 doesn't work properly with a DEFINED being used in a conditional expression:

ld -melf_x86_64_fbsd -T xen.lds -N prelink.o --build-id=sha1 \
/root/src/xen/xen/common/symbols-dummy.o -o /root/src/xen/xen/.xen-syms.0
ld: error: xen.lds:233: symbol not found: efi

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Daniel Kiper <[email protected]>

---
 xen/arch/x86/Makefile     | 10 ++++++++++
 xen/arch/x86/efi/Makefile | 11 +++--------
 xen/arch/x86/xen.lds.S    |  4 +++-
 3 files changed, 16 insertions(+), 9 deletions(-)
xen/arch/x86/Makefile +10 -0
index 5563c813dd..59f96626aa 100644
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_
 # Don't use $(wildcard ...) here - at least make 3.80 expands this too early!
 $(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)
 
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif
+
 ifneq ($(build_id_linker),)
 ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
 CFLAGS += -DBUILD_ID_EFI
xen/arch/x86/efi/Makefile +3 -8
index 3be9661108..ff5e33fb25 100644
@@ -1,16 +1,11 @@
 CFLAGS += -fshort-wchar
 
-efi := y$(shell rm -f disabled)
-efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c check.c 2>disabled && echo y))
-efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o check.efi check.o 2>disabled && echo y))
-efi := $(if $(efi),$(shell rm disabled)y)
-
 %.o: %.ihex
 	$(OBJCOPY) -I ihex -O binary $< $@
 
 boot.init.o: buildid.o
 
 obj-y := stub.o
-obj-$(efi) := boot.init.o compat.o relocs-dummy.o runtime.o
-extra-$(efi) += buildid.o
-nocov-$(efi) += stub.o
+obj-$(BUILD_PE) := boot.init.o compat.o relocs-dummy.o runtime.o
+extra-$(BUILD_PE) += buildid.o
+nocov-$(BUILD_PE) += stub.o
xen/arch/x86/xen.lds.S +3 -1
index 326e885402..f93d5d7e16 100644
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif
 
   /* Sections to be discarded */
   /DISCARD/ : {
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too early! $(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 9 lines
xen/arch/x86/Makefile +9 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 10 lines
xen/arch/x86/xen.lds.S +3 -1
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 31 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too early! $(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 9 lines
xen/arch/x86/Makefile +9 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>efi/disabled && echo y))
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
Quoted 7 lines

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 4 lines
xen/arch/x86/xen.lds.S +3 -1
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

As I understand it EFI only signals whether a PE binary will be created, but the ELF binary will also contain efi support if the build toolchain supports PE. Hence whether the efi symbol is defined or not solely depends on the detection done above (and whether runtime.c or stub.c is used).

Maybe I'm missing something, I have to admit the code is quite convoluted.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 19 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
Quoted 7 lines

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 4 lines
xen/arch/x86/xen.lds.S +3 -1
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

Quoted 2 lines

As I understand it EFI only signals whether a PE binary will be created,

But that is my point: BUILD_PE signals exactly that aiui.

Jan

Quoted 9 lines

but the ELF binary will also contain efi support if the build toolchain supports PE. Hence whether the efi symbol is defined or not solely depends on the detection done above (and whether runtime.c or stub.c is used).

Maybe I'm missing something, I have to admit the code is quite convoluted.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 44 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 26 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 10 lines
xen/arch/x86/xen.lds.S +3 -1
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

Quoted 4 lines
Quoted 2 lines

As I understand it EFI only signals whether a PE binary will be created,

But that is my point: BUILD_PE signals exactly that aiui.

No, BUILD_PE signals whether the binary will use runtime.c instead of stub.c, and thus have the efi symbol defined. It is my understanding from the previous conversation with Daniel that for multiboot2 support you need an EFL binary that contains runtime.c (and thus the efi symbol is defined), and that you can build such a binary without having EFI set.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:12, <[email protected]> wrote:
Quoted 44 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 26 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 10 lines
xen/arch/x86/xen.lds.S +3 -1
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

As I understand it EFI only signals whether a PE binary will be created,

But that is my point: BUILD_PE signals exactly that aiui.

No, BUILD_PE signals whether the binary will use runtime.c instead of stub.c, and thus have the efi symbol defined.

But in that case - why did you chose this particular name?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 49 lines · Jan Beulich
Quoted 49 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:12, <[email protected]> wrote:
Quoted 47 lines · Jan Beulich
Quoted 46 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c 

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 19 lines

xen/arch/x86/Makefile $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_ · line 179

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
Quoted 7 lines

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 4 lines
xen/arch/x86/xen.lds.S +3 -1
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

As I understand it EFI only signals whether a PE binary will be created,

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

But that is my point: BUILD_PE signals exactly that aiui.

No, BUILD_PE signals whether the binary will use runtime.c instead of stub.c, and thus have the efi symbol defined.

But in that case - why did you chose this particular name?

Because that seems to be what the tests actually do. AFAICT it tests that the compiler supports the MS ABI and that the linker is able to generate PE binaries.

I think this is slightly wrong, because for multiboot2 support you likely only need the compiler MS ABI support, but not the linker PE support?

How about naming this BUILD_EFI_SERVICES or some such?

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 59 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:25, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:12, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) 

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

xen/arch/x86/Makefile

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) 

-c

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 19 lines

xen/arch/x86/Makefile

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
Quoted 7 lines

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 4 lines
xen/arch/x86/xen.lds.S +3 -1
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

As I understand it EFI only signals whether a PE binary will be created,

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

But that is my point: BUILD_PE signals exactly that aiui.

No, BUILD_PE signals whether the binary will use runtime.c instead of stub.c, and thus have the efi symbol defined.

But in that case - why did you chose this particular name?

Quoted 7 lines

Because that seems to be what the tests actually do. AFAICT it tests that the compiler supports the MS ABI and that the linker is able to generate PE binaries.

I think this is slightly wrong, because for multiboot2 support you likely only need the compiler MS ABI support, but not the linker PE support?

Indeed. But too strict checking is less of a problem than too lax one. Otoh people are far more likely to have a suitable gcc but no suitably configured binutils, so relaxing this would likely be worthwhile. Daniel?

Quoted 1 line

How about naming this BUILD_EFI_SERVICES or some such?

Perhaps just BUILD_EFI, but yes. EFI, as used in xen.lds.S, would then perhaps better be renamed into BUILD_PE (or some such).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
Quoted 63 lines · Jan Beulich
Quoted 63 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:25, <[email protected]> wrote:
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 11:12, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:26, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.07.18 at 18:02, <[email protected]> wrote:
xen/arch/x86/Makefile +0 -0
@@ -168,6 +168,16 @@ $(TARGET).efi: ALT_BASE = 0x$(shell $(NM)

efi/relocs-dummy.o | sed -n 's, A ALT_
# Don't use $(wildcard ...) here - at least make 3.80 expands this too

early!

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

xen/arch/x86/Makefile

Quoted 5 lines

$(TARGET).efi: guard = $(if $(shell echo efi/dis* | grep disabled),:)

xen/arch/x86/Makefile +3 -0
+# Check if the build system supports PE.
+efi := y$(shell rm -f efi/disabled)
+efi := $(if $(efi),$(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS))

-c

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines

efi/check.c -o efi/check.o 2>efi/disabled && echo y))

Quoted 1 line
Quoted 1 line

+efi := $(if $(efi),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi

efi/check.o 2>efi/disabled && echo y))

Quoted 19 lines

xen/arch/x86/Makefile

Quoted 5 lines
xen/arch/x86/Makefile +5 -0
+efi := $(if $(efi),$(shell rm efi/disabled)y)
+export BUILD_PE := $(efi)
+ifeq ($(efi),y)
+CFLAGS += -DBUILD_PE
+endif

For one I'm not really happy about this being moved here: I did place it in efi/Makefile for the simple reason of having as much as possible of the EFI specifics in that single file.

Additionally I think it would be better if setting propagated through the environment had XEN_ prefixes.

Quoted 6 lines
xen/arch/x86/xen.lds.S +0 -0
@@ -304,7 +304,9 @@ SECTIONS
   } :text
 #endif
 
Quoted 7 lines

xen/arch/x86/xen.lds.S SECTIONS · line 309

Quoted 4 lines
xen/arch/x86/xen.lds.S +3 -1
-  efi = DEFINED(efi) ? efi : .;
+#ifndef BUILD_PE
+  efi = .;
+#endif

And then I don't really understand how this is different from the original #ifndef EFI that Daniel had problems with.

As I understand it EFI only signals whether a PE binary will be created,

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

But that is my point: BUILD_PE signals exactly that aiui.

No, BUILD_PE signals whether the binary will use runtime.c instead of stub.c, and thus have the efi symbol defined.

But in that case - why did you chose this particular name?

Because that seems to be what the tests actually do. AFAICT it tests that the compiler supports the MS ABI and that the linker is able to generate PE binaries.

Quoted 7 lines
Quoted 3 lines

I think this is slightly wrong, because for multiboot2 support you likely only need the compiler MS ABI support, but not the linker PE support?

Indeed. But too strict checking is less of a problem than too lax one. Otoh people are far more likely to have a suitable gcc but no suitably configured binutils, so relaxing this would likely be worthwhile. Daniel?

Yes, it is true and I think that it is worth relaxing the check.

Quoted 3 lines
Quoted 1 line

How about naming this BUILD_EFI_SERVICES or some such?

Perhaps just BUILD_EFI, but yes. EFI, as used in xen.lds.S, would

s/BUILD_EFI/XEN_BUILD_EFI/?

Quoted 1 line

then perhaps better be renamed into BUILD_PE (or some such).

XEN_BUILD_PE or XEN_LINK_PE?

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel