mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/9] sandbox: source/invoke um Makefiles provided by host architecture
Date: Mon, 25 Nov 2024 16:35:17 +0100	[thread overview]
Message-ID: <20241125153523.1411849-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241125153523.1411849-1-a.fatoum@pengutronix.de>

It can make sense to use an existing arch's implementation for low-level
things like setjmp/longjmp. Copy the Linux scheme that enables this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 Makefile                |  2 ++
 arch/sandbox/Makefile   |  9 +++++++++
 scripts/subarch.include | 11 +++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 scripts/subarch.include

diff --git a/Makefile b/Makefile
index aa66d0cf3b38..bc75c6335177 100644
--- a/Makefile
+++ b/Makefile
@@ -321,6 +321,8 @@ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S
 BUILDSYSTEM_VERSION =
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION BUILDSYSTEM_VERSION
 
+include $(srctree)/scripts/subarch.include
+
 # Cross compiling and selecting different set of gcc/bin-utils
 # ---------------------------------------------------------------------------
 #
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 8f6425760619..157e856c59b1 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -19,6 +19,14 @@ board-y := arch/sandbox/board
 BOARD	:= $(board-y)/
 lds-y   := $(BOARD)/barebox.lds
 
+HEADER_ARCH 	:= $(SUBARCH)
+HOST_DIR := arch/$(HEADER_ARCH)
+
+-include $(srctree)/$(HOST_DIR)/Makefile.um
+
+common-y += $(HOST_DIR)/um/
+
+KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include
 
 TEXT_BASE = $(CONFIG_TEXT_BASE)
 KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
@@ -49,6 +57,7 @@ machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 
 archprepare: maketools
+	$(Q)$(MAKE) $(build)=$(HOST_DIR)/um
 
 PHONY += maketools
 
diff --git a/scripts/subarch.include b/scripts/subarch.include
new file mode 100644
index 000000000000..caf3c641b52a
--- /dev/null
+++ b/scripts/subarch.include
@@ -0,0 +1,11 @@
+# SUBARCH tells the usermode build what the underlying arch is.  That is set
+# first, and if a usermode build is happening, the "ARCH=sandbox" on the command
+# line overrides the setting of ARCH below.  If a native build is happening,
+# then ARCH is assigned, getting whatever value it gets normally, and
+# SUBARCH is subsequently ignored.
+
+SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
+				  -e s/arm.*/arm/ -e s/sa110/arm/ \
+				  -e s/aarch64.*/arm/ \
+				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+				  -e s/riscv.*/riscv/)
-- 
2.39.5




  parent reply	other threads:[~2024-11-25 15:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 15:35 [PATCH 0/9] sandbox: use native setjmp/longjmp/initjmp implementation by default Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 1/9] sandbox: asm: support inclusion from sandbox os support code Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 2/9] test: self: setjmp: add simple initial testcase Ahmad Fatoum
2024-11-25 15:35 ` Ahmad Fatoum [this message]
2024-11-25 15:35 ` [PATCH 4/9] sandbox: setjmp: mark C version as __weak Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 5/9] sandbox: use native setjmp/longjmp/initjmp implementation by default Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 6/9] sandbox: retire HAVE_ARCH_ASAN Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 7/9] bthread: move asan fiber API into header Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 8/9] test: self: setjmp: make compatible with ASAN Ahmad Fatoum
2024-11-25 15:35 ` [PATCH 9/9] bthread: fix use of ASAN fiber stack switch API Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241125153523.1411849-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox