[PATCH] powerpc: Define USE_PPC64_NOTOC iff compiler and linker also supports it
Adhemerval Zanella
adhemerval.zanella@linaro.org
Mon Nov 22 17:54:12 GMT 2021
On 19/11/2021 12:52, Tulio Magno Quites Machado Filho wrote:
> 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>
Ack.
>
> 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)
I am using the provided package from llvm.org itself, where it returns:
$ ld.lld --version
LLD 13.0.0 (https://github.com/llvm/llvm-project/ 24c8eaec9467b2aaf70b0db33a4e4dd415139a50) (compatible with GNU linkers)
And I could build everything, including tests, for default (no --with-cpu),
and with --with-cpu=power8 and --with-cpu=power9. The --with-cpu=power10
still shows same issues while linking the loader:
ld.lld: error: ../sysdeps/powerpc/powerpc64/dl-trampoline.S:55:(.text+0x29AE4): call to save__dl_fixup lacks nop, can't restore toc
ld.lld: error: ../sysdeps/powerpc/powerpc64/dl-trampoline.S:286:(.text+0x29C58): call to save__dl_profile_fixup lacks nop, can't restore toc
ld.lld: error: ../sysdeps/powerpc/powerpc64/dl-trampoline.S:455:(.text+0x29E78): call to save__dl_call_pltexit lacks nop, can't restore toc
collect2: error: ld returned 1 exit status
Which I am not sure it is something related to lld or something we should
fix on glibc.
>
> The following change to the case test in configure fixes this issue:
>
> - "LLD"*)
> + *"LLD"*)
>
> Is this a GNU Bash-ism?
I think Debian is patching LLD, so we will need to support anything before
"LLD" string.
>
>
> 2. LLD itself crashes while linking the tests.
> I need to collect more details.
>
Do you have a log of what is happening? Could it be something related to the
debian provided LLD? Could you check with the official package?
More information about the Libc-alpha
mailing list