diff mbox series

arm-bsp/trusted-firmware-a: ensure native tools respect BUILD_LDFLAGS

Message ID 20260122171805.2119993-1-ross.burton@arm.com
State New
Headers show
Series arm-bsp/trusted-firmware-a: ensure native tools respect BUILD_LDFLAGS | expand

Commit Message

Ross Burton Jan. 22, 2026, 5:18 p.m. UTC
TF-A has a number for variables to control how host binaries are built:

- Our BUILD_CC is HOSTCC; this is set in the recipes
- Our BUILD_CFLAGS is HOSTCCFLAGS; this is not set
- Our BUILD_LDFLAGS has no corresponding variable

However when uninative is enabled we really need to pass BUILD_LDFLAGS
as otherwise there can be link problems:

  ld: libcrypto.so: undefined reference to `__isoc23_strtol@GLIBC_2.38'

Patch into the TF-A makefiles support for HOSTLDFLAGS and ensure that we
set all three of the relevant BUILD_ variables.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 ...OSTLDFLAGS-to-pass-flags-to-host-lin.patch | 31 +++++++++++++++++++
 .../trusted-firmware-a/trusted-firmware-a.inc |  2 +-
 .../trusted-firmware-a_2.14.0.bb              |  2 ++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 meta-arm/recipes-bsp/trusted-firmware-a/files/0001-feat-build-add-HOSTLDFLAGS-to-pass-flags-to-host-lin.patch
diff mbox series

Patch

diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-feat-build-add-HOSTLDFLAGS-to-pass-flags-to-host-lin.patch b/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-feat-build-add-HOSTLDFLAGS-to-pass-flags-to-host-lin.patch
new file mode 100644
index 0000000000..c0820f65fb
--- /dev/null
+++ b/meta-arm/recipes-bsp/trusted-firmware-a/files/0001-feat-build-add-HOSTLDFLAGS-to-pass-flags-to-host-lin.patch
@@ -0,0 +1,31 @@ 
+From a55ee6bd2eb7e0aff6f17b933b78cb3f73ea3634 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Thu, 22 Jan 2026 16:16:27 +0000
+Subject: [PATCH] feat(build): add HOSTLDFLAGS to pass flags to host links
+
+There is a HOSTCCFLAGS variable to pass flags to all host compilations,
+but no corresponding HOSTLDFLAGS to pass flags to host links.
+
+Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/47531]
+Change-Id: I17441fc61e45d2ee41f9ab55a5d745bd0d2156d7
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ make_helpers/build_macros.mk | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk
+index 25b4fa498..a20c1ed2d 100644
+--- a/make_helpers/build_macros.mk
++++ b/make_helpers/build_macros.mk
+@@ -356,7 +356,7 @@ $(eval $(foreach src,$(SRCS),$(call MAKE_TOOL_C,$(1),$(src),$(2),$(3))))
+ 
+ $(DST): $(OBJS) $(filter-out %.d,$(MAKEFILE_LIST)) | $(1)
+ 	$$(s)echo "  HOSTLD  $$@"
+-	$$(q)$(host-cc) $${OBJS} -o $$@ $($(3)_LDFLAGS)
++	$$(q)$(host-cc) $${HOSTLDFLAGS} $${OBJS} -o $$@ $($(3)_LDFLAGS)
+ 	$$(s)echo
+ 	$$(s)echo "Built $$@ successfully"
+ 	$$(s)echo
+-- 
+2.43.0
+
diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
index 28e415e24f..6a2c0da9ca 100644
--- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
+++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
@@ -159,7 +159,7 @@  EXTRA_OEMAKE += "${@bb.utils.contains('SEL2_SPMC', '1', 'ARM_SPMC_MANIFEST_DTS=$
 # Tell the tools where the native OpenSSL is located
 EXTRA_OEMAKE += "OPENSSL_DIR=${STAGING_DIR_NATIVE}/${prefix_native}"
 # Use the correct native compiler
-EXTRA_OEMAKE += "HOSTCC='${BUILD_CC}'"
+EXTRA_OEMAKE += "HOSTCC='${BUILD_CC}' HOSTCCFLAGS='${BUILD_CFLAGS}' HOSTLDFLAGS='${BUILD_LDFLAGS}'"
 
 # Runtime variables
 EXTRA_OEMAKE += "RUNTIME_SYSROOT=${STAGING_DIR_HOST}"
diff --git a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.14.0.bb b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.14.0.bb
index b84b6ad0cf..31ad86805a 100644
--- a/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.14.0.bb
+++ b/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.14.0.bb
@@ -14,3 +14,5 @@  SRC_URI_MBEDTLS = "gitsm://github.com/Mbed-TLS/mbedtls;name=mbedtls;protocol=htt
 SRCREV_mbedtls = "e185d7fd85499c8ce5ca2a54f5cf8fe7dbe3f8df"
 
 LIC_FILES_CHKSUM_MBEDTLS = "file://mbedtls/LICENSE;md5=379d5819937a6c2f1ef1630d341e026d"
+
+SRC_URI += "file://0001-feat-build-add-HOSTLDFLAGS-to-pass-flags-to-host-lin.patch"