Message ID | 20190217153131.94556-5-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | cgcc: use gcc -dumpmachine | expand |
On 17/02/2019 15:31, Luc Van Oostenryck wrote: > From: Uwe Kleine-König <uwe@kleine-koenig.org> > > `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@kleine-koenig.org> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> > --- > 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'); >
On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: > > > On 17/02/2019 15:31, Luc Van Oostenryck wrote: > > From: Uwe Kleine-König <uwe@kleine-koenig.org> > > > > `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? I still consider it more or less as RFC since it's lack some testing. And since it started from Uwe's patch for Debian builds, I would prefer to hear his opinion about it first. Best regards, -- Luc
On 20/02/2019 11:25, Luc Van Oostenryck wrote: > On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: >> >> >> On 17/02/2019 15:31, Luc Van Oostenryck wrote: >>> From: Uwe Kleine-König <uwe@kleine-koenig.org> >>> >>> `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? > > I still consider it more or less as RFC since it's lack some testing. > And since it started from Uwe's patch for Debian builds, I would > prefer to hear his opinion about it first. Ah, OK, fair enough. ;-) [BTW, I am used to seeing RFC in the PATCH header rather than in the commit message - it makes the transition from RFC to non-RFC easier, since you don't have to edit the commit! :-D ] ATB, Ramsay Jones
On 2/20/19 12:25 PM, Luc Van Oostenryck wrote: > On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: >> >> >> On 17/02/2019 15:31, Luc Van Oostenryck wrote: >>> From: Uwe Kleine-König <uwe@kleine-koenig.org> >>> >>> `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? > > I still consider it more or less as RFC since it's lack some testing. > And since it started from Uwe's patch for Debian builds, I would > prefer to hear his opinion about it first. Do you have this in a branch somewhere to pull? Then I can give it a go on a few Debian porter machines. Best regards Uwe
On Wed, Feb 20, 2019 at 05:17:29PM +0100, Uwe Kleine-König wrote: > On 2/20/19 12:25 PM, Luc Van Oostenryck wrote: > > On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: > >> > >> > >> On 17/02/2019 15:31, Luc Van Oostenryck wrote: > >>> From: Uwe Kleine-König <uwe@kleine-koenig.org> > >>> > >>> `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? > > > > I still consider it more or less as RFC since it's lack some testing. > > And since it started from Uwe's patch for Debian builds, I would > > prefer to hear his opinion about it first. > > Do you have this in a branch somewhere to pull? Then I can give it a go > on a few Debian porter machines. That would be wonderful. I've put the branch at: git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git cgcc-dumpmachine-v2 It's the same as the patches posted here but: *) with the last 2 patches removed *) with Ramsay's comments taken in account *) rebased on top of the current master. Best regards, -- Luc
On Wed, Feb 20, 2019 at 03:01:52PM +0000, Ramsay Jones wrote: > On 20/02/2019 11:25, Luc Van Oostenryck wrote: > > > > I still consider it more or less as RFC since it's lack some testing. > > And since it started from Uwe's patch for Debian builds, I would > > prefer to hear his opinion about it first. > > Ah, OK, fair enough. ;-) > > [BTW, I am used to seeing RFC in the PATCH header rather than > in the commit message - it makes the transition from RFC to > non-RFC easier, since you don't have to edit the commit! :-D ] Yes, I should have done this. I'll try to remember using git format-patch --rfc ... Best regards, -- Luc
On 20/02/2019 21:12, Luc Van Oostenryck wrote: > On Wed, Feb 20, 2019 at 05:17:29PM +0100, Uwe Kleine-König wrote: >> On 2/20/19 12:25 PM, Luc Van Oostenryck wrote: >>> On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: >>>> >>>> >>>> On 17/02/2019 15:31, Luc Van Oostenryck wrote: >>>>> From: Uwe Kleine-König <uwe@kleine-koenig.org> >>>>> >>>>> `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? >>> >>> I still consider it more or less as RFC since it's lack some testing. >>> And since it started from Uwe's patch for Debian builds, I would >>> prefer to hear his opinion about it first. >> >> Do you have this in a branch somewhere to pull? Then I can give it a go >> on a few Debian porter machines. > > That would be wonderful. I've put the branch at: > git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git cgcc-dumpmachine-v2 > > It's the same as the patches posted here but: > *) with the last 2 patches removed > *) with Ramsay's comments taken in account > *) rebased on top of the current master. BTW, I think commit 1a51714958 ("teach sparse about -mfloat-abi on ARM", 2019-02-17) is incorrect. It seems to me to have (despite the commit title) implemented '-ffloat-abi' _not_ '-mfloat-abi'. This makes some later commits ineffective as well, because sparse does not complain when passed '-mfloat-abi=hard' (or indeed '-ffloat-abi=junk'). ATB, Ramsay Jones
On 2/20/19 10:12 PM, Luc Van Oostenryck wrote: > On Wed, Feb 20, 2019 at 05:17:29PM +0100, Uwe Kleine-König wrote: >> On 2/20/19 12:25 PM, Luc Van Oostenryck wrote: >>> On Wed, Feb 20, 2019 at 01:50:21AM +0000, Ramsay Jones wrote: >>>> >>>> >>>> On 17/02/2019 15:31, Luc Van Oostenryck wrote: >>>>> From: Uwe Kleine-König <uwe@kleine-koenig.org> >>>>> >>>>> `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? >>> >>> I still consider it more or less as RFC since it's lack some testing. >>> And since it started from Uwe's patch for Debian builds, I would >>> prefer to hear his opinion about it first. >> >> Do you have this in a branch somewhere to pull? Then I can give it a go >> on a few Debian porter machines. > > That would be wonderful. I've put the branch at: > git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git cgcc-dumpmachine-v2 > > It's the same as the patches posted here but: > *) with the last 2 patches removed > *) with Ramsay's comments taken in account > *) rebased on top of the current master. I gave this branch a go in a mips chroot on a mips64 machine and env CHECK=./sparse ./cgcc -no-compile memops.c was happy there. Ditto on an armhf chroot on arm64. Best regards Uwe
On Thu, Feb 21, 2019 at 02:55:26PM +0000, Ramsay Jones wrote: > > BTW, I think commit 1a51714958 ("teach sparse about -mfloat-abi on ARM", > 2019-02-17) is incorrect. It seems to me to have (despite the commit > title) implemented '-ffloat-abi' _not_ '-mfloat-abi'. Yes, you're right of course. Thanks a lot for noticing this -- Luc
On Fri, Feb 22, 2019 at 11:02:11PM +0100, Uwe Kleine-König wrote: > On 2/20/19 10:12 PM, Luc Van Oostenryck wrote: > > On Wed, Feb 20, 2019 at 05:17:29PM +0100, Uwe Kleine-König wrote: > >> On 2/20/19 12:25 PM, Luc Van Oostenryck wrote: > >>> > >>> I still consider it more or less as RFC since it's lack some testing. > >>> And since it started from Uwe's patch for Debian builds, I would > >>> prefer to hear his opinion about it first. > >> > >> Do you have this in a branch somewhere to pull? Then I can give it a go > >> on a few Debian porter machines. > > > > That would be wonderful. I've put the branch at: > > git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git cgcc-dumpmachine-v2 > > > > It's the same as the patches posted here but: > > *) with the last 2 patches removed > > *) with Ramsay's comments taken in account > > *) rebased on top of the current master. > > I gave this branch a go in a mips chroot on a mips64 machine and > > env CHECK=./sparse ./cgcc -no-compile memops.c > > was happy there. Ditto on an armhf chroot on arm64. The change I made for ARM's -mfloat-abi was buggy but at least this show that the logic for the arch selection is good. Thanks a lot, -- Luc
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 + # 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');