diff mbox series

edk2-firmware: fix SOURCE_DATE_EPOCH

Message ID 20250331110446.33082-1-mikko.rapeli@linaro.org
State New
Headers show
Series edk2-firmware: fix SOURCE_DATE_EPOCH | expand

Commit Message

Mikko Rapeli March 31, 2025, 11:04 a.m. UTC
edk2-firmware build scripts use printenv to print SOURCE_DATE_EPOCH
but that is not in HOSTTOOLS and thus fails. Change to using
environment variable directly to fix builds. I think this is OE
specific build config change and thus not submitted to upstream.

Applying patch in 202411 recipe and not .inc since 202408 recipe
from meta-arm-bsp does not find the patch file from meta-arm
side.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 .../recipes-bsp/uefi/edk2-firmware_202411.bb  |  4 +++
 .../uefi/files/edk2_fix_epoch.patch           | 27 +++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 meta-arm/recipes-bsp/uefi/files/edk2_fix_epoch.patch
diff mbox series

Patch

diff --git a/meta-arm/recipes-bsp/uefi/edk2-firmware_202411.bb b/meta-arm/recipes-bsp/uefi/edk2-firmware_202411.bb
index 5892a485..22e72434 100644
--- a/meta-arm/recipes-bsp/uefi/edk2-firmware_202411.bb
+++ b/meta-arm/recipes-bsp/uefi/edk2-firmware_202411.bb
@@ -5,3 +5,7 @@  SRCREV_edk2-platforms ?= "2d66a9e048285af8ba4bfe4bdaab37a8e98288b3"
 TOOLCHAIN:aarch64 = "gcc"
 
 require recipes-bsp/uefi/edk2-firmware.inc
+
+SRC_URI += "\
+    file://edk2_fix_epoch.patch \
+"
diff --git a/meta-arm/recipes-bsp/uefi/files/edk2_fix_epoch.patch b/meta-arm/recipes-bsp/uefi/files/edk2_fix_epoch.patch
new file mode 100644
index 00000000..278de593
--- /dev/null
+++ b/meta-arm/recipes-bsp/uefi/files/edk2_fix_epoch.patch
@@ -0,0 +1,27 @@ 
+edk2-firmware: fix SOURCE_DATE_EPOCH use
+
+printenv host tool is not exposed to recipes so
+just set epoch using SOURCE_DATE_EPOCH which is always
+set. Fixes compile error:
+
+Building ... ../build/tmp_zynqmp-kria-starter-psa/work/zynqmp_kria_starter_psa-poky-linux/edk2-firmware/202411/edk2/MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf [AARCH64]
+../build/tmp_zynqmp-kria-starter-psa/work/zynqmp_kria_starter_psa-poky-linux/edk2-firmware/202411/edk2/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c: In function 'LibGetTime':
+<command-line>: error: stray '`' in program
+../build/tmp_zynqmp-kria-starter-psa/work/zynqmp_kria_starter_psa-poky-linux/edk2-firmware/202411/edk2/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c:89:20: note: in expansion of macro 'BUILD_EPOCH'
+   89 |     EpochSeconds = BUILD_EPOCH;
+      |                    ^~~~~~~~~~~
+
+Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
+
+Upstream-Status: Inappropriate [OE specific build config fix]
+
+diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
+index 285e880daa..e1c986a653 100644
+--- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
++++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
+@@ -34,4 +34,4 @@
+ 
+ # Current usage of this library expects GCC in a UNIX-like shell environment with the date command
+ [BuildOptions]
+-  GCC:*_*_*_CC_FLAGS = -DBUILD_EPOCH=`printenv SOURCE_DATE_EPOCH || date +%s`
++  GCC:*_*_*_CC_FLAGS = -DBUILD_EPOCH=${SOURCE_DATE_EPOCH}