On 17/02/2019 15:31, Luc Van Oostenryck wrote: > From: Uwe Kleine-König <uwe@xxxxxxxxxxxxxxxxx> > > `uname -m` returns information about the host machine but this > information is useless when cgcc is used with a non-native compiler. > In this case it's information about the target machine that is needed. > > [This can happen when cross compiling or (more > common) if you are running a 32 bit userspace on a 64 bit kernel. The > latter makes sparse fail to build on some machines of the Debian build > farm as for example some armhf builder run on arm64 kernels.] > > This patch is only lightly tested and also misses details for mips* and missing [ and ... > so marked as RFC.] probably should be removed completely, since it is no longer an RFC? > > Originally-by: Uwe Kleine-König <uwe@xxxxxxxxxxxxxxxxx> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> > --- > cgcc | 33 ++++++++++++++++++++++++++++----- > 1 file changed, 28 insertions(+), 5 deletions(-) > > diff --git a/cgcc b/cgcc > index 5336ae3ce..69380c60d 100755 > --- a/cgcc > +++ b/cgcc > @@ -338,7 +338,34 @@ sub add_specs { > chomp $os; > return &add_specs (lc $os); > } elsif ($spec eq 'host_arch_specs') { > - my $arch = `uname -m`; > + my $gccmachine; > + my $arch; > + > + $gccmachine = `$ccom -dumpmachine`; > + chomp $gccmachine; > + > + if ($gccmachine =~ '^aarch64-') { > + return &add_specs ('aarch64'); > + } elsif ($gccmachine =~ '^arm-.*eabihf$') { > + return &add_specs ('arm+hf'); > + } elsif ($gccmachine =~ '^arm-') { > + return &add_specs ('arm'); > + } elsif ($gccmachine =~ '^i[23456]86-') { > + return &add_specs ('i386'); > + } elsif ($gccmachine =~ '^(powerpc|ppc)64le-') { > + return &add_specs ('ppc64+le'); > + } elsif ($gccmachine =~ '^s390x-') { > + return &add_specs ('s390x'); > + } elsif ($gccmachine eq 'x86_64-linux-gnu') { > + return &add_specs ('x86_64'); > + } > + > + # fall back to uname -m to determine the specifics. > + # Note: this is only meaningful when using natively > + # since informaton about the host i sused to guess s/informaton/information/; s/i sused/is used/ ATB, Ramsay Jones > + # characteristics of the target. > + > + $arch = `uname -m`; > chomp $arch; > if ($arch =~ /^(i.?86|athlon)$/i) { > return &add_specs ('i386'); > @@ -357,10 +384,6 @@ sub add_specs { > } elsif ($arch =~ /^(sparc64)$/i) { > return &add_specs ('sparc64'); > } elsif ($arch =~ /^arm(?:v[78]l)?$/i) { > - chomp (my $gccmachine = `$ccom -dumpmachine`); > - if ($gccmachine eq 'arm-linux-gnueabihf') { > - return &add_specs ('arm+hf'); > - } > return &add_specs ('arm'); > } elsif ($arch =~ /^(aarch64)$/i) { > return &add_specs ('aarch64'); >