Re: [PATCH v3] perf tools: avoid sample_reg_masks being const + weak
From: Arnaldo Carvalho de Melo
Date: Thu Oct 10 2019 - 08:29:15 EST
Em Wed, Oct 09, 2019 at 04:07:37PM -0700, Ian Rogers escreveu:
> On Tue, Oct 8, 2019 at 5:31 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > On Mon, Sep 30, 2019 at 05:36:23PM -0700, Ian Rogers wrote:
> > > Being const + weak breaks with some compilers that constant-propagate
> > > from the weak symbol. This behavior is outside of the specification, but
> > > in LLVM is chosen to match GCC's behavior.
> > >
> > > LLVM's implementation was set in this patch:
> > > https://github.com/llvm/llvm-project/commit/f49573d1eedcf1e44893d5a062ac1b72c8419646
> > > A const + weak symbol is set to be weak_odr:
> > > https://llvm.org/docs/LangRef.html
> > > ODR is one definition rule, and given there is one constant definition
> > > constant-propagation is possible. It is possible to get this code to
> > > miscompile with LLVM when applying link time optimization. As compilers
> > > become more aggressive, this is likely to break in more instances.
> > is this just aprecaution or you actualy saw some breakage?
> We saw a breakage with clang with thinlto enabled for linking. Our
> compiler team had recently seen, and were surprised by, a similar
> issue and were able to dig out the weak ODR issue.
This is useful info, I'll add it to the commit log message.
> > > Move the definition of sample_reg_masks to the conditional part of
> > > perf_regs.h and guard usage with HAVE_PERF_REGS_SUPPORT. This avoids the
> > > weak symbol.
> > > Fix an issue when HAVE_PERF_REGS_SUPPORT isn't defined from patch v1.
> > > In v3, add perf_regs.c for architectures that HAVE_PERF_REGS_SUPPORT but
> > > don't declare sample_regs_masks.
> > looks good to me (again ;-)), let's see if it passes Arnaldo's farm
It passed a few of the usual places where things like this break, I'll
submit it to a full set of build environments soon, together with what
is sitting in acme/perf/core.
Thanks,
- Arnaldo