[Pixman] [PATCH v3] build: improve control logic for enabling MMI.

YunQiang Su syq at debian.org
Sat Mar 7 02:55:51 UTC 2020


在 2020-03-07六的 10:47 +0800,Shiyou Yin写道:
> From: Yin Shiyou <yinshiyou-hf at loongson>
> 
> 1. Replace LS_CFLAGS with MMI_CFLAGS to express its intention more
> accurately.
>    LS_CFLAGS is still available, but it is not recommended.
> 2. Improve the control logic for enabling MMI.
> 
> Three essential conditions for enabling MMI:
> 1) user have not specify --disable-loongson-mmi.
> 2) MMI options has been specified by MMI_CFLAGS,CC or compiler's
> default setting.
> 3) compiler supports these MMI options.
> ---
>  configure.ac | 70 ++++++++++++++++++++++++++++++++++++++++--------
> ------------
>  1 file changed, 47 insertions(+), 23 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 1ca3974..be7a6ec 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -272,16 +272,13 @@ PIXMAN_CHECK_CFLAG([-xldscope=hidden], [dnl
>  dnl
> =====================================================================
> ======
>  dnl Check for Loongson Multimedia Instructions
>  
> -if test "x$LS_CFLAGS" = "x" ; then
> -    LS_CFLAGS="-march=loongson2f"
> -fi
> -
> -have_loongson_mmi=no
> -AC_MSG_CHECKING(whether to use Loongson MMI assembler)
> -
> +# check CC default configuration
>  xserver_save_CFLAGS=$CFLAGS
> -CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
> -AC_LINK_IFELSE([AC_LANG_SOURCE([[
> +# MMI_CFLAGS is recommended, LS_CFLAGS is being replaced by
> MMI_CFLAGS.
> +MMI_CFLAGS="$MMI_CFLAGS $LS_CFLAGS"
> +AC_MSG_CHECKING(whether to enable Loongson MMI)
> +
> +read -d '' tmp_src_mmi << EOF
>  #ifndef __mips_loongson_vector_rev
>  #error "Loongson Multimedia Instructions are only available on
> Loongson"
>  #endif
> @@ -292,35 +289,62 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[
>  int main () {
>      union {
>          __m64 v;
> -        char c[8];
> +        char c[[8]]; // autoconf will strip one pair of [], it is
> not typo
>      } a = { .c = {1, 2, 3, 4, 5, 6, 7, 8} };
>      int b = 4;
>      __m64 c = _mm_srli_pi16 (a.v, b);
>      return 0;
> -}]])], have_loongson_mmi=yes)
> -CFLAGS=$xserver_save_CFLAGS
> +}
> +EOF
> +read -d '' tmp_src_loongson2f << EOF
> +#ifndef _MIPS_ARCH_LOONGSON2F
> +#error "Loongson 2F support of CC is not enabled, Please use CFLAGS
> to enable it"
> +#endif
> +$tmp_src_mmi
> +EOF
> +read -d '' tmp_src_loongson3a << EOF
> +#if !defined(_MIPS_ARCH_LOONGSON2F) && defined(__mips_loongson_mmi)
> +#else
> +  #error "Loongson 3A/MMI support of CC is not enabled, Please use
> CFLAGS to enable it"
> +#endif
> +$tmp_src_mmi
> +EOF
> +
> +CFLAGS="$xserver_save_CFLAGS $MMI_CFLAGS -I$srcdir"
> +AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson2f]])],cc_enable_m
> mi_2f=yes)
> +AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson3a]])],cc_enable_m
> mi_3a=yes)
>  
> +# user may disable MMI by --disable-loongson-mmi even compiler
> supports it by default
> +# or MMI_CFLAGS for MMI is given
>  AC_ARG_ENABLE(loongson-mmi,
>     [AC_HELP_STRING([--disable-loongson-mmi],
>                     [disable Loongson MMI fast paths])],
>     [enable_loongson_mmi=$enableval], [enable_loongson_mmi=auto])
>  
> -if test $enable_loongson_mmi = no ; then
> -   have_loongson_mmi=disabled
> +if test x"$enable_loongson_mmi" = xyes && \
> +   test x"$cc_enable_mmi_2f" != x"yes" && \
> +   test x"$cc_enable_mmi_3a" != x"yes"; then
> +    AC_MSG_ERROR([MMI_CFLAGS is required while enable MMI.
> +    Try to set MMI_CFLAGS as -march=loongson2f for 2F or -mloongson-
> mmi for 3A])
>  fi
>  
> -if test $have_loongson_mmi = yes ; then
> -   AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia
> Instructions])
> -else
> -   LS_CFLAGS=
> +# MMI will be disabled if compiler didn't support it or
> +# exact option for compiling it is not specified.
> +if test x"$enable_loongson_mmi" != xno && \
> +   test x"$cc_enable_mmi_2f" != x"yes" && \
> +   test x"$cc_enable_mmi_3a" != x"yes"; then
> +    enable_loongson_mmi=no
> +    MMI_CFLAGS=""
>  fi
>  

Looks good for me.
Reviewed-by: YunQiang Su <syq at debian.org>

> -AC_MSG_RESULT($have_loongson_mmi)
> -if test $enable_loongson_mmi = yes && test $have_loongson_mmi = no ;
> then
> -   AC_MSG_ERROR([Loongson MMI not detected])
> +CFLAGS="$xserver_save_CFLAGS"
> +if test x"$enable_loongson_mmi" != xno; then
> +   CFLAGS="$CFLAGS $MMI_CFLAGS"
> +   AC_DEFINE(USE_LOONGSON_MMI, 1, [use Loongson Multimedia
> Instructions])
>  fi
> +AC_MSG_RESULT($enable_loongson_mmi)
>  
> -AM_CONDITIONAL(USE_LOONGSON_MMI, test $have_loongson_mmi = yes)
> +AM_CONDITIONAL(USE_LOONGSON_MMI, test x"$enable_loongson_mmi" !=
> xno)
>  
>  dnl
> =====================================================================
> ======
>  dnl Check for MMX
> @@ -531,7 +555,7 @@ case $host_os in
>        ;;
>  esac
>  
> -AC_SUBST(LS_CFLAGS)
> +AC_SUBST(MMI_CFLAGS)
>  AC_SUBST(IWMMXT_CFLAGS)
>  AC_SUBST(MMX_CFLAGS)
>  AC_SUBST(MMX_LDFLAGS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/pixman/attachments/20200307/a7f95d4b/attachment.sig>


More information about the Pixman mailing list