On Thu, 2019-08-29 at 22:20 +0100, Robert Swindells wrote: > Michał Górny <mgorny%gentoo.org@localhost> wrote: > > On Wed, 2019-08-28 at 02:40 +0100, Robert Swindells wrote: > > > I wrote: > > > > It looks like clang++ on aarch64 is broken too, but in a different way. > > > > > > > > Static constructors don't get called. I do have a small test application > > > > that demonstrates this. > > > > > > This looks to be caused by clang/llvm putting the references to the > > > constructor in the .ctors section instead of the .init_array section as > > > required by the ABI. > > > > > > There is code in clang to select this and a web search turns up some > > > patches from 2014 to enable it for all AARCH64 ELF platforms but the > > > source tree seems to have changed a lot since then. > > > > I see the following for Generic_ELF thingy: > > > > if (DriverArgs.hasFlag(options::OPT_fuse_init_array, > > options::OPT_fno_use_init_array, UseInitArrayDefault)) > > CC1Args.push_back("-fuse-init-array"); > > > > NetBSD should be using that. Could you verify with 'clang -v' whether > > it's being passed to cc1? > > The NetBSD ToolChain class that is derived from the Generic_ELF class > also has an addClangTargetOptions() method that will override the one in > the parent, the code fragment above won't get called. Indeed, my mistake. > > The version of clang in base looks fine. > > I'm using this patch: > > $NetBSD$ > > --- lib/Driver/ToolChains/NetBSD.cpp.orig 2019-01-30 19:13:49.000000000 +0000 > +++ lib/Driver/ToolChains/NetBSD.cpp > @@ -469,10 +469,20 @@ SanitizerMask NetBSD::getSupportedSaniti > return Res; > } > > -void NetBSD::addClangTargetOptions(const ArgList &, > +void NetBSD::addClangTargetOptions(const ArgList &DriverArgs, > ArgStringList &CC1Args, > Action::OffloadKind) const { > const SanitizerArgs &SanArgs = getSanitizerArgs(); > + bool UseInitArrayDefault = > + getTriple().getArch() == llvm::Triple::aarch64 || > + getTriple().getArch() == llvm::Triple::aarch64_be || > + getTriple().getArch() == llvm::Triple::riscv32 || > + getTriple().getArch() == llvm::Triple::riscv64; Don't we want to enable it for all platforms these days? > + > + if (DriverArgs.hasFlag(options::OPT_fuse_init_array, > + options::OPT_fno_use_init_array, UseInitArrayDefault)) > + CC1Args.push_back("-fuse-init-array"); > + > if (SanArgs.hasAnySanitizer()) > CC1Args.push_back("-D_REENTRANT"); > } -- Best regards, Michał Górny
Attachment:
signature.asc
Description: This is a digitally signed message part