Shiyou Yin <yinshiyou...@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@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. > > >-----Original Message----- > >From: YunQiang Su [mailto:wzss...@gmail.com] > >Sent: Friday, February 21, 2020 10:12 PM > >To: Shiyou Yin > >Cc: pixman@lists.freedesktop.org > >Subject: Re: [Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for > >Loongson MMI. > > > >Shiyou Yin <yinshiyou...@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:wzss...@gmail.com] > >> >Sent: Thursday, February 20, 2020 10:30 PM > >> >To: Yin Shiyou > >> >Cc: pixman@lists.freedesktop.org > >> >Subject: Re: [Pixman] [PATCH v2 2/3] build: use '-mloongson-mmi' for > >> >Loongson MMI. > >> > > >> >Yin Shiyou <yinshiyou...@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@lists.freedesktop.org > >> >> https://lists.freedesktop.org/mailman/listinfo/pixman > >> > > >> > > >> > > >> >-- > >> >YunQiang Su > >> > > > > > >-- > >YunQiang Su > -- YunQiang Su _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pixman