Hi Tomek,

You are right that there is no standard here. POSIX only says that
"uname -m" is "the name of the hardware type", and struct utsname has
just five fields: sysname, nodename, release, version and machine.
There is no processor field.

But I think we can agree that there is a convention. I went through
the sources of the tools that people actually run, to see what they
read and what they expect:

  Python      platform.machine() (and PEP 508 platform_machine) is the
              machine field from uname(). It gives "aarch64" on Linux,
              "arm64" on macOS, and "riscv64".

  Tcl         platform::generic reads the machine field and turns every
              "arm*" into "arm". So "arm64" becomes the 32-bit name "arm".

  meson       reads platform.machine() ("uname -p" only on the BSDs, QNX
              and AIX). It maps "arm64" to "aarch64", but for "risc-v" it
              warns "Unknown CPU family".

  Qt          QSysInfo::currentCpuArchitecture() reads the machine field.
              It knows "arm64" and "riscv64", but not "risc-v".

  autotools   config.guess reads "uname -m". config.sub takes "arm64" as
              an alias of "aarch64" and knows "riscv32" and "riscv64",
              but "risc-v" is not a CPU name for it.

  CMake       reads "uname -m" on Linux and macOS, and "uname -p" on
              other systems. NuttX is an "other" system, so today CMake
              gets "unknown".

  libuv/Node  os.machine(), Perl POSIX::uname and agetty just pass the
              machine field on.

  coreutils   "uname -p" prints "unknown" on Linux.

  FreeBSD     "uname -m" gives "arm64" / "riscv", and "uname -p" gives
              "aarch64" / "riscv64".

  Linux       "uname -m" gives "aarch64", "riscv64", "riscv32", and on
              32-bit Arm the CPU version ("armv7l"). That is also where
              Android's "armv7l" comes from: Android uses the Linux kernel.

  Toolchains  Go: arm64, riscv64. Rust: aarch64, riscv64. LLVM: aarch64
              (arm64 as an alias), riscv64. Debian: arm64, riscv64.

So, in short:

- Nobody uses "risc-v". Every tool and every system says "riscv64" or "riscv32".
- "arm64" is a real machine name (macOS and the BSDs), and most tools
map it to "aarch64". Tcl does not: it turns it into "arm".
- "uname -p" alone does not reach most programs. uname() has no
processor field, so Python, Tcl, Qt, meson and Node never see it. Only
CMake (on a system it does not know) and Python's platform.processor()
run "uname -p".
- Where "-p" has a value on other systems, it is the ISA name
("aarch64", "riscv64" on the BSDs), not a CPU version like "armv7l" or
"i686". On Linux it is just "unknown".

So my proposal is basically your option 2 from 1 December, plus one
thing. #22584 changes the machine field to the toolchain names, one
name per CPU. Then I send a small nuttx-apps PR so that NSH "uname -p"
prints the same name, which also gives CMake and BSD-style scripts
what they look for.

If the project would rather keep "arm64" in "-m" (the macOS/BSD name),
I am fine with that too: I will limit #22584 to RISC-V and put
"aarch64" only in "uname -p".

What do you think?

If you want to check any of this, here are the sources:
- POSIX: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/uname.html
- Python: https://github.com/python/cpython/blob/v3.12.8/Lib/platform.py
- Tcl: 
https://github.com/tcltk/tcl/blob/core-8-6-16/library/platform/platform.tcl
- meson: 
https://github.com/mesonbuild/meson/blob/8b8aa6489e4e485af2bb46e116ea2250a66886da/mesonbuild/envconfig.py
- Qt: 
https://github.com/qt/qtbase/blob/c87526ff396876153710c8681cbaed82fa9e87c6/src/corelib/global/qsysinfo.cpp
- config.sub: 
https://github.com/autotools-mirror/automake/blob/49d40961656504baeb22271cf8b3b17e4fc0ebdb/lib/config.sub
- CMake: 
https://github.com/Kitware/CMake/blob/61a2bd8a8736861f39379bb2b3cbb7a23454a14b/Modules/CMakeDetermineSystem.cmake#L60-L131
- FreeBSD: 
https://github.com/freebsd/freebsd-src/blob/a1fbb469963b65924a6eb1aadc106331f2c28e7d/usr.bin/uname/uname.c
- Linux: 
https://github.com/torvalds/linux/blob/v6.18/arch/arm64/Makefile#L125-L131
and https://github.com/torvalds/linux/blob/v6.18/arch/riscv/Makefile#L29-L42

Best regards,
Marco

On Wed, Dec 2, 2026 at 5:24 PM Tomek CEDRO <[email protected]> wrote:
>
> * Actually there is no standard to what `uname` reports [1]. What is
> more different OS report different tings [2]. So this change only
> moves alignment from BSD to Linux.
> * Only option `-m` option (MACHINE) is defined by POSIX and means
> "Write the name of the hardware type on which the system is running to
> standard output.".
> * Option `-p` (PROCESSOR) is not defined by POSIX but widely used.
>
> My proposition is to leave `uname -m` untouched (it prints out
> CONFIG_ARCH) and implement `uname -p` in a way that would give
> detailed information about the processor (i.e. riscv32, riscv64,
> armv6l, armv7l, i386, i686, x86_6x, amd64, etc). This maintains
> self-compatibility and bring new feature that gives better information
> about underlying CPU.
>
> RISC-V part is obvious riscv32 or riscv64. ARM is not that obvious
> because there is at least arm64, aarch64, armv6l, armv7l, etc. Last
> two come from Android which handles different underlying architectures
> and for me this should be the way to follow as we plan to have distro
> too one day.
>
> [1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/uname.html
> [2] https://en.wikipedia.org/wiki/Uname
>
> --
> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
>
> On Wed, Dec 2, 2026 at 4:44 AM Tomek CEDRO <[email protected]> wrote:
> >
> > Just as Greg noticed in the PR comment arm64 is used by the BSD world.
> > I dug deeper and this turns out `uname -m` is for PLATFORM (i.e.
> > arm64, riscv) versus `uname -p` is for PROCESSOR (i.e. aarch64,
> > riscv32, riscv64) discrepancy.
> >
> > So maybe we only need to update the uname -p part that reports unknown
> > at the moment?
> >
> > Also no other OS uses risc-v but riscv - this one may need an update.
> >
> > Full details in
> > https://github.com/apache/nuttx/pull/22584#issuecomment-7334112153
> >
> > --
> > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
> >
> > On Tue, Dec 1, 2026 at 4:56 PM Tomek CEDRO <[email protected]> wrote:
> > >
> > > Thank you Marco for raising the discussion :-)
> > >
> > > I am for the alignment with the other OS just to mark the change as
> > > breaking in case someone uses build / test scripts to be updated :-)
> > >
> > > I can see 3 choices here in general:
> > >
> > > 1. Most invasive (least welcome): Update CONFIG_ARCH to use widely
> > > used nomenclature to align with other OS/RTOS. This would also imply
> > > renaming directories. Strongly breaking change.
> > >
> > > 2. Least invasive (most welcome): As Marco proposing keep CONFIG_ARCH
> > > but change what uname reports to align with other OS. Sources
> > > structure remains untouched.
> > >
> > > 3. Non-invasive (for consideration):  As proposed on the PR we can add
> > > a Kconfig string such as LIBC_UNAME_MACHINE, defaulting to
> > > CONFIG_ARCH. Anyone who wants the Linux names (for example, for
> > > scripting-language platform detection, which seems to be the
> > > motivation) can opt in per board or defconfig. The current behaviour
> > > stays the default. But this may result in strong inconsisencies.
> > >
> > > Thus I am for option (2) as proposed by Marco :-)
> > >
> > > --
> > > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
> > >
> > > On Tue, Dec 1, 2026 at 12:37 PM Marco C. <[email protected]> wrote:
> > > >
> > > > Hello,
> > > >
> > > > CONTRIBUTING.md 1.13 asks for a discussion on dev@ before the vote on a
> > > > breaking change. This is the discussion for:
> > > >
> > > > https://github.com/apache/nuttx/pull/22584
> > > >
> > > > What changes: uname() gives the Linux machine name on two architectures:
> > > > "aarch64" instead of "arm64", and "riscv64" or "riscv32" instead of
> > > > "risc-v". The other architectures keep CONFIG_ARCH (x86_64 already gives
> > > > "x86_64"). The change is the same in flat, protected and kernel builds.
> > > >
> > > > Why: scripts and language runtimes detect the platform with "uname -m" 
> > > > or
> > > > uname() and compare the result with the Linux names. With "arm64" and
> > > > "risc-v", each of them needs a special case for NuttX.
> > > >
> > > > Who is affected: NSH "uname -m" and "uname -a", the assert dump header 
> > > > and
> > > > the core dump note show the new name. In nuttx and nuttx-apps, only
> > > > boards/risc-v/erbium/minion/tools/test_emu.py compared the name; the PR
> > > > updates it. nxpkg and nxdiag use CONFIG_ARCH and do not change. 
> > > > Out-of-tree
> > > > code that compares the machine field with "arm64" or "risc-v" is 
> > > > affected.
> > > >
> > > > Quick fix: accept "aarch64", "riscv64" and "riscv32" too, or compare
> > > > CONFIG_ARCH at build time.
> > > >
> > > > The alternative: Tomasz proposed a Kconfig option (default CONFIG_ARCH) 
> > > > to
> > > > select the Linux names. Then the same CPU has two names, and portable
> > > > programs must accept both. I prefer one name, the same as Linux.
> > > >
> > > > I will add build and runtime logs from real hardware (1.14) to the PR, 
> > > > and
> > > > start the vote after this discussion. Please send your comments here or 
> > > > in
> > > > the PR.
> > > >
> > > > Best regards,
> > > > Marco Casaroli

Reply via email to