[Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.

Shiyou Yin yinshiyou-hf at loongson.cn
Sat Feb 22 13:19:10 UTC 2020


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.

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 
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.
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?

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.


>-----Original Message-----
>From: YunQiang Su [mailto:wzssyqa at gmail.com]
>Sent: Friday, February 21, 2020 10:12 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月21日周五 下午9:47写道:
>>
>> >1. it breaks cross building
>> This patch only let '-march=loongson2f' can be replaced with '-march=loongson-mmi'
>> when compile locally on Loongson-3A. In other cases, nothing will be changed.
>>
>> >2. qemu-user mode cannot make /proc/cpuinfo correct
>> >3. sometimes, some user may want to build software in a chroot env
>> >without /proc bind mount.
>> If there are no '/proc/cpuinfo', grep will return nonzero, -march=loongson2f will be
>> setted just like what it was setted before.
>>
>> Thanks very much, Your analysis is very comprehensive,
>> do you have a fix to satisfy all the above cases.
>>
>> This patch can let us compile locally on Loongson-3A without setting option 'LS_CFLAGS=***'.
>> In other cases like what you said, specify 'LS_CFLAGS=***' while compile may be the best approach.
>
>The generic use case is like:
>
>if not-defined LS_CFLAGS;then
>    reuslt=do_some_guess(compiler)
>    if not result;then
>        reuslt=do_some_guess(cpuinfo)
>    fi
>    if yes result;then
>        use_3a()
>    fi
>else
>    use_2f()
>fi
>
>Since as I know, some of your internal toolchains are configured:
>    --with-cpu=longson3a
>If you don't determine compiler, you will override the default
>configuration of gcc.
>
>>
>> >-----Original Message-----
>> >From: YunQiang Su [mailto:wzssyqa at gmail.com]
>> >Sent: Thursday, February 20, 2020 10:30 PM
>> >To: Yin Shiyou
>> >Cc: pixman at lists.freedesktop.org
>> >Subject: Re: [Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for Loongson MMI.
>> >
>> >Yin Shiyou <yinshiyou-hf at loongson.cn> 于2020年2月20日周四 下午10:23写道:
>> >>
>> >> It's suggested to use '-mloongson-mmi' to enable MMI.
>> >> To keep compatible with old processor, '-mloongson-mmi' will be
>> >> setted for Loongson-3A only.
>> >
>> >Please resend the whole patch set.
>> >
>> >> ---
>> >>  configure.ac | 8 ++++++--
>> >>  meson.build  | 2 +-
>> >>  2 files changed, 7 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/configure.ac b/configure.ac
>> >> index 1ca3974..2548799 100644
>> >> --- a/configure.ac
>> >> +++ b/configure.ac
>> >> @@ -271,9 +271,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"
>> >> +    IS_LOONGSON_3A=`grep "Loongson-3A" /proc/cpuinfo`
>> >
>> >It is a bad way to determine CPU from cpuinfo:
>> >
>> >1. it breaks cross building
>> >2. qemu-user mode cannot make /proc/cpuinfo correct
>> >3. sometimes, some user may want to build software in a chroot env
>> >without /proc bind mount.
>> >
>> >> +    if test $? -eq 0 -a -n "$IS_LOONGSON_3A" ; then
>> >> +        LS_CFLAGS="-mloongson-mmi"
>> >> +    else
>> >> +        LS_CFLAGS="-march=loongson2f"
>> >> +    fi
>> >>  fi
>> >>
>> >>  have_loongson_mmi=no
>> >> diff --git a/meson.build b/meson.build
>> >> index 15d3409..a45c969 100644
>> >> --- a/meson.build
>> >> +++ b/meson.build
>> >> @@ -51,7 +51,7 @@ endforeach
>> >>
>> >>  use_loongson_mmi = get_option('loongson-mmi')
>> >>  have_loongson_mmi = false
>> >> -loongson_mmi_flags = ['-march=loongson2f']
>> >> +loongson_mmi_flags = ['-mloongson-mmi']
>> >>  if not use_loongson_mmi.disabled()
>> >>    if host_machine.cpu_family() == 'mips64' and cc.compiles('''
>> >>        #ifndef __mips_loongson_vector_rev
>> >> --
>> >> 2.1.0
>> >>
>> >> _______________________________________________
>> >> Pixman mailing list
>> >> Pixman at lists.freedesktop.org
>> >> https://lists.freedesktop.org/mailman/listinfo/pixman
>> >
>> >
>> >
>> >--
>> >YunQiang Su
>>
>
>
>--
>YunQiang Su



More information about the Pixman mailing list