public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guilherme Amadio <amadio@gentoo.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	amadio@ghostprotocols.net, Namhyung Kim <namhyung@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: perf tools: Options being passed to clang when building the BPF part of skels
Date: Tue, 22 Aug 2023 20:58:09 +0200	[thread overview]
Message-ID: <ZOUFQc-IIw3kbHsY@gentoo.org> (raw)
In-Reply-To: <ZOSrDGujou8WwS5r@kernel.org>

Hi Arnaldo,

On Tue, Aug 22, 2023 at 09:33:16AM -0300, Arnaldo Carvalho de Melo wrote:
> Hi,
> 
> 	On gentoo I'm noticing this:
> 
> clang-16clang-16: : clang-16error: : error: clang-16clang-16: clang-16clang-16clang-16: clang-16error: clang-16: : ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]: : : clang-16error: ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]error: error: : 
> error: 
> error: error: error: ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]error: ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]
> 
> ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]
> 
> ignoring '-fstack-protector-strong' option as it is not currently supported for target 'bpf' [-Werror,-Woption-ignored]
> 
> And while just doing:
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index a5dd1ba..7726b57 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -1101,7 +1101,7 @@ else
>  endif
>  
>  $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
> -	$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf -Wall -Werror $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
> +	$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf -Wall -Werror -Wno-option-ignored $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
>  	  -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
>  
>  $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
> 
> 
> "Fixes" it, I'm curious as where is that we're setting up the options
> that are being passed to clang at:
> 
> tools/perf/Makefile.perf
> 
> $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
>         $(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf -Wall -Werror $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
>           -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
> 
> Perhaps it is plain just using CFLAGS? I.e. maybe the native build
> CFLAGS is being passed to the BPF target clang calls?
> 
> Ideas?

In the patches I sent previously, I had a commit to address this. In
summary, the extra flags you see are hardening flags added by default.
Have also a look at /usr/include/gentoo/fortify.h. I suppose other 
distributions may add such flags as well. It's a pity the hardening
flags are added indiscriminately to all target architectures, but just
making the compiler not error out should be enough to work around the
issue. In my patch, I put -Werror under the control of the WERROR build
option and disabled it when configuring perf in the ebuild. Since other
warnings may be triggered in the future, having an easy way to disable
-Werror when building the package would be nice to have, otherwise when
a new compiler comes out users may hit build failures, since we are a
source based distribution.

Best regards,
-Guilherme




  reply	other threads:[~2023-08-22 18:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 12:33 perf tools: Options being passed to clang when building the BPF part of skels Arnaldo Carvalho de Melo
2023-08-22 18:58 ` Guilherme Amadio [this message]
2023-08-22 19:43   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOUFQc-IIw3kbHsY@gentoo.org \
    --to=amadio@gentoo.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=amadio@ghostprotocols.net \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox