Message ID | 20230919070109.573374-1-mengqinggang@loongson.cn |
---|---|
State | New |
Headers | show |
Series | [v3] Modify gas uleb128 support test | expand |
Pushed to r14-4161. 在 2023/9/19 下午3:01, mengqinggang 写道: > Some assemblers (GNU as for LoongArch) generates relocations for leb128 > symbol arithmetic for relaxation, we need to disable relaxation probing > leb128 support then. > > gcc/ChangeLog: > > * configure: Regenerate. > * configure.ac: Checking assembler for -mno-relax support. > Disable relaxation when probing leb128 support. > > co-authored-by: Xi Ruoyao <xry111@xry111.site> > --- > gcc/configure | 42 +++++++++++++++++++++++++++++++++++++++++- > gcc/configure.ac | 17 ++++++++++++++++- > 2 files changed, 57 insertions(+), 2 deletions(-) > > diff --git a/gcc/configure b/gcc/configure > index d5e218e9a16..2ceab4e3b9c 100755 > --- a/gcc/configure > +++ b/gcc/configure > @@ -24676,6 +24676,46 @@ _ACEOF > > > > +# Some assemblers (GNU as for LoongArch) generates relocations for > +# leb128 symbol arithmetic for relaxation, we need to disable relaxation > +# probing leb128 support then. > +case $target in > + loongarch*-*-*) > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mno-relax support" >&5 > +$as_echo_n "checking assembler for -mno-relax support... " >&6; } > +if ${gcc_cv_as_mno_relax+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + gcc_cv_as_mno_relax=no > + if test x$gcc_cv_as != x; then > + $as_echo '.text' > conftest.s > + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mno-relax -o conftest.o conftest.s >&5' > + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 > + (eval $ac_try) 2>&5 > + ac_status=$? > + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 > + test $ac_status = 0; }; } > + then > + gcc_cv_as_mno_relax=yes > + else > + echo "configure: failed program was" >&5 > + cat conftest.s >&5 > + fi > + rm -f conftest.o conftest.s > + fi > +fi > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mno_relax" >&5 > +$as_echo "$gcc_cv_as_mno_relax" >&6; } > +if test $gcc_cv_as_mno_relax = yes; then > + check_leb128_asflags=-mno-relax > +fi > + > + ;; > + *) > + check_leb128_asflags= > + ;; > +esac > + > # Check if we have .[us]leb128, and support symbol arithmetic with it. > # Older versions of GAS and some non-GNU assemblers, have a bugs handling > # these directives, even when they appear to accept them. > @@ -24694,7 +24734,7 @@ L1: > L2: > .uleb128 0x8000000000000000 > ' > conftest.s > - if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' > + if { ac_try='$gcc_cv_as $gcc_cv_as_flags $check_leb128_asflags -o conftest.o conftest.s >&5' > { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 > (eval $ac_try) 2>&5 > ac_status=$? > diff --git a/gcc/configure.ac b/gcc/configure.ac > index 019d0375a2f..d780ea25386 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -3229,10 +3229,25 @@ AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix) > > gcc_AC_INITFINI_ARRAY > > +# Some assemblers (GNU as for LoongArch) generates relocations for > +# leb128 symbol arithmetic for relaxation, we need to disable relaxation > +# probing leb128 support then. > +case $target in > + loongarch*-*-*) > + gcc_GAS_CHECK_FEATURE([-mno-relax support], > + gcc_cv_as_mno_relax,[-mno-relax],[.text],, > + [check_leb128_asflags=-mno-relax]) > + ;; > + *) > + check_leb128_asflags= > + ;; > +esac > + > # Check if we have .[us]leb128, and support symbol arithmetic with it. > # Older versions of GAS and some non-GNU assemblers, have a bugs handling > # these directives, even when they appear to accept them. > -gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,, > +gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128, > +[$check_leb128_asflags], > [ .data > .uleb128 L2 - L1 > L1:
diff --git a/gcc/configure b/gcc/configure index d5e218e9a16..2ceab4e3b9c 100755 --- a/gcc/configure +++ b/gcc/configure @@ -24676,6 +24676,46 @@ _ACEOF +# Some assemblers (GNU as for LoongArch) generates relocations for +# leb128 symbol arithmetic for relaxation, we need to disable relaxation +# probing leb128 support then. +case $target in + loongarch*-*-*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mno-relax support" >&5 +$as_echo_n "checking assembler for -mno-relax support... " >&6; } +if ${gcc_cv_as_mno_relax+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_mno_relax=no + if test x$gcc_cv_as != x; then + $as_echo '.text' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mno-relax -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_mno_relax=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mno_relax" >&5 +$as_echo "$gcc_cv_as_mno_relax" >&6; } +if test $gcc_cv_as_mno_relax = yes; then + check_leb128_asflags=-mno-relax +fi + + ;; + *) + check_leb128_asflags= + ;; +esac + # Check if we have .[us]leb128, and support symbol arithmetic with it. # Older versions of GAS and some non-GNU assemblers, have a bugs handling # these directives, even when they appear to accept them. @@ -24694,7 +24734,7 @@ L1: L2: .uleb128 0x8000000000000000 ' > conftest.s - if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' + if { ac_try='$gcc_cv_as $gcc_cv_as_flags $check_leb128_asflags -o conftest.o conftest.s >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 ac_status=$? diff --git a/gcc/configure.ac b/gcc/configure.ac index 019d0375a2f..d780ea25386 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3229,10 +3229,25 @@ AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix) gcc_AC_INITFINI_ARRAY +# Some assemblers (GNU as for LoongArch) generates relocations for +# leb128 symbol arithmetic for relaxation, we need to disable relaxation +# probing leb128 support then. +case $target in + loongarch*-*-*) + gcc_GAS_CHECK_FEATURE([-mno-relax support], + gcc_cv_as_mno_relax,[-mno-relax],[.text],, + [check_leb128_asflags=-mno-relax]) + ;; + *) + check_leb128_asflags= + ;; +esac + # Check if we have .[us]leb128, and support symbol arithmetic with it. # Older versions of GAS and some non-GNU assemblers, have a bugs handling # these directives, even when they appear to accept them. -gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128,, +gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128, +[$check_leb128_asflags], [ .data .uleb128 L2 - L1 L1: