From patchwork Fri Sep 5 17:01:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 245 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091736; bh=IqDDdO7OegmYJ9XapAZsNj0Xdk36hGmzuj5quXR5g54=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eQFIyPR0uLguQtD7WL9XrgjgP/acfvbZcQ9b7xvXHQmQAkW2xBIB565Ng20IqlZvc BJxD0L4Ox0zITi88oCXO0gvx/8KS7bR9LgczcSyimmI+mcOoGg2GvyURkx5aFFjUhW yppVfTYpJJTEdZIDUgW6tLlM72VyPYrWAFqgE7mgE6Iyoci51h3Rh3FS8Wm/evSwfC Fn8qlmIIKe3+uTFXdqTKHxInfDTVZHXl8qJIw6HCCdRRW5moRwiF7UoO4yYOGV7r7S feJXfzuJy02zsztaXSV742g/q7BohiTp67XO0+0o6PBomUQLi4prQBjbC2q1SevSxa 6ZsCM6RbXIwtw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A071F6799D for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VzOLYf07JFEK for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091736; bh=IqDDdO7OegmYJ9XapAZsNj0Xdk36hGmzuj5quXR5g54=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eQFIyPR0uLguQtD7WL9XrgjgP/acfvbZcQ9b7xvXHQmQAkW2xBIB565Ng20IqlZvc BJxD0L4Ox0zITi88oCXO0gvx/8KS7bR9LgczcSyimmI+mcOoGg2GvyURkx5aFFjUhW yppVfTYpJJTEdZIDUgW6tLlM72VyPYrWAFqgE7mgE6Iyoci51h3Rh3FS8Wm/evSwfC Fn8qlmIIKe3+uTFXdqTKHxInfDTVZHXl8qJIw6HCCdRRW5moRwiF7UoO4yYOGV7r7S feJXfzuJy02zsztaXSV742g/q7BohiTp67XO0+0o6PBomUQLi4prQBjbC2q1SevSxa 6ZsCM6RbXIwtw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FE17678E6 for ; Fri, 5 Sep 2025 11:02:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091733; bh=gJHq+1uMrKQtFSeMUFKDIAp34DppQ+IUjx3cI5zbKpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYaFJPBMG57P1ttaQA1XOOmpAtWCqeeF+IcRE9qHHFU1spmJiiHeA806v5GKitM9y AlNQNue9A0sTYbGdORIJGE3shmK+poiZ40Z7EOmGayJNWnJZGQzvUj0Mx8dXuAs+wS NYEw1QyMjSFihPsMheesaeA5lAXOTFlq2AF4MKQbZYj4FzZyAp+KIk3pfmnB21zH5u BLCMP10je7CIjVOFiAoR6P1iW80xAz5kky1lHCugYiULTk6AbKFTa0+r6ECeJGicxR DPEgKS0FpL/NzIf4FSljBGtq+EnhRbi99Zzm9Tewv0Kf1RNKK3GyaAXqgIQpb3Xbm7 pfdDhKmHeo7jA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 92BC7678AA; Fri, 5 Sep 2025 11:02:13 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id R0DMm99EDtEP; Fri, 5 Sep 2025 11:02:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091729; bh=OVxyuJNZuO2SivfnMB5T8VA7Lexz25rPZ2xPrH0NNr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEtOVnhnxisC1+JlL00a6l5Wehqu4o0rV9X6GODEFWx6paePnCDDVv4UzBXO+IXtY wAv2AoWdwBRcgqaoB/Ow4s3MGa8ZftWsr6Cej2aM6RyjXx7EGxQ9lnPCxFeu7QA+ak 0Wn8De6iJ/fBsqMT8BmboifO2p37A7MomaNbnx04CYgrkRdUv7fkS+CVj2aG/MvqAH GLKiR1KIfKFrO8BTPG4A1H4ep81IQUn1wbS2gXfb0MjcCoL4pX+7wKZqsO3gI70hxy gi/gTG/aGgFCMXmacuw/P92fXrV7YukNiPI9nc35fkD0aCuXq00HNTo5hxCqGk6Bt+ BpTm5ecZMMEmA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 259AD678E6; Fri, 5 Sep 2025 11:02:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:19 -0600 Message-ID: <20250905170132.182249-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Y24DTZULLPEJSAUR5YVRC3XYHHOMRKGW X-Message-ID-Hash: Y24DTZULLPEJSAUR5YVRC3XYHHOMRKGW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/15] ulib: Add static-library build support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Sometimes it is more convenient to link an application directly with a static library. Add build rules to create libu-boot.a as a static library alongside the existing shared library (libu-boot.so). The static library is a fat archive containing all U-Boot object files except for arch/sandbox/cpu/main.o since it contains main(). A temporary thin archive is used to collect all the objects. Co-developed-by: Claude Signed-off-by: Simon Glass --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile b/Makefile index 1a378ebbee3..bf571de9f06 100644 --- a/Makefile +++ b/Makefile @@ -1046,6 +1046,7 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ ifdef CONFIG_CMDLINE ifneq ($(cc-name),clang) INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test +INPUTS-$(CONFIG_ULIB) += libu-boot.a endif endif @@ -1869,6 +1870,20 @@ libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) \ $(LIB_LDS) FORCE $(call if_changed,libu-boot.so) +# Build U-Boot as a static library +# Create a fat archive with all object files (except arch/sandbox/cpu/main.o) +# Avoid partial linking so as to preserve the linker-list sections +quiet_cmd_libu-boot.a = AR $@ + cmd_libu-boot.a = rm -f $@ $@.tmp $@.objlist; \ + $(AR) rcT $@.tmp $(u-boot-init) $(u-boot-main) \ + $(u-boot-keep-syms-lto); \ + $(AR) t $@.tmp | grep -v "arch/sandbox/cpu/main\.o$$" > $@.objlist; \ + cat $@.objlist | xargs $(AR) rcs $@; \ + rm -f $@.tmp $@.objlist + +libu-boot.a: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE + $(call if_changed,libu-boot.a) + # Build ulib_test that links with shared library quiet_cmd_ulib_test = HOSTCC $@ cmd_ulib_test = $(HOSTCC) $(HOSTCFLAGS) \