> -----Original Message-----
> From: Joseph Myers <jos...@codesourcery.com>
> Sent: 04 May 2020 21:03
> To: Szabolcs Nagy <szabolcs.n...@arm.com>
> Cc: Kyrylo Tkachov <kyrylo.tkac...@arm.com>; Florian Weimer
> <fwei...@redhat.com>; gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH][AArch64] Use __getauxval instead of getauxval in LSE
> detection code in libgcc
> 
> On Mon, 4 May 2020, Szabolcs Nagy wrote:
> 
> > i think __getauxval needs to be declared where it is used.
> 
> Yes.
> 
> > and libgcc should do a link test in configure becasuse a
> > libc may provide sys/auxv.h but not have __getauxval e.g.
> > musl libc does not export __getauxval, only getauxval.
> 
> libgcc can't do link tests, since it's built before libc.  It can use the
> glibc version number ($glibc_version_major and $glibc_version_minor)
> already computed in libgcc/configure.ac, which uses --with-glibc-version
> or target headers if available and otherwise defaults to 0.0.
> 
> A design principle is that glibc built with libgcc configured without
> glibc headers but with --with-glibc-version should produce an identical
> stripped binary to the glibc resulting from a longer alternating sequence
> of GCC and glibc builds.  So it is not correct for any libgcc
> functionality that would end up being linked into glibc binaries to depend
> on glibc headers or libraries being available when libgcc is configured.
> 
> Thus, this libgcc code should not actually be conditional on
> !inhibit_libc, without a fallback when configured using
> --with-glibc-version to specify a glibc version with __getauxval, because
> that would mean the modern process for bootstrapping a cross glibc build
> produces a glibc binary that quietly differs from one produced by a longer
> alternating sequence of builds (missing this constructor).

This version of the fix uses __getauxval instead of getauxval.
The whole thing is guarded simply on __GLIBC__ >= 2.
__getauxval was introduced in 2.16 but the aarch64 port was added in 2.17 so in 
practice I expect all aarch64 glibcs to support __getauxval.

Bootstrapped and tested on aarch64-none-linux-gnu.
Also tested on aarch64-none-elf and ran the glibc testsuite.

Thanks,
Kyrill

2020-05-05  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

        * config/aarch64/lse-init.c (init_have_lse_atomics): Use __getauxval
        instead of getauxval.
        (AT_HWCAP): Define.
        (HWCAP_ATOMICS): Define.
        Guard detection on __GLIBC__ >= 2.

> 
> --
> Joseph S. Myers
> jos...@codesourcery.com

Attachment: ool-glibc.patch
Description: ool-glibc.patch

Reply via email to