Skip to contentSkip to conversation

roms: Avoid iPXE/EDK2 EFIROM variable clash, pass CFLAGS to EDK2 build tools

PATCH In review Philippe Mathieu-Daudé 5 participants 11 messages Apr 9, 2019

lore
Share & tools
lore
#0 lore raw

v3 cover roms: Avoid iPXE/EDK2 EFIROM variable clash, pass CFLAGS to EDK2 build tools

Hi,

Two trivial fixes to avoid the latest EDK2 testing series to cause trouble to downstream distributions (in particular if they have PIE enforced).

Since v2:
- addressed Laszlo's suggestion
- reworded patch description

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01033.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01006.html
error report: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00992.html

Regards,

Phil.

Philippe Mathieu-Daudé (2):
roms: Rename the EFIROM variable to avoid clashing with iPXE
roms: Allow passing configure options to the EDK2 build tools

 roms/Makefile | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 1/2 roms: Rename the EFIROM variable to avoid clashing with iPXE

The iPXE's 'veryclean' recipe removes $(EFIROM) even if the EFIROM macro originates from elsewhere:

  $ git checkout f590a812c21~
  $ make -C roms clean EFIROM=$(type -P EfiRom)
  make: Entering directory '/source/qemu/roms'
  [...]
  make -C ipxe/src veryclean
  make[1]: Entering directory '/source/qemu/roms/ipxe/src'
  rm -f bin{,-*}/*.* bin{,-*}/.certificate.* bin{,-*}/.certificates.* bin{,-*}/.private_key.* bin{,-*}/errors bin{,-*}/NIC ./util/zbin ./util/elf2efi32 ./util/elf2efi64 /usr/bin/EfiRom ./util/efifatbin ./util/iccfix ./util/einfo TAGS bin{,-*}/symtab
  rm: cannot remove '/usr/bin/EfiRom': Permission denied
  make[1]: *** [Makefile.housekeeping:1564: clean] Error 1
  make[1]: Leaving directory '/source/qemu/roms/ipxe/src'
  make: *** [Makefile:152: clean] Error 2
  make: Leaving directory '/source/qemu/roms'

Before f590a812c21 this variable could be overridden or unset, and the 'veryclean' Makefile rule would not complain.

Commit f590a812c21 enforces this variable to the Intel EfiRom tool provided by the EDK2 project.

To avoid the name clash and make the difference between the projects obvious, rename the variable used by the EDK2 project as EDK2_EFIROM.

Fixes f590a812c21074e82228de3e1dfb57b75fc02b62
---
 roms/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
roms/Makefile +4 -4
index 78d5dd18c30..d28252dafdf 100644
@@ -47,7 +47,7 @@ SEABIOS_EXTRAVERSION="-prebuilt.qemu.org"
 # We need that to combine multiple images (legacy bios,
 # efi ia32, efi x64) into a single rom binary.
 #
-EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
+EDK2_EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
 
 default:
 	@echo "nothing is build by default"
@@ -102,8 +102,8 @@ pxe-rom-%: build-pxe-roms
 
 efirom: $(patsubst %,efi-rom-%,$(pxerom_variants))
 
-efi-rom-%: build-pxe-roms build-efi-roms $(EFIROM)
-	$(EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
+efi-rom-%: build-pxe-roms build-efi-roms $(EDK2_EFIROM)
+	$(EDK2_EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
 		-b ipxe/src/bin/$(VID)$(DID).rom \
 		-ec ipxe/src/bin-i386-efi/$(VID)$(DID).efidrv \
 		-ec ipxe/src/bin-x86_64-efi/$(VID)$(DID).efidrv \
@@ -120,7 +120,7 @@ build-efi-roms: build-pxe-roms
 		$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
 		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
-$(EFIROM):
+$(EDK2_EFIROM):
 	$(MAKE) -C edk2/BaseTools
 
 slof:
Signature · 1 line
2.20.1
#2 lore raw

Re: [Qemu-devel] [PATCH for-4.0 v3 1/2] roms: Rename the EFIROM variable to avoid clashing with iPXE

Quoted 60 lines · Philippe Mathieu-Daudé

The iPXE's 'veryclean' recipe removes $(EFIROM) even if the EFIROM macro originates from elsewhere:

  $ git checkout f590a812c21~
  $ make -C roms clean EFIROM=$(type -P EfiRom)
  make: Entering directory '/source/qemu/roms'
  [...]
  make -C ipxe/src veryclean
  make[1]: Entering directory '/source/qemu/roms/ipxe/src'
  rm -f bin{,-*}/*.* bin{,-*}/.certificate.* bin{,-*}/.certificates.* bin{,-*}/.private_key.* bin{,-*}/errors bin{,-*}/NIC ./util/zbin ./util/elf2efi32 ./util/elf2efi64 /usr/bin/EfiRom ./util/efifatbin ./util/iccfix ./util/einfo TAGS bin{,-*}/symtab
  rm: cannot remove '/usr/bin/EfiRom': Permission denied
  make[1]: *** [Makefile.housekeeping:1564: clean] Error 1
  make[1]: Leaving directory '/source/qemu/roms/ipxe/src'
  make: *** [Makefile:152: clean] Error 2
  make: Leaving directory '/source/qemu/roms'

Before f590a812c21 this variable could be overridden or unset, and the 'veryclean' Makefile rule would not complain.

Commit f590a812c21 enforces this variable to the Intel EfiRom tool provided by the EDK2 project.

To avoid the name clash and make the difference between the projects obvious, rename the variable used by the EDK2 project as EDK2_EFIROM.

Fixes f590a812c21074e82228de3e1dfb57b75fc02b62
---
 roms/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
roms/Makefile +3 -3
index 78d5dd18c30..d28252dafdf 100644
@@ -47,7 +47,7 @@ SEABIOS_EXTRAVERSION="-prebuilt.qemu.org"
 # We need that to combine multiple images (legacy bios,
 # efi ia32, efi x64) into a single rom binary.
 #
-EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
+EDK2_EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
 
 default:
 	@echo "nothing is build by default"
@@ -102,8 +102,8 @@ pxe-rom-%: build-pxe-roms
 
 efirom: $(patsubst %,efi-rom-%,$(pxerom_variants))
 
-efi-rom-%: build-pxe-roms build-efi-roms $(EFIROM)
-	$(EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
+efi-rom-%: build-pxe-roms build-efi-roms $(EDK2_EFIROM)
+	$(EDK2_EFIROM) -f "0x$(VID)" -i "0x$(DID)" -l 0x02 \
 		-b ipxe/src/bin/$(VID)$(DID).rom \
 		-ec ipxe/src/bin-i386-efi/$(VID)$(DID).efidrv \
 		-ec ipxe/src/bin-x86_64-efi/$(VID)$(DID).efidrv \

roms/Makefile build-efi-roms: build-pxe-roms · line 126

Quoted 8 lines
roms/Makefile +1 -1
@@ -120,7 +120,7 @@ build-efi-roms: build-pxe-roms
 		$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
 		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
-$(EFIROM):
+$(EDK2_EFIROM):
 	$(MAKE) -C edk2/BaseTools
 
 slof:

looks good, thank you; my R-b stands.

Laszlo

#3 lore raw

PATCH v3 2/2 roms: Allow passing configure options to the EDK2 build tools

In reply to Philippe Mathieu-Daudé

Since commit f590a812c210 we build the EDK2 EfiRom utility unconditionally.

Some distributions require to use extra compiler/linker flags, i.e. SUSE which enforces the PIE protection (see [*]).

EDK2 build tools already provide a set of variables for that, use them to allow the caller to easily inject compiler/linker options..

Now build scripts can pass extra options, example:

  $ make -C roms \
      EDK2_BASETOOLS_OPTFLAGS='-fPIE' \
      efirom

[*] https://lists.opensuse.org/opensuse-factory/2017-06/msg00403.html

---
 roms/Makefile | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
roms/Makefile +14 -1
index d28252dafdf..1ff78b63bb3 100644
@@ -120,8 +120,21 @@ build-efi-roms: build-pxe-roms
 		$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
 		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
+# Build scripts can pass compiler/linker flags to the EDK2 build tools
+# via the EDK2_BASETOOLS_OPTFLAGS (CPPFLAGS and CFLAGS) and
+# EDK2_BASETOOLS_LDFLAGS (LDFLAGS) environment variables.
+#
+# Example:
+#
+#  make -C roms \
+#    EDK2_BASETOOLS_OPTFLAGS='...' \
+#    EDK2_BASETOOLS_LDFLAGS='...' \
+#    efirom
+#
 $(EDK2_EFIROM):
-	$(MAKE) -C edk2/BaseTools
+	$(MAKE) -C edk2/BaseTools \
+		EXTRA_OPTFLAGS='$(EDK2_BASETOOLS_OPTFLAGS)' \
+		EXTRA_LDFLAGS='$(EDK2_BASETOOLS_LDFLAGS)'
 
 slof:
 	$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
Signature · 1 line
2.20.1
Reviewed-by on v3 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH for-4.0 v3 2/2] roms: Allow passing configure options to the EDK2 build tools

Quoted 16 lines · On Tue, 9 Apr 2019 15:45:36 +0200 Philippe Mathieu-Daudé <[email protected]>…

Since commit f590a812c210 we build the EDK2 EfiRom utility unconditionally.

Some distributions require to use extra compiler/linker flags, i.e. SUSE which enforces the PIE protection (see [*]).

EDK2 build tools already provide a set of variables for that, use them to allow the caller to easily inject compiler/linker options..

Now build scripts can pass extra options, example:

  $ make -C roms \
      EDK2_BASETOOLS_OPTFLAGS='-fPIE' \
      efirom
Quoted 5 lines

[*] https://lists.opensuse.org/opensuse-factory/2017-06/msg00403.html

Quoted 31 lines
---
 roms/Makefile | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
roms/Makefile +14 -1
index d28252dafdf..1ff78b63bb3 100644
@@ -120,8 +120,21 @@ build-efi-roms: build-pxe-roms
 		$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
 		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
+# Build scripts can pass compiler/linker flags to the EDK2 build tools
+# via the EDK2_BASETOOLS_OPTFLAGS (CPPFLAGS and CFLAGS) and
+# EDK2_BASETOOLS_LDFLAGS (LDFLAGS) environment variables.
+#
+# Example:
+#
+#  make -C roms \
+#    EDK2_BASETOOLS_OPTFLAGS='...' \
+#    EDK2_BASETOOLS_LDFLAGS='...' \
+#    efirom
+#
 $(EDK2_EFIROM):
-	$(MAKE) -C edk2/BaseTools
+	$(MAKE) -C edk2/BaseTools \
+		EXTRA_OPTFLAGS='$(EDK2_BASETOOLS_OPTFLAGS)' \
+		EXTRA_LDFLAGS='$(EDK2_BASETOOLS_LDFLAGS)'
 
 slof:
 	$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
Reviewed-by on v3 2/2
#5 lore raw

Re: [Qemu-devel] [PATCH for-4.0 v3 2/2] roms: Allow passing configure options to the EDK2 build tools

In reply to Philippe Mathieu-Daudé
Quoted 43 lines · Philippe Mathieu-Daudé

Since commit f590a812c210 we build the EDK2 EfiRom utility unconditionally.

Some distributions require to use extra compiler/linker flags, i.e. SUSE which enforces the PIE protection (see [*]).

EDK2 build tools already provide a set of variables for that, use them to allow the caller to easily inject compiler/linker options..

Now build scripts can pass extra options, example:

  $ make -C roms \
      EDK2_BASETOOLS_OPTFLAGS='-fPIE' \
      efirom

[*] https://lists.opensuse.org/opensuse-factory/2017-06/msg00403.html

---
 roms/Makefile | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
roms/Makefile +9 -0
index d28252dafdf..1ff78b63bb3 100644
@@ -120,8 +120,21 @@ build-efi-roms: build-pxe-roms
 		$(patsubst %,bin-i386-efi/%.efidrv,$(pxerom_targets)) \
 		$(patsubst %,bin-x86_64-efi/%.efidrv,$(pxerom_targets))
 
+# Build scripts can pass compiler/linker flags to the EDK2 build tools
+# via the EDK2_BASETOOLS_OPTFLAGS (CPPFLAGS and CFLAGS) and
+# EDK2_BASETOOLS_LDFLAGS (LDFLAGS) environment variables.
+#
+# Example:
+#
+#  make -C roms \
+#    EDK2_BASETOOLS_OPTFLAGS='...' \
+#    EDK2_BASETOOLS_LDFLAGS='...' \

roms/Makefile build-efi-roms: build-pxe-roms · line 140

Quoted 10 lines
roms/Makefile +5 -1
+#    efirom
+#
 $(EDK2_EFIROM):
-	$(MAKE) -C edk2/BaseTools
+	$(MAKE) -C edk2/BaseTools \
+		EXTRA_OPTFLAGS='$(EDK2_BASETOOLS_OPTFLAGS)' \
+		EXTRA_LDFLAGS='$(EDK2_BASETOOLS_LDFLAGS)'
 
 slof:
 	$(MAKE) -C SLOF CROSS=$(powerpc64_cross_prefix) qemu
#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 17 lines · Philippe Mathieu-Daudé

Hi,

Two trivial fixes to avoid the latest EDK2 testing series to cause trouble to downstream distributions (in particular if they have PIE enforced).

Since v2:
- addressed Laszlo's suggestion
- reworded patch description

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01033.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01006.html
error report: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00992.html

Regards,

Quoted 8 lines

Phil.

Philippe Mathieu-Daudé (2):
roms: Rename the EFIROM variable to avoid clashing with iPXE
roms: Allow passing configure options to the EDK2 build tools

 roms/Makefile | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

Thanks. This is one of a handful of remaining bugs we should fix for 4.0, so I would ideally like to get this in rc3 today (or tomorrow if we have to slip rc3 a day). If people wanting to review this series could do so promptly I'd definitely appreciate it.

-- PMM

#7 lore raw
Quoted 27 lines · Peter Maydell
Quoted 17 lines · Philippe Mathieu-Daudé

Hi,

Two trivial fixes to avoid the latest EDK2 testing series to cause trouble to downstream distributions (in particular if they have PIE enforced).

Since v2:
- addressed Laszlo's suggestion
- reworded patch description

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01033.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01006.html
error report: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00992.html

Regards,

Quoted 8 lines

Phil.

Philippe Mathieu-Daudé (2):
roms: Rename the EFIROM variable to avoid clashing with iPXE
roms: Allow passing configure options to the EDK2 build tools

 roms/Makefile | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
Quoted 8 lines

Thanks. This is one of a handful of remaining bugs we should fix for 4.0, so I would ideally like to get this in rc3 today (or tomorrow if we have to slip rc3 a day). If people wanting to review this series could do so promptly I'd definitely appreciate it.

-- PMM

I hope I was quick enough.

Thanks,
Laszlo

#8 lore raw
Quoted 9 lines · Laszlo Ersek
Quoted 5 lines · Peter Maydell

Thanks. This is one of a handful of remaining bugs we should fix for 4.0, so I would ideally like to get this in rc3 today (or tomorrow if we have to slip rc3 a day). If people wanting to review this series could do so promptly I'd definitely appreciate it.

I hope I was quick enough.

Yep, thanks. (I knew you'd had comments on v1 so I was assuming you'd want to review v2.)

thanks
-- PMM

Reviewed-by on the v3 series
#9 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Hi,

Two trivial fixes to avoid the latest EDK2 testing series to cause trouble to downstream distributions (in particular if they have PIE enforced).

Since v2:
- addressed Laszlo's suggestion
- reworded patch description

Quoted 7 lines

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01033.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01006.html
error report: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00992.html

Regards,

Phil.

Peter do you want to merge this directly?

Quoted 9 lines

Philippe Mathieu-Daudé (2):
roms: Rename the EFIROM variable to avoid clashing with iPXE
roms: Allow passing configure options to the EDK2 build tools

 roms/Makefile | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
#10 lore raw
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Philippe Mathieu-Daudé

Hi,

Two trivial fixes to avoid the latest EDK2 testing series to cause trouble to downstream distributions (in particular if they have PIE enforced).

Since v2:
- addressed Laszlo's suggestion
- reworded patch description

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01033.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01006.html
error report: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg00992.html

Quoted 8 lines
Quoted 3 lines

Regards,

Phil.

Peter do you want to merge this directly?

Yes, I'll do that.

thanks
-- PMM