Re: [PATCH 1/2] Support clang for explicit_bzero
> diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c > index 87fadba81a..71a1cca3b0 100644 > --- a/lib/explicit_bzero.c > +++ b/lib/explicit_bzero.c > @@ -56,9 +56,19 @@ explicit_bzero (void *s, size_t len) >(void) memset_s (s, len, '\0', len); > #else >memset (s, '\0', len); > -# if defined __GNUC__ && !defined __clang__ > - /* Compiler barrier. */ > +# if defined __GNUC__ > +/* Compiler barrier. */ > +# if !defined __clang__ >asm volatile ("" ::: "memory"); > +# else > + /* See https://bugs.llvm.org/show_bug.cgi?id=15495#c11 > + with asm("" ::: "memory") LLVM analyzes uses of 's' > + and finds that the whole thing is dead and eliminates it. > + > + Using g workarround this problem > + */ > + __asm__ volatile("" : : "g"(s) : "memory"); > +# endif > # endif > #endif > } Thanks. I applied this with two changes: - Make it work also with clang on Windows. Recall that clang on Windows does not define __GNUC__ [1]. - Use a gnulib-style ChangeLog entry. Bruno [1] https://lists.gnu.org/archive/html/bug-gnulib/2020-08/msg00038.html
[PATCH 1/2] Support clang for explicit_bzero
From: Bastien Roucariès According to https://bugs.llvm.org/show_bug.cgi?id=15495#c11 llvm need g type constraint Signed-off-by: Bastien Roucariès --- lib/explicit_bzero.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c index 87fadba81a..71a1cca3b0 100644 --- a/lib/explicit_bzero.c +++ b/lib/explicit_bzero.c @@ -56,9 +56,19 @@ explicit_bzero (void *s, size_t len) (void) memset_s (s, len, '\0', len); #else memset (s, '\0', len); -# if defined __GNUC__ && !defined __clang__ - /* Compiler barrier. */ +# if defined __GNUC__ +/* Compiler barrier. */ +# if !defined __clang__ asm volatile ("" ::: "memory"); +# else + /* See https://bugs.llvm.org/show_bug.cgi?id=15495#c11 + with asm("" ::: "memory") LLVM analyzes uses of 's' + and finds that the whole thing is dead and eliminates it. + + Using g workarround this problem + */ + __asm__ volatile("" : : "g"(s) : "memory"); +# endif # endif #endif } -- 2.29.2
[PATCH 1/2] Support clang for explicit_bzero
From: Bastien Roucariès According to https://bugs.llvm.org/show_bug.cgi?id=15495#c11 llvm need g type constraint Signed-off-by: Bastien Roucariès --- lib/explicit_bzero.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c index 87fadba81a..71a1cca3b0 100644 --- a/lib/explicit_bzero.c +++ b/lib/explicit_bzero.c @@ -56,9 +56,19 @@ explicit_bzero (void *s, size_t len) (void) memset_s (s, len, '\0', len); #else memset (s, '\0', len); -# if defined __GNUC__ && !defined __clang__ - /* Compiler barrier. */ +# if defined __GNUC__ +/* Compiler barrier. */ +# if !defined __clang__ asm volatile ("" ::: "memory"); +# else + /* See https://bugs.llvm.org/show_bug.cgi?id=15495#c11 + with asm("" ::: "memory") LLVM analyzes uses of 's' + and finds that the whole thing is dead and eliminates it. + + Using g workarround this problem + */ + __asm__ volatile("" : : "g"(s) : "memory"); +# endif # endif #endif } -- 2.29.2