Currently BUILD_BUG() macro is expanded to smth like the following:
do {
extern void __compiletime_assert_0(void)
__attribute__((error("BUILD_BUG failed")));
if (!(!(1)))
__compiletime_assert_0();
} while (0);
If used in a function body this obviously would produce build errors
with -Wnested-externs and -Werror.
To enable BUILD_BUG() usage in tools/arch/x86/lib/insn.c which perf
includes in intel-pt-decoder, build perf without -Wnested-externs.
Reported-by: Stephen Rothwell <[email protected]>
Signed-off-by: Vasily Gorbik <[email protected]>
---
tools/perf/Makefile.config | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 190be4fa5c21..8137a6046a47 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
-CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
+CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
include $(srctree)/tools/scripts/Makefile.arch
--
⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
On Fri, Oct 09, 2020 at 08:47:45AM +0200, Vasily Gorbik wrote:
> Currently BUILD_BUG() macro is expanded to smth like the following:
> do {
> extern void __compiletime_assert_0(void)
> __attribute__((error("BUILD_BUG failed")));
> if (!(!(1)))
> __compiletime_assert_0();
> } while (0);
>
> If used in a function body this obviously would produce build errors
> with -Wnested-externs and -Werror.
>
> To enable BUILD_BUG() usage in tools/arch/x86/lib/insn.c which perf
> includes in intel-pt-decoder, build perf without -Wnested-externs.
>
> Reported-by: Stephen Rothwell <[email protected]>
> Signed-off-by: Vasily Gorbik <[email protected]>
> ---
> tools/perf/Makefile.config | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 190be4fa5c21..8137a6046a47 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
> detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
> detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
>
> -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
> +CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
looks good, but I can't apply the patch with 'git am'
Applying: perf build: Allow nested externs to enable BUILD_BUG() usage
error: patch failed: tools/perf/Makefile.config:16
error: tools/perf/Makefile.config: patch does not apply
Patch failed at 0001 perf build: Allow nested externs to enable BUILD_BUG() usage
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
I wonder it's that picture at the bottom ;-)
jirka
>
> include $(srctree)/tools/scripts/Makefile.arch
>
> --
> ⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
> ⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
> ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
> ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
> ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
> ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
On Fri, Oct 09, 2020 at 01:23:27PM +0200, Jiri Olsa wrote:
> On Fri, Oct 09, 2020 at 08:47:45AM +0200, Vasily Gorbik wrote:
> > Currently BUILD_BUG() macro is expanded to smth like the following:
...snip...
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 190be4fa5c21..8137a6046a47 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
> > detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)
> > detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
> >
> > -CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS)
> > +CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
>
> looks good, but I can't apply the patch with 'git am'
>
> Applying: perf build: Allow nested externs to enable BUILD_BUG() usage
> error: patch failed: tools/perf/Makefile.config:16
> error: tools/perf/Makefile.config: patch does not apply
> Patch failed at 0001 perf build: Allow nested externs to enable BUILD_BUG() usage
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
>
> I wonder it's that picture at the bottom ;-)
>
> jirka
>
>
> >
> > include $(srctree)/tools/scripts/Makefile.arch
> >
> > --
> > ⣿⣿⣿⣿⢋⡀⣀⠹⣿⣿⣿⣿
> > ⣿⣿⣿⣿⠠⣶⡦⠀⣿⣿⣿⣿
> > ⣿⣿⣿⠏⣴⣮⣴⣧⠈⢿⣿⣿
> > ⣿⣿⡏⢰⣿⠖⣠⣿⡆⠈⣿⣿
> > ⣿⢛⣵⣄⠙⣶⣶⡟⣅⣠⠹⣿
> > ⣿⣜⣛⠻⢎⣉⣉⣀⠿⣫⣵⣿
>
What? This makes tux and blind people very unhappy. Those are nothing
else but braille utf-8 characters. And I've seen people on lkml are
using those, i.e. debian icon in a signature. Oh, well... I'll avoid
using this signature in future.
BTW which branch did you try to apply it on? I've just checked perf/core
and there should be no conflicts as well. But I assume this should go
via objtool together with other changes which introduced that BUILD_BUG()
usage.
Anyhow I've resent the patch without fancy signatures included.