linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Changing the ARM variant reported by 'uname -m'
@ 2017-10-18 15:07 Tuomas Tynkkynen
  2017-10-18 15:40 ` Willy Tarreau
  0 siblings, 1 reply; 2+ messages in thread
From: Tuomas Tynkkynen @ 2017-10-18 15:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

For our distro (NixOS), I've experimented with building packages for 
ARMv6 on ARMv7 hardware. This has generally worked fine, except that 
some build scripts (in coreutils, for example) notice that `uname -m` 
returns 'armv7l' and thus decide to e.g. add some ARMv7-specific gcc 
flags, which makes the binaries not run on actual ARMv6 devices.

So to avoid that, it would be necessary to have a way to make `uname -m` 
return a different ARM architecture version that the hardware has. After 
all, there is precedent for doing this: calling personality(PER_LINUX32) 
turns 'x86_64' to 'i686' and so on for other architectures.

I can see two ways of implementing this:

1) Keep using the personality() call by reserving some PER_* constants 
for architectures to use and decide what to map them to. E.g. the ARM 
implementation would require 8 values for choosing one of:
        armv4 armv4t armv5t armv5te armv5tej armv6 armv7 armv7m
plus automatically appending 'b' or 'l' depending on endianness.

2) Add a new setmachine() system call that allows setting the machine 
    name to an arbitrary string inside a non-initial UTS namespace.

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

* Changing the ARM variant reported by 'uname -m'
  2017-10-18 15:07 Changing the ARM variant reported by 'uname -m' Tuomas Tynkkynen
@ 2017-10-18 15:40 ` Willy Tarreau
  0 siblings, 0 replies; 2+ messages in thread
From: Willy Tarreau @ 2017-10-18 15:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Tuomas,

On Wed, Oct 18, 2017 at 06:07:22PM +0300, Tuomas Tynkkynen wrote:
> Hi,
> 
> For our distro (NixOS), I've experimented with building packages for ARMv6
> on ARMv7 hardware. This has generally worked fine, except that some build
> scripts (in coreutils, for example) notice that `uname -m` returns 'armv7l'
> and thus decide to e.g. add some ARMv7-specific gcc flags, which makes the
> binaries not run on actual ARMv6 devices.
> 
> So to avoid that, it would be necessary to have a way to make `uname -m`
> return a different ARM architecture version that the hardware has.

In fact, while cheating on the "uname" output can have its use cases, what
you describe is a different use case, your problem is related to the fact
that you are trying to cross-compile but are not doing it. This is always
extremely risky as you only catch the most visible part of the iceberg.
Some build programs may even detect certain syscalls on your systems, the
kernel version or the support for certain instructions or CPU extensions.
I used to suffer from this 15 years ago when dealing with i386 vs i486,
regularly facing the common "Illegal instruction" everytime a program
accidently used BSWAP for htonl() despite me being very careful... 

The proper way to definitely get rid of this situation is to pass
--host= and --build= to "configure" and to cross-compile everything. It's
much less complicated than what it sounds like and comes with a lot of
benefits, including the fact that you can build from about any arch for
any other arch, and that you don't accidently depend on anything detected
in the build environment.

Hoping this helps,
Willy

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

end of thread, other threads:[~2017-10-18 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-18 15:07 Changing the ARM variant reported by 'uname -m' Tuomas Tynkkynen
2017-10-18 15:40 ` Willy Tarreau

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).