I'm looking into a regression between gcc-7 and gcc-8 that causes
compilation with -mfloat-abi=hard to fail on arm-eabi with:

$ arm-eabi-gcc -c -mfloat-abi=hard t.c
cc1: error: -mfloat-abi=hard: selected processor lacks an FPU

Per the documentation, -mfpu=auto was supposed to be the default, but
the implicit -mcpu=armv7tdmi option from configure_default_options, or
the -march=armv4t derived from it, seems to be taken as choosing to
disable the fpu.  Even passing -mfpu=auto explicitly one gets the error
above; AFAICT it would only work if the default cpu had support for an
fpu, and the "regression" is caused by new checks about conflicting
options.  Does that sound right?

While trying to find a work-around, still suspecting the issue was a
lack of -mfpu=auto, I tried configuring --with-fpu=auto and ran into a
few issues.


The first problem was a shell bug in the $fpu = error test: there must
be a blank before the closing bracket.


The second problem, hit after fixing the first, was that it printed a
very confusing error message:

  Unknown target in --with-arch=

which set me down a bit of a wild goose chase until I realized the error
was about with_fpu, but the error message, presumably copied from an
earlier loop, had not been adjusted for the fact that 'which' and 'val',
set in the loop, were not set in the block below, and we don't want to
print the values in the last iteration of the loop, we want the
--with-fpu stuff.


The third problem is that chkfpu rejects auto because auto is special,
it's not in the fpu_cnames array.  I'm not sure whether it's
inappropriate to accept it, but if we could accept it so as to enable it
to be an overriding default, it could be arranged to be explicitly
accepted right in the portion of config.gcc modified by the patch below,
or in parsecpu.awk.  Any preferences?

Weirdly, *without* the obvious fixes in the patch below, --with-fpu=auto
is accepted, but after the patch it's no longer accepted, so I guess it
might make sense to refrain from installing it until there's a decision
as to whether --with-fpu=auto should be accepted.  So, any objections to
my installing this then, or even now, if --with-fpu=auto shouldn't be
accepted?


for  gcc/ChangeLog

        * config.gcc: Fix ARM --with-fpu checking and error message.


diff --git a/gcc/config.gcc b/gcc/config.gcc
index 6b00c3872473..89ccbecec23d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3962,12 +3962,13 @@ case "${target}" in
 
                # see if --with-fpu matches any of the supported FPUs
                if [ x"$with_fpu" != x ] ; then
+                 val=$with_fpu
                  fpu=`awk -f ${srcdir}/config/arm/parsecpu.awk \
-                       -v cmd="chkfpu $with_fpu" \
+                       -v cmd="chkfpu $val" \
                        ${srcdir}/config/arm/arm-cpus.in`
-                 if [ "$fpu" = "error"]
+                 if [ "$fpu" = "error" ]
                  then
-                   echo "Unknown target in --with-$which=$val" 1>&2
+                   echo "Unknown target in --with-fpu=$val" 1>&2
                    exit 1
                  fi
                fi

-- 
Alexandre Oliva, freedom fighter  he/him   https://FSFLA.org/blogs/lxo
Be the change, be Free!                 FSF Latin America board member
GNU Toolchain Engineer                        Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás - Che GNUevara

Reply via email to