From patchwork Sat Feb 14 02:13:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1870 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=1771035256; bh=MiAemH0DLZMZTZyYNiughL2iEleIGXvnbZD5B9d4vRI=; 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=vy+4s6ZbLfIXpdWEP/sXPoZve8R+SBNckGIIkNn/fSwClW7Ju4j2+DeVMmGqwt94+ xBO9XhvHL6ep3AMjNziqbdSbsPCAM6pM+LdC3DcgsZVJCOvb1H29BwLpqH4x7BLjhl 3N4bisYXNbWItE3ySr11TqizLlM3nRy2EnJDU/CFc7fAiRDvdngTu+oWc0UfdyBG8A 378+AQqU7qo+AH1VVx/fa2YzHn1DmyKkyEOiSJtMDopHpywoRQ5hR3iqo8tfAsWI8l RA5UoFRmzxph2X6cDUOMsiHSZDebScgFTeZg01nkvg6QkLE+4g+kRU4imsT8fUyGQk xPN2OR+OipnOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8604369B69 for ; Fri, 13 Feb 2026 19:14:16 -0700 (MST) 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 V7G0u9RclDW6 for ; Fri, 13 Feb 2026 19:14:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035254; bh=MiAemH0DLZMZTZyYNiughL2iEleIGXvnbZD5B9d4vRI=; 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=O1C0NcjlpmOsDkYgGlh5Il0eYp5plmHZRZgnADZdzhmviCxOkHxW3+4P1QqKBpSPB i7qdY1q3fbHHtMWrrpPfU8u+6LtgesrRoXQMyNkkjzEy8pQYftg/8UYCIXMLdJFrkO c/WP4Xc7sfesKLnPe9YbsiNkELEie/uAx7GNPuNBigg4PxtBjvLzZPW3CI573wk4Fd 0pI037Jr04RQ+l2/L780b6K2NIDLvsPUZPXpf8orZgdgpYmDzBn6OTIXHnQ3ljr2ns DdRKJPB4QxulOORVaubMYNblJG1H/Ph8/exICxQBgHnRpS3Drz2abFJPmkqVzxXGol PU3YovglRKwKg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7F8A469A69 for ; Fri, 13 Feb 2026 19:14:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035253; bh=8mXUVF3wIZw3Y9jH9a2p2RL8gtxMuP9W4EsgMmOVRnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7APGr9+pHj4QlonGkktugAGXz0wYmt2/KAKAQQykp09NDZ/dRZFA8/DITma37Tag EM+WbHPjqFWqBgAZqSGlr+RaB9MapYlNUZYA43QdskYV6p1v6B8R/PeEq13/1Malc9 diID7kPMYE47Ww7AM+l+ebHk/iRZhMPJUHN9uKNxEZu3EOnmnC8swpXLKvXwWZTrq3 L8NjjgfPEQ7Kx2+rI9xXhmonA+FySdRM4K/bMBcjARAzvH7MQgkjuh1ENPXuDuDntw wn01LVxNJLgiKodh7SbI+7DR1ilIHb7FTNGmUQQxQ0+W2J+GthYsqskcFVg537FYA5 xbgcvgzvUQb0A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A7F0569B56; Fri, 13 Feb 2026 19:14:13 -0700 (MST) 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 1tonq2rUbULS; Fri, 13 Feb 2026 19:14:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035253; bh=+ex/23NgZh1FKxIQcdJ2O49dQiwOpehkLoznBuMw/a4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWZlQ7DaZUZy31DcYc0dNx89K59NJ5AZCzcbTHmQ/n7GGb1MsaFjBeQETGx+vaSkK 1R6fq3l/Rk2uZy3ClwK2UWrwjolJ2zT/nFOD4S9eY3TEIlsq+YRs4UtUq4YbJ87V3V 18MBR/i28bcoYuXsSELc67z/V3BRwu+rQReGoUDlm+w/YjfwNm3ke+PcWfGVJHk6os T0UoK7Es9q3zovMEnbpasUXazMenQg7W1dWqBvTMl7e8FHe2bM+ny3SYzaWahvbwT6 ePnZJmSN+zFBxSIzF1EDANF/gtvwDQEacJIt7XNseM1udRuoDZtBQLGO5zf4TDyijt GwaZWXuHs/KHQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 07F9069A69; Fri, 13 Feb 2026 19:14:12 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 13 Feb 2026 19:13:04 -0700 Message-ID: <20260214021317.816170-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260214021317.816170-1-sjg@u-boot.org> References: <20260214021317.816170-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XNWDAG5B4CTUF6P5RY3YXUDHF4XH72I6 X-Message-ID-Hash: XNWDAG5B4CTUF6P5RY3YXUDHF4XH72I6 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 Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/13] x86: ulib: Add build infrastructure for example/ 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 Add the kbuild and Makefile plumbing to compile and link ulib example programs for x86: - examples/ulib/Kbuild compiles demo objects via kbuild (not linked into u-boot itself) - examples/Makefile hooks the ulib subdirectory for non-sandbox builds - arch/x86/Makefile re-links u-boot with the example objects using the u-boot-link helper, so the example's strong main() overrides the weak default, then objcopy produces a flat binary Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- arch/x86/Makefile | 32 ++++++++++++++++++++++++++++++++ examples/Makefile | 4 ++++ examples/ulib/Kbuild | 6 ++++++ 3 files changed, 42 insertions(+) create mode 100644 examples/ulib/Kbuild diff --git a/arch/x86/Makefile b/arch/x86/Makefile index e8813aa7e28..7df20c43de1 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -64,3 +64,35 @@ u-boot-x86-start16.bin: u-boot-x86-16bit.elf FORCE u-boot-x86-reset16.bin: u-boot-x86-16bit.elf FORCE $(call if_changed,objcopy) endif + +# x86 example targets: re-link U-Boot with example objects providing main() +# +# The example .o files are compiled via kbuild (examples/ulib/Kbuild). +# This re-links u-boot with those objects so the example's strong main() +# overrides the weak one in board_r.c, using the shared u-boot-link helper. +ifdef CONFIG_EXAMPLES +INPUTS-$(CONFIG_ULIB) += examples_x86 + +PHONY += examples_x86 + +X86_EXAMPLES := demo + +quiet_cmd_u-boot-example = LD $@ + cmd_u-boot-example = $(call u-boot-link,$(example-objs),$@.map) + +# Per-example object lists (matches examples/ulib/Makefile:demo_objs) +example-demo-objs := examples/ulib/demo.o examples/ulib/demo_helper.o + +# Link each example ELF (depends on u-boot to ensure archives exist) +examples/ulib/demo: $(example-demo-objs) u-boot FORCE + $(eval example-objs := $(example-demo-objs)) + $(call if_changed,u-boot-example) + +# Binary targets (same objcopy flags as u-boot-nodtb.bin) +OBJCOPYFLAGS_demo-nodtb.bin = $(OBJCOPYFLAGS_u-boot-nodtb.bin) +examples/ulib/demo-nodtb.bin: examples/ulib/demo FORCE + $(call if_changed,objcopy) + +examples_x86: $(foreach e,$(X86_EXAMPLES),examples/ulib/$(e)-nodtb.bin) FORCE + @: +endif diff --git a/examples/Makefile b/examples/Makefile index 50bef4e6157..21c703d144b 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -8,4 +8,8 @@ endif subdir-$(EXAMPLES_STANDALONE) += standalone subdir-$(CONFIG_LEGACY_API) += api +# Sandbox examples use the standalone Makefile; other archs use kbuild +ifndef CONFIG_SANDBOX +subdir-$(CONFIG_ULIB) += ulib +endif endif diff --git a/examples/ulib/Kbuild b/examples/ulib/Kbuild new file mode 100644 index 00000000000..88d6a805b91 --- /dev/null +++ b/examples/ulib/Kbuild @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Example objects for x86 platforms (compiled via kbuild, not linked into +# u-boot). The standalone Makefile is used for sandbox builds instead. + +extra-y += demo.o demo_helper.o