rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts: subarch.include: fix SUBARCH on MacOS hosts
@ 2022-11-13 23:38 Nick Desaulniers
  2022-11-15  4:12 ` Nicolas Schier
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Desaulniers @ 2022-11-13 23:38 UTC (permalink / raw)
  To: Masahiro Yamada, Jiaxun Yang, Nick Desaulniers, Huacai Chen,
	WANG Xuerui, Guo Ren, linux-kernel
  Cc: rust-for-linux, asahi, linux-kbuild

When building the Linux kernel on an aarch64 MacOS based host, if we don't
specify a value for ARCH when invoking make, we default to arm and thus
multi_v7_defconfig rather than the expected arm64 and arm64's defconfig.

This is because subarch.include invokes `uname -m` which on MacOS hosts
evaluates to `arm64` but on Linux hosts evaluates to `aarch64`,

This allows us to build ARCH=arm64 natively on MacOS (as in ARCH need
not be specified on an aarch64-based system).

Utilize a negative lookahead regular expression to avoid matching arm64.

Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
---
This is only part 1 of
https://github.com/ClangBuiltLinux/linux/commit/f06333e29addbc3d714adb340355f471c1dfe95a
I'm still working on the rest...

 scripts/subarch.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/subarch.include b/scripts/subarch.include
index 4bd327d0ae42..aa130286b627 100644
--- a/scripts/subarch.include
+++ b/scripts/subarch.include
@@ -6,7 +6,7 @@
 
 SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
 				  -e s/sun4u/sparc64/ \
-				  -e s/arm.*/arm/ -e s/sa110/arm/ \
+				  -e s/arm\(?:\(?!64\).*\)/arm/ -e s/sa110/arm/ \
 				  -e s/s390x/s390/ \
 				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
 				  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
-- 
2.37.0 (Apple Git-136)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts: subarch.include: fix SUBARCH on MacOS hosts
  2022-11-13 23:38 [PATCH] scripts: subarch.include: fix SUBARCH on MacOS hosts Nick Desaulniers
@ 2022-11-15  4:12 ` Nicolas Schier
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Schier @ 2022-11-15  4:12 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Masahiro Yamada, Jiaxun Yang, Huacai Chen, WANG Xuerui, Guo Ren,
	linux-kernel, rust-for-linux, asahi, linux-kbuild

[-- Attachment #1: Type: text/plain, Size: 2056 bytes --]

On Sun, 13 Nov 2022 15:38:09 -0800 Nick Desaulniers wrote:
> When building the Linux kernel on an aarch64 MacOS based host, if we don't
> specify a value for ARCH when invoking make, we default to arm and thus
> multi_v7_defconfig rather than the expected arm64 and arm64's defconfig.
> 
> This is because subarch.include invokes `uname -m` which on MacOS hosts
> evaluates to `arm64` but on Linux hosts evaluates to `aarch64`,
> 
> This allows us to build ARCH=arm64 natively on MacOS (as in ARCH need
> not be specified on an aarch64-based system).
> 
> Utilize a negative lookahead regular expression to avoid matching arm64.
> 
> Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
> ---
> This is only part 1 of
> https://github.com/ClangBuiltLinux/linux/commit/f06333e29addbc3d714adb340355f471c1dfe95a
> I'm still working on the rest...
> 
>  scripts/subarch.include | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/subarch.include b/scripts/subarch.include
> index 4bd327d0ae42..aa130286b627 100644
> --- a/scripts/subarch.include
> +++ b/scripts/subarch.include
> @@ -6,7 +6,7 @@
>  
>  SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
>  				  -e s/sun4u/sparc64/ \
> -				  -e s/arm.*/arm/ -e s/sa110/arm/ \
> +				  -e s/arm\(?:\(?!64\).*\)/arm/ -e s/sa110/arm/ \

On my Debian's sed, this does not match any more at all, e.g.:

  $ echo armv4 | sed -e 's/arm\(?:\(?!64\).*\)/arm/'
  armv4
.

This one works for me, but does not look such advanced:

  $ echo arm64 | sed -e '/^arm64$/!s/arm.*/arm/'
  arm64
  $ echo armv4 | sed -e '/^arm64$/!s/arm.*/arm/'
  arm
.

Kind regards,
Nicolas

>  				  -e s/s390x/s390/ \
>  				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
>  				  -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
> -- 
> 2.37.0 (Apple Git-136)

-- 
epost|xmpp: nicolas@fjasle.eu          irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb  c82b 7d97 0932 55a0 ce7f
     -- frykten for herren er opphav til kunnskap --

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-15  4:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-13 23:38 [PATCH] scripts: subarch.include: fix SUBARCH on MacOS hosts Nick Desaulniers
2022-11-15  4:12 ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).