diff mbox series

[1/1] boot/edk2: add a new Kconfig option to pass arbitrary build options

Message ID 20250630185854.9826-1-ju.o@free.fr
State Superseded
Headers show
Series [1/1] boot/edk2: add a new Kconfig option to pass arbitrary build options | expand

Commit Message

Julien Olivain June 30, 2025, 6:58 p.m. UTC
EDK2 build may include extra options. Those are usually in the form
of "-D SOMEFLAG_ENABLE" and might be specific for a processor
architecture or a platform. For example:
"-D NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...

Those options are generally documented in their respective packages.
See for example:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/README

This commit adds a new Kconfig string option to let the use define
arbitrary build flags.

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 boot/edk2/Config.in | 15 +++++++++++++++
 boot/edk2/edk2.mk   |  1 +
 2 files changed, 16 insertions(+)

Comments

Romain Naour July 5, 2025, 9:32 p.m. UTC | #1
Hello Julien, All,

Le 30/06/2025 à 20:58, Julien Olivain via buildroot a écrit :
> EDK2 build may include extra options. Those are usually in the form
> of "-D SOMEFLAG_ENABLE" and might be specific for a processor
> architecture or a platform. For example:
> "-D NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...
> 
> Those options are generally documented in their respective packages.
> See for example:
> https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
> 
> This commit adds a new Kconfig string option to let the use define
> arbitrary build flags.
> 
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
>  boot/edk2/Config.in | 15 +++++++++++++++
>  boot/edk2/edk2.mk   |  1 +
>  2 files changed, 16 insertions(+)
> 
> diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
> index 635bb0100a..eda15df2a1 100644
> --- a/boot/edk2/Config.in
> +++ b/boot/edk2/Config.in
> @@ -119,6 +119,21 @@ config BR2_TARGET_EDK2_OVMF_DEBUG_ON_SERIAL
>  	  See OVMF README:
>  	  https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
>  
> +config BR2_TARGET_EDK2_EXTRA_BUILD_OPTS
> +	string "Extra build options"
> +	help
> +	  EDK2 build may include extra options. Those are usually in
> +	  the form of "-D SOMEFLAG_ENABLE" and might be specific for a
> +	  processor architecture or a platform. For example: "-D
> +	  NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...
> +
> +	  Those options are generally documented in their respective
> +	  packages. See for example:
> +	  https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
> +
> +	  This configuration is an arbitrary string that will be
> +	  passed to the build command.
> +
>  config BR2_TARGET_EDK2_FD_NAME
>  	string
>  	default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_I386
> diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
> index 36bcbfc88b..57d45e5fca 100644
> --- a/boot/edk2/edk2.mk
> +++ b/boot/edk2/edk2.mk
> @@ -146,6 +146,7 @@ EDK2_BUILD_ENV += \
>  	GCC5_$(EDK2_ARCH)_PREFIX=$(TARGET_CROSS)
>  
>  EDK2_BUILD_OPTS += \
> +	$(call qstrip,$(BR2_TARGET_EDK2_EXTRA_BUILD_OPTS)) \

Maybe we should use a loop here adding "-D" with the options provided by
BR2_TARGET_EDK2_EXTRA_BUILD_OPTS. Otherwise the user can add whatever he want
that could conflict with other build arguments.

I found an example of such extra options to disable PXE booting in qemu:
-D NETWORK_PXE_BOOT_ENABLE=FALSE

https://git.yoctoproject.org/meta-arm/diff/meta-arm/recipes-bsp/uefi/edk2-firmware_%25.bbappend?id=69121ff4e5b298dca16781f67f44f345e143667c

Best regards,
Romain


>  	-t GCC5 \
>  	-n $(BR2_JLEVEL) \
>  	-a $(EDK2_ARCH) \
Thomas Petazzoni Jan. 4, 2026, 10:56 a.m. UTC | #2
On Mon, 30 Jun 2025 20:58:54 +0200
Julien Olivain via buildroot <buildroot@buildroot.org> wrote:

> EDK2 build may include extra options. Those are usually in the form
> of "-D SOMEFLAG_ENABLE" and might be specific for a processor
> architecture or a platform. For example:
> "-D NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...
> 
> Those options are generally documented in their respective packages.
> See for example:
> https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
> 
> This commit adds a new Kconfig string option to let the use define
> arbitrary build flags.
> 
> Signed-off-by: Julien Olivain <ju.o@free.fr>

Sounds good to me, but one question:

>  EDK2_BUILD_OPTS += \
> +	$(call qstrip,$(BR2_TARGET_EDK2_EXTRA_BUILD_OPTS)) \

Shouldn't this go...

>  	-t GCC5 \
>  	-n $(BR2_JLEVEL) \
>  	-a $(EDK2_ARCH) \

... at the end of all options, so that BR2_TARGET_EDK2_EXTRA_BUILD_OPTS
can potentially be used to override whatever option is passed by Buildroot?

Thomas
Thomas Petazzoni Jan. 4, 2026, 10:57 a.m. UTC | #3
Hello Romain,

On Sat, 5 Jul 2025 23:32:17 +0200
Romain Naour via buildroot <buildroot@buildroot.org> wrote:

> >  EDK2_BUILD_OPTS += \
> > +	$(call qstrip,$(BR2_TARGET_EDK2_EXTRA_BUILD_OPTS)) \  
> 
> Maybe we should use a loop here adding "-D" with the options provided by
> BR2_TARGET_EDK2_EXTRA_BUILD_OPTS. Otherwise the user can add whatever he want
> that could conflict with other build arguments.

No, I disagree here. If there's an option to pass extra options I
expect it to pass all my extra options, as-is with no magic. Including
if that means that I can shoot myself in the foot by passing
conflicting options.

Thomas
Julien Olivain Jan. 4, 2026, 1:52 p.m. UTC | #4
Hi Thomas,

On 04/01/2026 11:56, Thomas Petazzoni wrote:
> On Mon, 30 Jun 2025 20:58:54 +0200
> Julien Olivain via buildroot <buildroot@buildroot.org> wrote:
> 
>> EDK2 build may include extra options. Those are usually in the form
>> of "-D SOMEFLAG_ENABLE" and might be specific for a processor
>> architecture or a platform. For example:
>> "-D NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...
>> 
>> Those options are generally documented in their respective packages.
>> See for example:
>> https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
>> 
>> This commit adds a new Kconfig string option to let the use define
>> arbitrary build flags.
>> 
>> Signed-off-by: Julien Olivain <ju.o@free.fr>
> 
> Sounds good to me, but one question:
> 
>>  EDK2_BUILD_OPTS += \
>> +	$(call qstrip,$(BR2_TARGET_EDK2_EXTRA_BUILD_OPTS)) \
> 
> Shouldn't this go...
> 
>>  	-t GCC5 \
>>  	-n $(BR2_JLEVEL) \
>>  	-a $(EDK2_ARCH) \
> 
> ... at the end of all options, so that BR2_TARGET_EDK2_EXTRA_BUILD_OPTS
> can potentially be used to override whatever option is passed by 
> Buildroot?

I agree this would be better. I've sent a v2 including your suggestion:
https://patchwork.ozlabs.org/project/buildroot/patch/20260104134755.1786447-1-ju.o@free.fr/

Best regards,

Julien.
diff mbox series

Patch

diff --git a/boot/edk2/Config.in b/boot/edk2/Config.in
index 635bb0100a..eda15df2a1 100644
--- a/boot/edk2/Config.in
+++ b/boot/edk2/Config.in
@@ -119,6 +119,21 @@  config BR2_TARGET_EDK2_OVMF_DEBUG_ON_SERIAL
 	  See OVMF README:
 	  https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
 
+config BR2_TARGET_EDK2_EXTRA_BUILD_OPTS
+	string "Extra build options"
+	help
+	  EDK2 build may include extra options. Those are usually in
+	  the form of "-D SOMEFLAG_ENABLE" and might be specific for a
+	  processor architecture or a platform. For example: "-D
+	  NETWORK_HTTP_BOOT_ENABLE", "-D NETWORK_TLS_ENABLE", ...
+
+	  Those options are generally documented in their respective
+	  packages. See for example:
+	  https://github.com/tianocore/edk2/blob/master/OvmfPkg/README
+
+	  This configuration is an arbitrary string that will be
+	  passed to the build command.
+
 config BR2_TARGET_EDK2_FD_NAME
 	string
 	default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_I386
diff --git a/boot/edk2/edk2.mk b/boot/edk2/edk2.mk
index 36bcbfc88b..57d45e5fca 100644
--- a/boot/edk2/edk2.mk
+++ b/boot/edk2/edk2.mk
@@ -146,6 +146,7 @@  EDK2_BUILD_ENV += \
 	GCC5_$(EDK2_ARCH)_PREFIX=$(TARGET_CROSS)
 
 EDK2_BUILD_OPTS += \
+	$(call qstrip,$(BR2_TARGET_EDK2_EXTRA_BUILD_OPTS)) \
 	-t GCC5 \
 	-n $(BR2_JLEVEL) \
 	-a $(EDK2_ARCH) \