public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11
@ 2022-02-08 23:45 noloader at gmail dot com
  2022-02-09 11:47 ` [Bug target/104455] " rearnsha at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2022-02-08 23:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

            Bug ID: 104455
           Summary: Cannot select -march=armv7-a using GCC 11
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: noloader at gmail dot com
  Target Milestone: ---

Hi Everyone,

We are trying to fix a compile problem Debian encountered on Sid [1,2]. The
machine is armhf, but I don't have access to it. Sid is using GCC 11, but I am
not sure which version. The problem does not exist in GCC 10 and below.

I think this is the test case. Below, test.S is mostly armv4 but has some armv7
instructions. I used movw and movt as an example since they are armv7.

$ cat test.S
        .globl return_magic
        .type  return_magic,%function

return_magic:

        movw r0, #0x1234
        movt r0, #0x5678
        bl   0

$ g++ -g2 -O3 -Wa,--noexecstack -march=armv7-a test.S -c

When Debian compiles with GCC 11, it results in:

  cc1: error: ‘-mfloat-abi=hard’: selected architecture lacks an FPU

test.S does not use floating point or neon instructions. This source file does
not need a fpu. We don't care what the platform default is because we don't use
it. But in this case, the machine is armhf so GCC should know it should use
hard floats.

When I attempt to add -mfpu=auto per [3], it results in another error:

  cc1: sorry, unimplemented: -mfpu=auto not currently supported without an
explicit CPU.
  cc1: error: -mfloat-abi=hard: selected processor lacks an FPU

test.S does not use floating point or neon instructions. This source file does
not need a fpu. I also tried -mfpu=none, but it results in:

  g++: error: unrecognized argument in option ‘-mfpu=none’
  g++: note: valid arguments to ‘-mfpu=’ are: auto crypto-neon-fp-armv8
  fp-armv8 fpv4-sp-d16 fpv5-d16 fpv5-sp-d16 neon neon-fp-armv8 neon-fp16
  neon-vfpv3 neon-vfpv4 vfp vfp3 vfpv2 vfpv3 vfpv3-d16 vfpv3-d16-fp16
  vfpv3-fp16 vfpv3xd vfpv3xd-fp16 vfpv4 vfpv4-d16; did you mean ‘neon’?

In the past we avoided specifying a -mfpu option because the code [used to]
work with GCC 4 and above, Clang 3 and above, armel, armhf and Android with
soft floats. The compiler always knew what float abi it should use.

I would like to drop -march=armv7-a, but GCC requires me to use an ISA option
before I use instructions from the ISA. I've never liked the rule, but it is
what it is. (Microsoft's C/C++ compiler got this right).

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001995
[2] https://github.com/weidai11/cryptopp/issues/1094
[3] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
@ 2022-02-09 11:47 ` rearnsha at gcc dot gnu.org
  2022-02-10  3:12 ` noloader at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2022-02-09 11:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2022-02-09
     Ever confirmed|0                           |1

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
What's the configuration of the compiler?  Eg, the output of gcc -v

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
  2022-02-09 11:47 ` [Bug target/104455] " rearnsha at gcc dot gnu.org
@ 2022-02-10  3:12 ` noloader at gmail dot com
  2022-02-10 11:17 ` rearnsha at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2022-02-10  3:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

--- Comment #2 from Jeffrey Walton <noloader at gmail dot com> ---
(In reply to Richard Earnshaw from comment #1)
> What's the configuration of the compiler?  Eg, the output of gcc -v

Thanks Richard. I set-up a Debian Qemu/Chroot for armhf. I can now duplicate
the problem.

#  cat test.S 
        .globl return_magic
        .type  return_magic,%function

return_magic:

        movw r0, #0x1234
        movt r0, #0x5678
        bl   0

# g++ -g2 -O3 -Wa,--noexecstack -march=armv7-a test.S -c
cc1: error: ‘-mfloat-abi=hard’: selected architecture lacks an FPU

# gcc --version -v
Using built-in specs.
COLLECT_AS_OPTIONS='--version'
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/11/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 11.2.0-16'
--with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-11
--program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm
--disable-libquadmath --disable-libquadmath-support --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-sjlj-exceptions --with-arch=armv7-a+fp --with-float=hard
--with-mode=thumb --disable-werror --enable-checking=release
--build=arm-linux-gnueabihf --host=arm-linux-gnueabihf
--target=arm-linux-gnueabihf
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Debian 11.2.0-16) 
gcc (Debian 11.2.0-16) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


COLLECT_GCC_OPTIONS='--version' '-v'  '-mfloat-abi=hard' '-mtls-dialect=gnu'
'-mthumb' '-mlibarch=armv7-a+fp' '-march=armv7-a+fp' '-dumpdir' 'a-'
 /usr/lib/gcc/arm-linux-gnueabihf/11/cc1 -quiet -v -imultilib . -imultiarch
arm-linux-gnueabihf help-dummy -quiet -dumpdir a- -dumpbase help-dummy
-mfloat-abi=hard -mtls-dialect=gnu -mthumb -mlibarch=armv7-a+fp
-march=armv7-a+fp -version --version -o /tmp/ccdbsVZx.s
GNU C17 (Debian 11.2.0-16) version 11.2.0 (arm-linux-gnueabihf)
        compiled by GNU C version 11.2.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='--version' '-v'  '-mfloat-abi=hard' '-mtls-dialect=gnu'
'-mthumb' '-mlibarch=armv7-a+fp' '-march=armv7-a+fp' '-dumpdir' 'a-'
 as -v -march=armv7-a -mfloat-abi=hard -meabi=5 --version -o /tmp/ccYLSQQS.o
/tmp/ccdbsVZx.s
GNU assembler version 2.37.90 (arm-linux-gnueabihf) using BFD version (GNU
Binutils for Debian) 2.37.90.20220207
GNU assembler (GNU Binutils for Debian) 2.37.90.20220207
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `arm-linux-gnueabihf'.
COMPILER_PATH=/usr/lib/gcc/arm-linux-gnueabihf/11/:/usr/lib/gcc/arm-linux-gnueabihf/11/:/usr/lib/gcc/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/11/:/usr/lib/gcc/arm-linux-gnueabihf/
LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabihf/11/:/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/11/../../../:/lib/arm-linux-gnueabihf/:/lib/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/
COLLECT_GCC_OPTIONS='--version' '-v'  '-mfloat-abi=hard' '-mtls-dialect=gnu'
'-mthumb' '-mlibarch=armv7-a+fp' '-march=armv7-a+fp' '-dumpdir' 'a.'
 /usr/lib/gcc/arm-linux-gnueabihf/11/collect2 -plugin
/usr/lib/gcc/arm-linux-gnueabihf/11/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/arm-linux-gnueabihf/11/lto-wrapper
-plugin-opt=-fresolution=/tmp/cc4oCuRH.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X --hash-style=gnu
--as-needed -m armelf_linux_eabi -pie --version
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/Scrt1.o
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/crti.o
/usr/lib/gcc/arm-linux-gnueabihf/11/crtbeginS.o
-L/usr/lib/gcc/arm-linux-gnueabihf/11
-L/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf
-L/usr/lib/gcc/arm-linux-gnueabihf/11/../../.. -L/lib/arm-linux-gnueabihf
-L/usr/lib/arm-linux-gnueabihf /tmp/ccYLSQQS.o -lgcc --push-state --as-needed
-lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state
/usr/lib/gcc/arm-linux-gnueabihf/11/crtendS.o
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/crtn.o
collect2 version 11.2.0
/usr/bin/ld -plugin /usr/lib/gcc/arm-linux-gnueabihf/11/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/arm-linux-gnueabihf/11/lto-wrapper
-plugin-opt=-fresolution=/tmp/cc4oCuRH.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X --hash-style=gnu
--as-needed -m armelf_linux_eabi -pie --version
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/Scrt1.o
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/crti.o
/usr/lib/gcc/arm-linux-gnueabihf/11/crtbeginS.o
-L/usr/lib/gcc/arm-linux-gnueabihf/11
-L/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf
-L/usr/lib/gcc/arm-linux-gnueabihf/11/../../.. -L/lib/arm-linux-gnueabihf
-L/usr/lib/arm-linux-gnueabihf /tmp/ccYLSQQS.o -lgcc --push-state --as-needed
-lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state
/usr/lib/gcc/arm-linux-gnueabihf/11/crtendS.o
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../arm-linux-gnueabihf/crtn.o
GNU ld (GNU Binutils for Debian) 2.37.90.20220207
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='--version' '-v'  '-mfloat-abi=hard' '-mtls-dialect=gnu'
'-mthumb' '-mlibarch=armv7-a+fp' '-march=armv7-a+fp' '-dumpdir' 'a.'

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
  2022-02-09 11:47 ` [Bug target/104455] " rearnsha at gcc dot gnu.org
  2022-02-10  3:12 ` noloader at gmail dot com
@ 2022-02-10 11:17 ` rearnsha at gcc dot gnu.org
  2022-02-10 20:44 ` noloader at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2022-02-10 11:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Your compiler is configured to pick the fp architecture up from the -march (or
-mcpu) option (it's using an 'auto' fpu).  Your ABI requires an FPU, so you
need to specify that as part of the -march command.  Use -march=armv7-a+fp or
something like -march=armv7-a+simd.  The various options are described in the
manual.

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
                   ` (2 preceding siblings ...)
  2022-02-10 11:17 ` rearnsha at gcc dot gnu.org
@ 2022-02-10 20:44 ` noloader at gmail dot com
  2022-02-10 21:16 ` schwab@linux-m68k.org
  2022-02-11 15:24 ` rearnsha at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: noloader at gmail dot com @ 2022-02-10 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

Jeffrey Walton <noloader at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #4 from Jeffrey Walton <noloader at gmail dot com> ---
(In reply to Richard Earnshaw from comment #3)
> Your compiler is configured to pick the fp architecture up from the -march
> (or -mcpu) option (it's using an 'auto' fpu).  Your ABI requires an FPU, so
> you need to specify that as part of the -march command.  Use
> -march=armv7-a+fp or something like -march=armv7-a+simd.  The various
> options are described in the manual.

Thanks again Richard.

So stepping back to 10,000 feet, we now need to specify options and ISA's we
are not using. That seems like a bug to me. I'm not sure I would consider this
fixed.

Where is it going to stop? How many non-used options that I am not aware of
will I need to specify?

I think either GCC or Debian needs to fix this. This could be a GCC bug because
GCC apparently knows there's a fp unit but it chooses to ignore it. Instead it
wants me to say it again. This could be a Debian bug because they need to
completely (not partially) configure things.

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
                   ` (3 preceding siblings ...)
  2022-02-10 20:44 ` noloader at gmail dot com
@ 2022-02-10 21:16 ` schwab@linux-m68k.org
  2022-02-11 15:24 ` rearnsha at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2022-02-10 21:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

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

* [Bug target/104455] Cannot select -march=armv7-a using GCC 11
  2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
                   ` (4 preceding siblings ...)
  2022-02-10 21:16 ` schwab@linux-m68k.org
@ 2022-02-11 15:24 ` rearnsha at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2022-02-11 15:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104455

--- Comment #5 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
(In reply to Jeffrey Walton from comment #4)

> 
> So stepping back to 10,000 feet, we now need to specify options and ISA's we
> are not using. That seems like a bug to me. I'm not sure I would consider
> this fixed.
> 
> Where is it going to stop? How many non-used options that I am not aware of
> will I need to specify?
> 
> I think either GCC or Debian needs to fix this. This could be a GCC bug
> because GCC apparently knows there's a fp unit but it chooses to ignore it.
> Instead it wants me to say it again. This could be a Debian bug because they
> need to completely (not partially) configure things.

No, it knows it /needs/ a FP unit, but you haven't told it which one is
available.  The Arm architecture has many variants and not all are necessarily
compatible with a base set, so you have to explicitly state which one is
intended.  Assumptions are a potential source of massive misunderstandings.

Note, in the past the FPU variant was baked into the compiler when it was
configured and this lead to all forms of confusion because if you had a Neon
FPU and then started compiling for a cortex-m device you could still end up
with Neon instructions in your code because there was no explicit option to
turn it off.  We've gone as far as we can by allowing you to simply specify
'+fp' rather than having to know exactly which variant of the VFP architecture
goes with armv7-a.

Also note that clang has the same option logic for CPU selection.

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

end of thread, other threads:[~2022-02-11 15:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 23:45 [Bug c++/104455] New: Cannot select -march=armv7-a using GCC 11 noloader at gmail dot com
2022-02-09 11:47 ` [Bug target/104455] " rearnsha at gcc dot gnu.org
2022-02-10  3:12 ` noloader at gmail dot com
2022-02-10 11:17 ` rearnsha at gcc dot gnu.org
2022-02-10 20:44 ` noloader at gmail dot com
2022-02-10 21:16 ` schwab@linux-m68k.org
2022-02-11 15:24 ` rearnsha at gcc dot gnu.org

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 read-only IMAP folder(s) and NNTP newsgroup(s).