All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas De Schampheleire <patrickdepinguin@gmail.com>
To: Romain Naour <romain.naour@gmail.com>
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>,
	Antoine Tenart <atenart@kernel.org>,
	"Yann E. MORIN" <yann.morin.1998@free.fr>,
	buildroot <buildroot@buildroot.org>,
	Clayton Shotwell <clayton.shotwell@collins.com>,
	Matt Weber <matthew.weber@collins.com>,
	Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Subject: Re: [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH
Date: Fri, 14 Jan 2022 13:27:30 +0100	[thread overview]
Message-ID: <CAAXf6LX7Lr_ZPA9eCwUbjxWWRFt89A2N7Eq=KcKqKSLDw8Kviw@mail.gmail.com> (raw)
In-Reply-To: <cd4152f3-72a1-fff8-828e-330c22a353d5@gmail.com>

Hi Romain,

El jue, 13 ene 2022 a las 22:30, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Le 18/05/2021 à 13:36, Thomas De Schampheleire a écrit :
> > From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >
> > The variable 'KERNEL_ARCH' is actually a normalized version of
> > 'ARCH'/'BR2_ARCH'. For example, 'arcle' and 'arceb' both become 'arc', just
> > as all powerpc variants become 'powerpc'.
> >
> > It is presumably called 'KERNEL_ARCH' because the Linux kernel is typically
> > the first place where support for a new architecture is added, and thus is
> > the entity that defines the normalized name.
> >
> > However, the term 'KERNEL_ARCH' can also be interpreted as 'the architecture
> > used by the kernel', which need not be exactly the same as 'the normalized
> > name for a certain arch'. In particular, for cases where a 64-bit
> > architecture is running a 64-bit kernel but 32-bit userspace. Examples
> > include:
> >     * aarch64 architecture, with aarch64 kernel and 32-bit (ARM) userspace
> >     * x86_64 architecture, with x86_64 kernel and 32-bit (i386) userspace
> >
> > In such cases, the 'architecture used by the kernel' needs to refer to the
> > 64-bit name (aarch64, x86_64), whereas all userspace applications need to
> > refer the, potentially normalized, 32-bit name.
> >
> > This means that there need to be two different variables:
> >
> > KERNEL_ARCH:     the architecture used by the kernel
> > NORMALIZED_ARCH: the normalized name for the current userspace architecture
> >
> > At this moment, both will actually have the same content. But a subsequent
> > patch will add basic support for situations described above, in which
> > KERNEL_ARCH may become overwritten to the 64-bit architecture, while
> > NORMALIZED_ARCH needs to remain the same (32-bit) case.
> >
> > This commit replaces use of KERNEL_ARCH where actually the userspace arch is
> > needed.  Places that use KERNEL_ARCH in combination with building of kernel
> > modules are not touched.
> > There may be cases where a package builds both a kernel module as userspace,
> > in which case it may need to know about both KERNEL_ARCH and
> > NORMALIZED_ARCH, for the case where they differ. But this is to be fixed on
> > a per-need basis.
>
> While reviewing this patch, I noticed that LINUX_ARCH_PATH [1] is wrong for sparc64
>
> LINUX_ARCH_PATH = $(LINUX_DIR)/arch/$(KERNEL_ARCH)
>
> Indeed:
>
> $ make O=test/qemu_sparc64_sun4u_defconfig printvars VARS=LINUX_ARCH_PATH
> LINUX_ARCH_PATH=/home/kubu/buildroot/test/qemu_sparc64_sun4u_defconfig/build/linux-5.15/arch/sparc64
>
> But since LINUX_ARCH_PATH is not used for this architecture, it was not noticed.
>
> [1] https://git.buildroot.net/buildroot/tree/linux/linux.mk?h=2021.11#n226
>

Are you sure that this is a problem?
In the kernel Makefile, some 'ARCH' strings are treated specially:

# Additional ARCH settings for x86
ifeq ($(ARCH),i386)
        SRCARCH := x86
endif
ifeq ($(ARCH),x86_64)
        SRCARCH := x86
endif

# Additional ARCH settings for sparc
ifeq ($(ARCH),sparc32)
       SRCARCH := sparc
endif
ifeq ($(ARCH),sparc64)
       SRCARCH := sparc
endif

# Additional ARCH settings for parisc
ifeq ($(ARCH),parisc64)
       SRCARCH := parisc
endif


So compiling the kernel with ARCH=sparc64 is accepted, and the arch
directory will be arch/sparc . Similar to how compiling with
ARCH=x86_64 works even though arch/x86_64 does not (no longer) exist.

While I'm not familiar with sparc64, there does not seem to be a bug to me.

Thanks,
Thomas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2022-01-14 12:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 11:36 [Buildroot] [PATCH RFC 0/4] Basic support for 64-bit kernel and 32-bit userland Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 1/4] arch: move definition of KERNEL_ARCH to Config.in.<arch> files Thomas De Schampheleire
2022-01-13 20:48   ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 2/4] core: introduce NORMALIZED_ARCH as non-kernel replacement for KERNEL_ARCH Thomas De Schampheleire
2022-01-13 21:30   ` Romain Naour
2022-01-14 12:27     ` Thomas De Schampheleire [this message]
2022-01-15 14:55       ` Romain Naour
2021-05-18 11:36 ` [Buildroot] [PATCH 3/4] core: introduce BR2_KERNEL_ARCH_OVERRIDE Thomas De Schampheleire
2022-01-09 23:27   ` Romain Naour
2022-01-12 11:04     ` Thomas De Schampheleire
2022-01-12 19:10       ` Arnout Vandecappelle
2022-01-12 20:06         ` Romain Naour
2022-01-13 22:05   ` Romain Naour
2022-01-15 19:31     ` Thomas De Schampheleire
2022-01-15 19:45     ` Thomas De Schampheleire
2021-05-18 11:36 ` [Buildroot] [PATCH 4/4] perf: fix compilation in case of i386 userspace with x86_64 kernel Thomas De Schampheleire
2022-01-13 22:15   ` Romain Naour
2022-01-14  9:33     ` Thomas De Schampheleire

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='CAAXf6LX7Lr_ZPA9eCwUbjxWWRFt89A2N7Eq=KcKqKSLDw8Kviw@mail.gmail.com' \
    --to=patrickdepinguin@gmail.com \
    --cc=atenart@kernel.org \
    --cc=buildroot@buildroot.org \
    --cc=clayton.shotwell@collins.com \
    --cc=marcus.folkesson@gmail.com \
    --cc=matthew.weber@collins.com \
    --cc=romain.naour@gmail.com \
    --cc=thomas.de_schampheleire@nokia.com \
    --cc=yann.morin.1998@free.fr \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.