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

YunQiang Su wzssyqa at gmail.com
Fri Mar 6 11:40:43 UTC 2020


Shiyou Yin <yinshiyou-hf at loongson.cn> 于2020年3月6日周五 下午7:28写道:
>
> 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 | 69 ++++++++++++++++++++++++++++++++++++++++--------------------
>  1 file changed, 46 insertions(+), 23 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1ca3974..6f3cc7f 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,61 @@ 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_mmi_2f=yes)
> +AC_LINK_IFELSE([AC_LANG_SOURCE([[$tmp_src_loongson3a]])],cc_enable_mmi_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
>
> -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 $MMI_CFLAGS"

Consider this case
    MMI_CFLAGS="-mloongso-mmi" ./configure --enable-loongson-mmi=no
Your code will still include MMI_CFLAGS into CFLAGS.
I think that the option should have higher priority than MMI_CFLAGS.

Since we have USE_LOONGSON_MMI macro, this will make no trouble,
and I don't think that anybody will use something like this.

> +if test x"$enable_loongson_mmi" != xno; then
> +   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 +554,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)
> --
> 2.1.0
>
> _______________________________________________
> Pixman mailing list
> Pixman at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pixman



-- 
YunQiang Su


More information about the Pixman mailing list