[Concept,01/17] ulib: Skip empty archives in build_api.py objcopy step

Message ID 20260216013511.4079770-2-sjg@u-boot.org
State New
Headers
Series ulib: Add multi-arch demo and EFI app support |

Commit Message

Simon Glass Feb. 16, 2026, 1:34 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When CONFIG_ULIB is enabled for cross-compiled EFI builds, some
built-in.o archives are empty (e.g. arch/riscv/cpu/generic/built-in.o
for efi-riscv_app64). The objcopy --redefine-sym command fails on
empty files.

Skip them by checking the file size before calling objcopy, producing
an empty output file to keep the archive list consistent.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 scripts/build_api.py | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/scripts/build_api.py b/scripts/build_api.py
index aa8b4f16a1a..a82cd83503c 100755
--- a/scripts/build_api.py
+++ b/scripts/build_api.py
@@ -356,6 +356,12 @@  class SymbolRedefiner:
         Returns:
             bool: True if file was modified, False otherwise
         """
+        # Skip empty archives (objcopy cannot process them)
+        if os.path.getsize(path) == 0:
+            with open(outfile, 'wb'):
+                pass
+            return False
+
         # Always run objcopy to apply redefinitions
         self.redefine_file(path, outfile)