[v1] LoongArch: Fix tst-gnu2-tls2 compiler error

Message ID 20240520090512.1122982-1-mengqinggang@loongson.cn (mailing list archive)
State Committed
Headers
Series [v1] LoongArch: Fix tst-gnu2-tls2 compiler error |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

mengqinggang May 20, 2024, 9:05 a.m. UTC
  Add -mno-lsx to tst-gnu2-tlsmod*.c if gcc support -mno-lsx.
Add escape character '\' in vector support test function.
---
 sysdeps/loongarch/Makefile     | 2 ++
 sysdeps/loongarch/configure    | 2 ++
 sysdeps/loongarch/configure.ac | 5 +++--
 3 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Xi Ruoyao May 20, 2024, 11:49 a.m. UTC | #1
On Mon, 2024-05-20 at 17:05 +0800, mengqinggang wrote:
> Add -mno-lsx to tst-gnu2-tlsmod*.c if gcc support -mno-lsx.

Ok.  I even didn't consider this.  Stupid I.

> Add escape character '\' in vector support test function.
> ---
>  sysdeps/loongarch/Makefile     | 2 ++
>  sysdeps/loongarch/configure    | 2 ++
>  sysdeps/loongarch/configure.ac | 5 +++--
>  3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
> index a4ee915eff..b00c090faa 100644
> --- a/sysdeps/loongarch/Makefile
> +++ b/sysdeps/loongarch/Makefile
> @@ -35,10 +35,12 @@ sysdep-dl-routines += \
>  # Disable the compiler from using LSX for TLS descriptor tests, or storing into
>  # 16B TLS variable may clobber FP/vector registers and prevent us from checking
>  # their contents.
> +ifeq (yes,$(loongarch-vec-com))
>  CFLAGS-tst-gnu2-tls2mod0.c += -mno-lsx
>  CFLAGS-tst-gnu2-tls2mod1.c += -mno-lsx
>  CFLAGS-tst-gnu2-tls2mod2.c += -mno-lsx
>  endif
> +endif
>  
>  # LoongArch's assembler also needs to know about PIC as it changes the
>  # definition of some assembler macros.
> diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
> index 731f79438f..93691af243 100644
> --- a/sysdeps/loongarch/configure
> +++ b/sysdeps/loongarch/configure
> @@ -143,3 +143,5 @@ then
>    printf "%s\n" "#define HAVE_LOONGARCH_VEC_COM 1" >>confdefs.h
>  
>  fi
> +config_vars="$config_vars
> +loongarch-vec-com = $libc_cv_loongarch_vec_com"
> diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
> index 24fee55dcc..c56a203574 100644
> --- a/sysdeps/loongarch/configure.ac
> +++ b/sysdeps/loongarch/configure.ac
> @@ -71,8 +71,8 @@ AC_CACHE_CHECK([for vector support in compiler],
>  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
>  void foo (void)
>  {
> -  asm volatile ("vldi $vr0, 1" ::: "$vr0");
> -  asm volatile ("xvldi $xr0, 1" ::: "$xr0");
> +  asm volatile ("vldi \$vr0, 1" ::: "\$vr0");
> +  asm volatile ("xvldi \$xr0, 1" ::: "\$xr0");
>  }
>  ]])],
>                  [libc_cv_loongarch_vec_com=yes],
> @@ -81,3 +81,4 @@ if test "$libc_cv_loongarch_vec_com" = yes ;
>  then
>    AC_DEFINE(HAVE_LOONGARCH_VEC_COM)
>  fi
> +LIBC_CONFIG_VAR([loongarch-vec-com], [$libc_cv_loongarch_vec_com])
  

Patch

diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
index a4ee915eff..b00c090faa 100644
--- a/sysdeps/loongarch/Makefile
+++ b/sysdeps/loongarch/Makefile
@@ -35,10 +35,12 @@  sysdep-dl-routines += \
 # Disable the compiler from using LSX for TLS descriptor tests, or storing into
 # 16B TLS variable may clobber FP/vector registers and prevent us from checking
 # their contents.
+ifeq (yes,$(loongarch-vec-com))
 CFLAGS-tst-gnu2-tls2mod0.c += -mno-lsx
 CFLAGS-tst-gnu2-tls2mod1.c += -mno-lsx
 CFLAGS-tst-gnu2-tls2mod2.c += -mno-lsx
 endif
+endif
 
 # LoongArch's assembler also needs to know about PIC as it changes the
 # definition of some assembler macros.
diff --git a/sysdeps/loongarch/configure b/sysdeps/loongarch/configure
index 731f79438f..93691af243 100644
--- a/sysdeps/loongarch/configure
+++ b/sysdeps/loongarch/configure
@@ -143,3 +143,5 @@  then
   printf "%s\n" "#define HAVE_LOONGARCH_VEC_COM 1" >>confdefs.h
 
 fi
+config_vars="$config_vars
+loongarch-vec-com = $libc_cv_loongarch_vec_com"
diff --git a/sysdeps/loongarch/configure.ac b/sysdeps/loongarch/configure.ac
index 24fee55dcc..c56a203574 100644
--- a/sysdeps/loongarch/configure.ac
+++ b/sysdeps/loongarch/configure.ac
@@ -71,8 +71,8 @@  AC_CACHE_CHECK([for vector support in compiler],
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 void foo (void)
 {
-  asm volatile ("vldi $vr0, 1" ::: "$vr0");
-  asm volatile ("xvldi $xr0, 1" ::: "$xr0");
+  asm volatile ("vldi \$vr0, 1" ::: "\$vr0");
+  asm volatile ("xvldi \$xr0, 1" ::: "\$xr0");
 }
 ]])],
                 [libc_cv_loongarch_vec_com=yes],
@@ -81,3 +81,4 @@  if test "$libc_cv_loongarch_vec_com" = yes ;
 then
   AC_DEFINE(HAVE_LOONGARCH_VEC_COM)
 fi
+LIBC_CONFIG_VAR([loongarch-vec-com], [$libc_cv_loongarch_vec_com])