The 05/04/2020 20:02, Joseph Myers wrote: > 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).
i.e. libgcc needs to replicate definitions from sys/auxv.h? like _Bool flag = 0; #if GLIBC_VERSION_OK # define AT_HWCAP ... # define HWCAP_ATOMICS ... unsigned long __getauxval (unsigned long); __attribute__ ((constructor)) static void init () { flag = (__getauxval(AT_HWCAP) & HWCAP_ATOMICS) != 0; } #endif