Thanks. This version is much better now, at least it works, and has no big side effects.
Yin Shiyou <yinshiyou-hf@loongson> 于2020年3月4日周三 下午5:43写道: > > 1. Replace LS_CFLAGS with MMI_CFLAGS to express its intention more accurately. I don't think that you should rename it, since it is a part of API of the build system now. you can rename or drip it only when you are sure no body is using it. > 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 | 67 > +++++++++++++++++++++++++++++++++++++++--------------------- > 1 file changed, 44 insertions(+), 23 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 1ca3974..aaae5ef 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -272,16 +272,11 @@ 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([[ > +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 +287,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 > It just exit if compiler doesn't enable MMI by default. It is a reasonable choice. In fact I think you can pass some flags if --enable-loongson-mmi=yes is given. It is only a suggestion. > -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" > +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 +552,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@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/pixman -- YunQiang Su _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman