Re: [PATCH RFC v2 02/25] stackdepot: prevent Clang from optimizing away stackdepot_memcmp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 7, 2019 at 11:19 AM Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> wrote:
>
>
>
> On 11/7/19 1:00 PM, Arnd Bergmann wrote:
> > On Thu, Nov 7, 2019 at 10:46 AM Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> wrote:
> >> On 11/7/19 12:22 PM, Alexander Potapenko wrote:
> >>> On Thu, Nov 7, 2019 at 10:04 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:
> >>>> On Thu, Nov 7, 2019 at 7:08 AM Sergey Senozhatsky
> >>>> <sergey.senozhatsky.work@xxxxxxxxx> wrote:
> >>>> The normal way to do a volatile access would be
> >>>> READ_ONCE()/WRITE_ONCE(), but that seems stronger than
> >>>> the barrier() here. I'd just stick to adding a barrier.
> >>> I actually like the READ_ONCE idea more, as READ_ONCE is really a
> >>> documented way to prevent the compiler from merging reads, which is
> >>> what we want here.
> >>
> >> I would rather go with -fno-builtin-bcmp or maybe even -fno-builtin if that works.
> >
> > The commit message for 5f074f3e192f ("lib/string.c: implement a basic bcmp")
> > mentions that  -fno-builtin-bcmp did not work for LTO when the global bcmp()
> > help was added. I don't know whether the same applies here, but my guess is
> > that it's the same issue.
>
> But we don't do LTO.
I don't think not doing LTO now is a valid argument, as some
distributions may start doing LTO in the future.
(Android already does LTO, by the way)

Regarding this particular case, -fno-builtin-bcmp is insufficient, as
Clang falls back to memcmp() in that case.
Building with -fno-builtin-bcmp -fno-builtin-memcmp does the trick,
but we'd probably better use -fno-builtin just to avoid future
surprises.
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@xxxxxxxxxxxxxxxx.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/6875c6e6-2f1f-f8e6-e5d7-d451c48397ff%40virtuozzo.com.



-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux