[Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
YunQiang Su
wzssyqa at gmail.com
Thu Feb 27 01:48:14 UTC 2020
Shiyou Yin <yinshiyou-hf at loongson.cn> 于2020年2月26日周三 下午5:46写道:
>
> >-----Original Message-----
> >From: YunQiang Su [mailto:wzssyqa at gmail.com]
> >Sent: Saturday, February 22, 2020 10:20 PM
> >To: Shiyou Yin
> >Cc: pixman at lists.freedesktop.org
> >Subject: Re: [Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
> >
> >Shiyou Yin <yinshiyou-hf at loongson.cn> 于2020年2月22日周六 下午9:19写道:
> >>
> >> First let's clarify what exactly compatibility mean, or what specific goals we want to achieve.
> >>
> >> If it's just ensure the features of new code consistent with old compilation and hardware
> >> environment, then this patch will works well.
> >>
> >
> >Of course that is not enough. If it is the only your goal, why sent this patch?
> >
> >> If it is going to make sure MMI can be enabled and works well on each cases, it may be not easy.
> >>
> >> Guess compiler? Compiler check can only ensure the compile option is supported or not
> >
> >yq at ls3b1500:~$ gcc -march=loongson3a -dM -E - < /dev/null | grep mmi
> >#define __mips_loongson_mmi 1
> >
> >So, you can try to compile (-c) the bellow code to test whether the
> >compiler has MMI enabled
> >
> >#ifndef __mips_loongson_mmi
> ># error "Loongson MMI is not supported"
> >#endif
> >
> >For example, mipsel-linux-gnu-gcc is a generic mips compiler and
> >target mips32r2;
> >and the user set CC="mipsel-linux-gnu-gcc -march=loongson3",
> >Your test can still pass.
> >
> >
> >> and then MMI instruction can be compiled. We can't ensure the binary can works well on
> >> each hardware, especially in the case of cross-compilation.
> >
> >Sure, that why you need to obey users configure, by LS_CFLAGS or CC or
> >the default configure of compiler.
> >
> >> Almost all latest gcc support "-march=loongson2f" and "-march=loongson3a"
> >> and "-mloongson-mmi". So which kind of compiler we will set LS_CFLAGS as -mloongson-mmi?
> >
> >due to history reason, the default value of LS_CFLAGS should be keep as 2f, and
> >user can set it by
> >
> >LS_CFLAGS="-mloongson-mmi" ./configure -- blabla
> >
> >>
> >> Guess CPU is always used in runtime check, it should be added in the optimization code but not in
> >> configure. The configure just need to ensure the compile process can finished successfully,
> >> So it may check compiler support some options or not and then enable/disable the features.
> >>
> >
> >Generally, we don't need to guess the BUILD_MACHINE's cpu in buildtime.
> >
>
> If this is what you mean, I will agree and update the patch.
> It should be noted that we still need to manually specify appropriate option to enable MMI correctly.
> The only change is now we have two new ways(2 & 3) to specify this option:
> 1) LS_CFLAGS
> 2) CC
> 3)compiler's default cflags, such as COLLECT_GCC_OPTIONS of gcc.
>
>
> Diff is as follows:
It is some better now.
>
> diff --git a/configure.ac b/configure.ac
> index 1ca3974..be9212d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -78,7 +78,7 @@ AC_C_BIGENDIAN
> AC_C_INLINE
>
> dnl PIXMAN_LINK_WITH_ENV(env-setup, program, true-action, false-action)
> -dnl
> +
> dnl Compiles and links the given program in the environment setup by env-setup
> dnl and executes true-action on success and false-action on failure.
> AC_DEFUN([PIXMAN_LINK_WITH_ENV],[dnl
> @@ -273,7 +273,27 @@ dnl ===========================================================================
> dnl Check for Loongson Multimedia Instructions
>
> if test "x$LS_CFLAGS" = "x" ; then
> - LS_CFLAGS="-march=loongson2f"
> + # check default cflags to set LS_CFLAGS
> + # Has -mloongson-mmi or -march=loongson3a : LS_CFLAGS="-mloongson-mmi"
> + # else : LS_CFLAGS="-march=loongson2f"
> + xserver_save_CFLAGS=$CFLAGS
> + CFLAGS=" $LS_CFLAGS $CFLAGS -I$srcdir"
> +AC_RUN_IFELSE([AC_LANG_SOURCE([[
AC_RUN_IFELSE will make always fail when cross build.
If you wish I can work for cross build, you can use
AC_COMPILE_IFELSE / AC_LINK_IFELSE
> +int main () {
> + /* check default cflags */
> + #ifndef __mips_loongson_mmi
> + /* No -mloongson-mmi,-march=loongson3a and -march=loongson2f */
> + return 0;
> + #else
> + #ifdef _MIPS_ARCH_LOONGSON2F
> + /* Has -march=loongson2f */
> + return 0;
> + #else
> + /* Has -mloongson-mmi or -march=loongson3a */
> + return 1;
> + #endif
> + #endif
> +}]])], LS_CFLAGS="-mloongson-mmi", LS_CFLAGS="-march=loongson2f")
> fi
No matter how, it will set LS_CFLAGS to
-mloongson-mmi
or
-march=loongson2f
So, on platform/gcc doesn't prefer Loongson, it will always use these 2 option.
It will break general MIPS distributions.
>
> have_loongson_mmi=no
>
>
--
YunQiang Su
More information about the Pixman
mailing list