lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 Apr 2022 11:47:13 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Nathan Chancellor <nathan@...nel.org>
Cc:     Sedat Dilek <sedat.dilek@...il.com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Fangrui Song <maskray@...gle.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Ian Rogers <irogers@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
        John Keeping <john@...anate.com>, Leo Yan <leo.yan@...aro.org>,
        Michael Petlan <mpetlan@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: Build perf with clang, failure with libperf

Em Mon, Apr 04, 2022 at 02:53:24PM -0700, Nathan Chancellor escreveu:
> On Mon, Apr 04, 2022 at 05:43:11PM -0300, Arnaldo Carvalho de Melo wrote:
> > 	Trying to apply Sedat's patch something changed in my system,
> > and that patch wasn't enough, so I had to first apply this one:

<SNIP>

> > diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> > index 1480910c792e2cb3..90774b60d31b2b8e 100644
> > --- a/tools/build/feature/Makefile
> > +++ b/tools/build/feature/Makefile
> > @@ -217,7 +217,7 @@ strip-libs = $(filter-out -l%,$(1))
> >  PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
> >  PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
> >  PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
> > -PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
> > +PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
> >  FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
> >  
> >  $(OUTPUT)test-libperl.bin:
> > 
> > ----------------------------------------------------- 8< -------------------

<SNIP>

> > So perhaps in this case its better to disable that
> > -Werror,-Wcompound-token-split-by-macro when building with clang?
 
> Yes, I think that is probably the best solution. As far as I can tell,
> at least in this file and context, the warning appears harmless, as the
> "create a GNU C statement expression from two different macros" is very
> much intentional, based on the presence of PERL_USE_GCC_BRACE_GROUPS.
> The warning is fixed in upstream Perl by just avoiding creating GNU C
> statement expressions using STMT_START and STMT_END:
 
> https://github.com/Perl/perl5/issues/18780
> https://github.com/Perl/perl5/pull/18984
> 
> If I am reading the source code correctly, an alternative to disabling
> the warning would be specifying -DPERL_GCC_BRACE_GROUPS_FORBIDDEN but it
> seems like that might end up impacting more than just this site,
> according to the issue discussion above.

Ok, so I ended up with the patch below.

On the 5.19 window I'll make the tools/perf/Makefile.config filters only
apply when clang is used and unify these settings so that we have it
setup just in one place, shared by the main build and the feature build.

- Arnaldo

commit 5b5da660aa70e2a01748f602e9bbcd18b162a176
Author: Arnaldo Carvalho de Melo <acme@...hat.com>
Date:   Tue Apr 5 10:33:21 2022 -0300

    tools build: Filter out options and warnings not supported by clang
    
    These make the feature check fail when using clang, so remove them just
    like is done in tools/perf/Makefile.config to build perf itself.
    
    Adding -Wno-compound-token-split-by-macro to tools/perf/Makefile.config
    when building with clang is also necessary to avoid these warnings
    turned into errors (-Werror):
    
        CC      /tmp/build/perf/util/scripting-engines/trace-event-perl.o
      In file included from util/scripting-engines/trace-event-perl.c:35:
      In file included from /usr/lib64/perl5/CORE/perl.h:4085:
      In file included from /usr/lib64/perl5/CORE/hv.h:659:
      In file included from /usr/lib64/perl5/CORE/hv_func.h:34:
      In file included from /usr/lib64/perl5/CORE/sbox32_hash.h:4:
      /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
          ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/lib64/perl5/CORE/zaphod32_hash.h:80:38: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
      #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                           ^~~~~~~~~~
      /usr/lib64/perl5/CORE/perl.h:737:29: note: expanded from macro 'STMT_START'
      #   define STMT_START   (void)( /* gcc supports "({ STATEMENTS; })" */
                                    ^
      /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: '{' token is here
          ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/lib64/perl5/CORE/zaphod32_hash.h:80:49: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
      #define ZAPHOD32_SCRAMBLE32(v,prime) STMT_START {  \
                                                      ^
      /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: error: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Werror,-Wcompound-token-split-by-macro]
          ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/lib64/perl5/CORE/zaphod32_hash.h:87:41: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
          v ^= (v>>23);                       \
                                              ^
      /usr/lib64/perl5/CORE/zaphod32_hash.h:150:5: note: ')' token is here
          ZAPHOD32_SCRAMBLE32(state[0],0x9fade23b);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/lib64/perl5/CORE/zaphod32_hash.h:88:3: note: expanded from macro 'ZAPHOD32_SCRAMBLE32'
      } STMT_END
        ^~~~~~~~
      /usr/lib64/perl5/CORE/perl.h:738:21: note: expanded from macro 'STMT_END'
      #   define STMT_END     )
                              ^
    
    Based-on-a-patch-by: Sedat Dilek <sedat.dilek@...il.com>
    Cc: Adrian Hunter <adrian.hunter@...el.com>
    Cc: Fangrui Song <maskray@...gle.com>
    Cc: Florian Fainelli <f.fainelli@...il.com>
    Cc: Ian Rogers <irogers@...gle.com>
    Cc: Jiri Olsa <jolsa@...nel.org>
    Cc: John Keeping <john@...anate.com>
    Cc: Leo Yan <leo.yan@...aro.org>
    Cc: Michael Petlan <mpetlan@...hat.com>
    Cc: Namhyung Kim <namhyung@...nel.org>
    Cc: Nathan Chancellor <nathan@...nel.org>
    Cc: Nick Desaulniers <ndesaulniers@...gle.com>
    Link: http://lore.kernel.org/lkml/YktYX2OnLtyobRYD@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 90774b60d31b2b8e..de66e1cc073481c5 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -220,6 +220,13 @@ PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
 PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
 FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 
+ifeq ($(CC_NO_CLANG), 0)
+  PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
+  PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
+  PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
+  FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
+endif
+
 $(OUTPUT)test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 96ad944ca6a885cd..5b5ba475a5c00c0f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -790,6 +790,9 @@ else
     LDFLAGS += $(PERL_EMBED_LDFLAGS)
     EXTLIBS += $(PERL_EMBED_LIBADD)
     CFLAGS += -DHAVE_LIBPERL_SUPPORT
+    ifeq ($(CC_NO_CLANG), 0)
+      CFLAGS += -Wno-compound-token-split-by-macro
+    endif
     $(call detected,CONFIG_LIBPERL)
   endif
 endif

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ