[PATCH] powerpc: Automatic CPU detection in preconfigure

Florian Weimer fweimer@redhat.com
Fri May 8 20:31:19 GMT 2020


* Paul E. Murphy via Libc-alpha:

> +# Lets ask the compiler which Power processor we've got, in case the user did
> +# not choose a --with-cpu value.
> +if test -z "$with_cpu"; then
> +  AC_MSG_NOTICE([--with-cpu not set. Trying to detect CPU.])
> +  archcpu=`echo "int foo () { return 0; }" \
> +	   | $CC $CFLAGS $CPPFLAGS -S -frecord-gcc-switches -xc -o - - \
> +	   | grep -E "\.ascii.*mcpu" | sed "s/.*mcpu=\(.*\)\"/\1/"`
> +  # Set --with-cpu as appropriate.
> +  # Note if you add patterns here you must ensure that an appropriate
> +  # directory exists in sysdeps/powerpc.
> +  case "$archcpu" in
> +  4??|4??fp)
> +    submachine=${archcpu%fp}
> +    # The submachine is now inferred.  However the generic submachine
> +    # check will not respect the soft/hard fp choice.  Fill the cache
> +    # to skip the unneeded check which unconditionally sets
> +    # -m{cpu,arch}=${submachine}.
> +    AC_CACHE_VAL(libc_cv_cc_submachine,libc_cv_cc_submachine="")
> +    ;;
> +  a2|970|power*)
> +    submachine=${archcpu}
> +    ;;
> +  *)
> +    AC_WARN([CPU not identified; using default])
> +    ;;
> +  esac
> +fi

This looks like a forward-compatibility trap.  If GCC supports -mfuture
(under the real name), an appropriate directory may not yet exist under
sysdeps/powerpc.

I also do not think this works as expected if GCC itself is built with
--with-cpu.  Maybe extracting the .machine argument works instead?

Thanks,
Florian



More information about the Libc-alpha mailing list