diff mbox series

[FFmpeg-devel] configure: arm: Don't add -march= to the compiler if no preference was passed

Message ID 20210920100040.3359213-1-martin@martin.st
State Accepted
Commit cb8dc600d289b2e30507a6fc3b61aaeb3129e0ad
Headers show
Series [FFmpeg-devel] configure: arm: Don't add -march= to the compiler if no preference was passed | expand

Commit Message

Martin Storsjö Sept. 20, 2021, 10 a.m. UTC
If no --cpu= option was passed to configure, we detect what the
compiler defaults to. This detected value was then fed back to the
rest of the configure logic, as if it was an explicit choice.

This breaks on Ubuntu 21.10 with GCC 11.1.

Since GCC 8, it's possible to add configure extra features via the
-march option, like e.g. -march=armv7-a+neon. If the -mfpu= option
is configured to default to 'auto', the fpu setting gets taken
from the -march option.

GCC 11.1 in Ubuntu seems to be configured to use -mfpu=auto. This
has the effect of breaking any compilation command that specifies
-march=armv7-a, because the driver implicitly also adds -mfloat-abi=hard,
and that combination results in this error:

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

Therefore, restructure configure. If no specific preference was set
(and the 'cpu' configure variable was set as the output of
probe_arm_arch), the value we tried to set via -march= was the same
value that we just tried to detect as the compiler default.

So instead, just try to detect what the compiler defaults to, with
to allow setting other configure settings (such as 'fast_unaligned'),
but don't try to spell out the compiler's default via the -march flag.

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Gianfranco Costamagna Sept. 20, 2021, 7 p.m. UTC | #1
Hello, thanks!
this fixes nicely my problem, and makes useless the two patches I posted
here:

please remove and drop:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4892
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4890
and accept this one whenever possible!

thanks

Gianfranco

Il giorno lun 20 set 2021 alle ore 12:00 Martin Storsjö <martin@martin.st>
ha scritto:

> If no --cpu= option was passed to configure, we detect what the
> compiler defaults to. This detected value was then fed back to the
> rest of the configure logic, as if it was an explicit choice.
>
> This breaks on Ubuntu 21.10 with GCC 11.1.
>
> Since GCC 8, it's possible to add configure extra features via the
> -march option, like e.g. -march=armv7-a+neon. If the -mfpu= option
> is configured to default to 'auto', the fpu setting gets taken
> from the -march option.
>
> GCC 11.1 in Ubuntu seems to be configured to use -mfpu=auto. This
> has the effect of breaking any compilation command that specifies
> -march=armv7-a, because the driver implicitly also adds -mfloat-abi=hard,
> and that combination results in this error:
>
>     cc1: error: ‘-mfloat-abi=hard’: selected processor lacks an FPU
>
> Therefore, restructure configure. If no specific preference was set
> (and the 'cpu' configure variable was set as the output of
> probe_arm_arch), the value we tried to set via -march= was the same
> value that we just tried to detect as the compiler default.
>
> So instead, just try to detect what the compiler defaults to, with
> to allow setting other configure settings (such as 'fast_unaligned'),
> but don't try to spell out the compiler's default via the -march flag.
>
> Signed-off-by: Martin Storsjö <martin@martin.st>
> ---
>  configure | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 9249254b70..3a05b8294b 100755
> --- a/configure
> +++ b/configure
> @@ -5009,9 +5009,11 @@ elif enabled arm; then
>          fi
>      }
>
> -    [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
>
>      case $cpu in
> +        generic)
> +            subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g')
> +        ;;
>          armv*)
>              cpuflags="-march=$cpu"
>              subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
> --
> 2.25.1
>
>
Janne Grunau Sept. 21, 2021, 8:03 a.m. UTC | #2
Hej,

On 2021-09-20 13:00:40 +0300, Martin Storsjö wrote:
> If no --cpu= option was passed to configure, we detect what the
> compiler defaults to. This detected value was then fed back to the
> rest of the configure logic, as if it was an explicit choice.
> 
> This breaks on Ubuntu 21.10 with GCC 11.1.
> 
> Since GCC 8, it's possible to add configure extra features via the
> -march option, like e.g. -march=armv7-a+neon. If the -mfpu= option
> is configured to default to 'auto', the fpu setting gets taken
> from the -march option.
> 
> GCC 11.1 in Ubuntu seems to be configured to use -mfpu=auto. This
> has the effect of breaking any compilation command that specifies
> -march=armv7-a, because the driver implicitly also adds -mfloat-abi=hard,
> and that combination results in this error:
> 
>     cc1: error: ‘-mfloat-abi=hard’: selected processor lacks an FPU
> 
> Therefore, restructure configure. If no specific preference was set
> (and the 'cpu' configure variable was set as the output of
> probe_arm_arch), the value we tried to set via -march= was the same
> value that we just tried to detect as the compiler default.
> 
> So instead, just try to detect what the compiler defaults to, with
> to allow setting other configure settings (such as 'fast_unaligned'),
> but don't try to spell out the compiler's default via the -march flag.
> 
> Signed-off-by: Martin Storsjö <martin@martin.st>
> ---
>  configure | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 9249254b70..3a05b8294b 100755
> --- a/configure
> +++ b/configure
> @@ -5009,9 +5009,11 @@ elif enabled arm; then
>          fi
>      }
>  
> -    [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
>  
>      case $cpu in
> +        generic)
> +            subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g')
> +        ;;
>          armv*)
>              cpuflags="-march=$cpu"
>              subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')

looks good to me

Janne
Martin Storsjö Sept. 21, 2021, 11:07 a.m. UTC | #3
On Mon, 20 Sep 2021, Gianfranco Costamagna wrote:

> Hello, thanks!
> this fixes nicely my problem, and makes useless the two patches I posted
> here:
> 
> please remove and drop:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4892
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4890
> and accept this one whenever possible!

Thanks, I pushed this one now.

I'm not sure if I have an account on patchwork, and even less so if I have 
access to edit the state of someone else's patches, so someone other than 
me have to take on that bit (or just leave them hanging, as I presume is 
the fate of most patches).

// Martin
diff mbox series

Patch

diff --git a/configure b/configure
index 9249254b70..3a05b8294b 100755
--- a/configure
+++ b/configure
@@ -5009,9 +5009,11 @@  elif enabled arm; then
         fi
     }
 
-    [ "$cpu" = generic ] && cpu=$(probe_arm_arch)
 
     case $cpu in
+        generic)
+            subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g')
+        ;;
         armv*)
             cpuflags="-march=$cpu"
             subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')