[PATCH] powerpc: Define USE_PPC64_NOTOC iff compiler and linker also supports it

Tulio Magno Quites Machado Filho tuliom@linux.ibm.com
Fri Nov 19 15:52:59 GMT 2021


Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:

> diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac
> index b77156f696..05f0000807 100644
> --- a/sysdeps/powerpc/powerpc64/configure.ac
> +++ b/sysdeps/powerpc/powerpc64/configure.ac
> @@ -22,13 +22,22 @@ if test x$libc_cv_overlapping_opd = xyes; then
>    AC_DEFINE(USE_PPC64_OVERLAPPING_OPD)
>  fi
>  
> -# @notoc started to be supported in GNU Binutils 2.31.
> -AC_CACHE_CHECK([if the assembler supports @notoc],
> -	       libc_cv_ppc64_notoc, [
> -	       AC_COMPILE_IFELSE([AC_LANG_SOURCE([
> -void foo (void) {asm("b foo@notoc");}
> -		  ])],
> -		  [libc_cv_ppc64_notoc=yes],
> -		  [libc_cv_ppc64_notoc=no])])
> +# We check if compiler supports @notoc generation since there is no
> +# gain by enabling it if it will be optimized away by the linker.
> +# It also helps linkers that might not optimize it and end up
> +# generating stubs with ISA 3.1 instruction even targetting older ISA.
> +AC_CACHE_CHECK([if the compiler supports @notoc],
> +	       libc_cv_ppc64_notoc, [dnl
> +  cat > conftest.c <<EOF
> +int bar (void);
> +int foo (void) { return bar () + 1; }
> +EOF
> +  libc_cv_ppc64_notoc=no
> +  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -o conftest.s conftest.c]) \

In order to use the -mcpu flag set via --with-cpu=power10, this command should be:

    ${CC-cc} $libc_cv_cc_submachine $CFLAGS $CPPFLAGS -S -o conftest.s conftest.c

LGTM with that fix.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

Notice that I'm still not able to complete building the tests using lld 13.0 on
powerpc64le after this patch.  I've seen 2 issues:

1. Some distributions modify the version output, causing an error when parsing
   LLD's version, e.g.

    $ ld.lld --version
    Debian LLD 13.0.0 (compatible with GNU linkers)

The following change to the case test in configure fixes this issue:

-  "LLD"*)
+  *"LLD"*)

Is this a GNU Bash-ism?


2. LLD itself crashes while linking the tests.
   I need to collect more details.

-- 
Tulio Magno


More information about the Libc-alpha mailing list