From nobody Thu Feb 12 06:36:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5328BEEAA79 for ; Thu, 14 Sep 2023 21:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbjINVUI (ORCPT ); Thu, 14 Sep 2023 17:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjINVUG (ORCPT ); Thu, 14 Sep 2023 17:20:06 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73C5326BB for ; Thu, 14 Sep 2023 14:20:02 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58cbf62bae8so18402917b3.3 for ; Thu, 14 Sep 2023 14:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694726401; x=1695331201; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=lStqQ9ffAu7tg36ET64D7TH2ZuxYOmdso1Dvk1E923U=; b=d0P9v8k9xEQq0Y9Zk/n8QCyBeDjPxurfah7KIkUmoZDlDtR0M+i/9gF+77SmhBMRDw vDKBPZ+hLEIHLE/YUpqJZtY7hMPJdpulb1cchs6lMMQaP8Alc9H9+7mj1dDaSNfw5JjX bk3doarLS6CsmdvANDoxwqU7yAaAFu/AKaGe/5ZiLEV6tNVtMzlcOUpi+szYuiU2KICY YKUO6Uurhrz/bT1HfWM1Cuv3CHs6vL9mqRZqnTknPQzrEpI0bwjAmfj6G8OmIsfThEa3 WL6NVg9EzY1DdVFocj0ZTktJ2JrBHnZDQbxfYcoqiky6y/lofFgJ8pfG6Kpluln3AXwg wJ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694726401; x=1695331201; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lStqQ9ffAu7tg36ET64D7TH2ZuxYOmdso1Dvk1E923U=; b=f5wsmcAtABejQBzJWOcTxD2o52zm+/KFEMwz3vd01jLVhqmyp6xZHPRHuOJka5hAmJ gyyrIqqbp5bjaXUfmX+pQ0KDO5ue9Ts6Qv8Opdahq7mV5rEH2h0i9zORA5Y96Lssob5j 1EMeYKZG/SXjwCgM82mDZcnmA31KvivyZ1/yTR8MIVDC5DpmPy/Md/Kb/nuTKnybtXdA CVUoWjf47UEfjoYf5xoNbHKY/yejiFLSZImKAbOeNRxkDtM2urTer5XP/yl6+5jBZ3ui nR9G0Gy7bAWk+7iwMO6rEQtc+TtSg6Q3EN1oEyatr9Y6iWZPalsNdpq7AW4adLU619C3 OP+A== X-Gm-Message-State: AOJu0Yx+1sajavrE5OMgkVarxiRJgeMOActBg1a+JxsdScp3ipuzuTLQ mgySxYNNGAmoUcmtSqZlbWezpY+uDnLO X-Google-Smtp-Source: AGHT+IFjRA5JUeGKSzOoa0TZAwd/2W6FhxzDTZAadOlCrpO4Vx/AQT0GBgpQR7QF6AbHQOEP6z9/0YF3A9DO X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:5357:1d03:3084:aacb]) (user=irogers job=sendgmr) by 2002:a25:ad87:0:b0:d80:eb4:9ca with SMTP id z7-20020a25ad87000000b00d800eb409camr162274ybi.0.1694726401718; Thu, 14 Sep 2023 14:20:01 -0700 (PDT) Date: Thu, 14 Sep 2023 14:19:45 -0700 In-Reply-To: <20230914211948.814999-1-irogers@google.com> Message-Id: <20230914211948.814999-3-irogers@google.com> Mime-Version: 1.0 References: <20230914211948.814999-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Subject: [PATCH v1 2/5] perf build: Default BUILD_BPF_SKEL, warn/disable for missing deps From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nick Terrell , Nathan Chancellor , Nick Desaulniers , Tom Rix , Andrii Nakryiko , Tiezhu Yang , James Clark , Kajol Jain , Patrice Duroux , Athira Rajeev , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" LIBBPF is dependent on zlib so move the NO_ZLIB and feature check early to avoid statically building when zlib is disabled. This avoids a linkage failure with perf and static libbpf when zlib isn't specified. Move BUILD_BPF_SKEL logic to one place and if not defined set BUILD_BPF_SKEL to 1. Detect dependencies of building with BPF skeletons and warn/disable if the dependencies aren't present. Change Makefile.perf to contain BPF skeleton logic dependent on the Makefile.config result and refresh the comment about BUILD_BPF_SKEL. Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 78 ++++++++++++++++++++++++-------------- tools/perf/Makefile.perf | 8 ++-- 2 files changed, 53 insertions(+), 33 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index d66b52407e19..f5ccbfc1a444 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -216,12 +216,6 @@ ifeq ($(call get-executable,$(BISON)),) dummy :=3D $(error Error: $(BISON) is missing on this system, please ins= tall it) endif =20 -ifeq ($(BUILD_BPF_SKEL),1) - ifeq ($(call get-executable,$(CLANG)),) - dummy :=3D $(error $(CLANG) is missing on this system, please install = it to be able to build with BUILD_BPF_SKEL=3D1) - endif -endif - ifneq ($(OUTPUT),) ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.= \+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\=3D 371), 1) BISON_FILE_PREFIX_MAP :=3D --file-prefix-map=3D$(OUTPUT)=3D @@ -530,6 +524,16 @@ ifdef CORESIGHT endif endif =20 +ifndef NO_ZLIB + ifeq ($(feature-zlib), 1) + CFLAGS +=3D -DHAVE_ZLIB_SUPPORT + EXTLIBS +=3D -lz + $(call detected,CONFIG_ZLIB) + else + NO_ZLIB :=3D 1 + endif +endif + ifndef NO_LIBELF CFLAGS +=3D -DHAVE_LIBELF_SUPPORT EXTLIBS +=3D -lelf @@ -571,22 +575,28 @@ ifndef NO_LIBELF =20 ifndef NO_LIBBPF ifeq ($(feature-bpf), 1) - CFLAGS +=3D -DHAVE_LIBBPF_SUPPORT - $(call detected,CONFIG_LIBBPF) - # detecting libbpf without LIBBPF_DYNAMIC, so make VF=3D1 shows libb= pf detection status $(call feature_check,libbpf) =20 ifdef LIBBPF_DYNAMIC ifeq ($(feature-libbpf), 1) EXTLIBS +=3D -lbpf + CFLAGS +=3D -DHAVE_LIBBPF_SUPPORT + $(call detected,CONFIG_LIBBPF) $(call detected,CONFIG_LIBBPF_DYNAMIC) else dummy :=3D $(error Error: No libbpf devel library found or older= than v1.0, please install/update libbpf-devel); endif else - # Libbpf will be built as a static library from tools/lib/bpf. - LIBBPF_STATIC :=3D 1 + ifeq ($(NO_ZLIB), 1) + dummy :=3D $(warning Warning: Statically building libbpf not pos= sible as zlib is missing) + NO_LIBBPF :=3D 1 + else + # Libbpf will be built as a static library from tools/lib/bpf. + LIBBPF_STATIC :=3D 1 + $(call detected,CONFIG_LIBBPF) + CFLAGS +=3D -DHAVE_LIBBPF_SUPPORT + endif endif endif endif # NO_LIBBPF @@ -663,16 +673,36 @@ ifndef NO_LIBBPF endif endif =20 -ifdef BUILD_BPF_SKEL - $(call feature_check,clang-bpf-co-re) - ifeq ($(feature-clang-bpf-co-re), 0) - dummy :=3D $(error Error: clang too old/not installed. Please install = recent clang to build with BUILD_BPF_SKEL) - endif +ifndef BUILD_BPF_SKEL + # BPF skeletons control a large number of perf features, by default + # they are enabled. + BUILD_BPF_SKEL :=3D 1 +endif + +ifeq ($(BUILD_BPF_SKEL),1) ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),) - dummy :=3D $(error Error: BPF skeleton support requires libbpf) + dummy :=3D $(warning Warning: Disabled BPF skeletons as libbpf is requ= ired) + BUILD_BPF_SKEL :=3D 0 + else ifeq ($(filter -DHAVE_LIBELF_SUPPORT, $(CFLAGS)),) + dummy :=3D $(warning Warning: Disabled BPF skeletons as libelf is requ= ired by bpftool) + BUILD_BPF_SKEL :=3D 0 + else ifeq ($(filter -DHAVE_ZLIB_SUPPORT, $(CFLAGS)),) + dummy :=3D $(warning Warning: Disabled BPF skeletons as zlib is requir= ed by bpftool) + BUILD_BPF_SKEL :=3D 0 + else ifeq ($(call get-executable,$(CLANG)),) + dummy :=3D $(warning Warning: Disabled BPF skeletons as clang ($(CLANG= )) is missing) + BUILD_BPF_SKEL :=3D 0 + else + $(call feature_check,clang-bpf-co-re) + ifeq ($(feature-clang-bpf-co-re), 0) + dummy :=3D $(warning Warning: Disabled BPF skeletons as clang is too= old) + BUILD_BPF_SKEL :=3D 0 + endif + endif + ifeq ($(BUILD_BPF_SKEL),1) + $(call detected,CONFIG_PERF_BPF_SKEL) + CFLAGS +=3D -DHAVE_BPF_SKEL endif - $(call detected,CONFIG_PERF_BPF_SKEL) - CFLAGS +=3D -DHAVE_BPF_SKEL endif =20 ifndef GEN_VMLINUX_H @@ -946,16 +976,6 @@ ifndef NO_DEMANGLE endif endif =20 -ifndef NO_ZLIB - ifeq ($(feature-zlib), 1) - CFLAGS +=3D -DHAVE_ZLIB_SUPPORT - EXTLIBS +=3D -lz - $(call detected,CONFIG_ZLIB) - else - NO_ZLIB :=3D 1 - endif -endif - ifndef NO_LZMA ifeq ($(feature-lzma), 1) CFLAGS +=3D -DHAVE_LZMA_SUPPORT diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 8d0f6d2bbc7a..98604e396ac3 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -120,7 +120,7 @@ include ../scripts/utilities.mak # # Define NO_LIBDEBUGINFOD if you do not want support debuginfod # -# Define BUILD_BPF_SKEL to enable BPF skeletons +# Set BUILD_BPF_SKEL to 0 to override BUILD_BPF_SKEL and not build BPF ske= letons # # Define BUILD_NONDISTRO to enable building an linking against libbfd and # libiberty distribution license incompatible libraries. @@ -1042,7 +1042,7 @@ SKELETONS +=3D $(SKEL_OUT)/augmented_raw_syscalls.ske= l.h $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBS= UBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ =20 -ifdef BUILD_BPF_SKEL +ifeq ($(CONFIG_PERF_BPF_SKEL),y) BPFTOOL :=3D $(SKEL_TMP_OUT)/bootstrap/bpftool # Get Clang's default includes on this system, as opposed to those seen by # '--target=3Dbpf'. This fixes "missing" files on some architectures/distr= os, @@ -1120,11 +1120,11 @@ bpf-skel: $(SKELETONS) =20 .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o =20 -else # BUILD_BPF_SKEL +else # CONFIG_PERF_BPF_SKEL =20 bpf-skel: =20 -endif # BUILD_BPF_SKEL +endif # CONFIG_PERF_BPF_SKEL =20 bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) --=20 2.42.0.459.ge4e396fd5e-goog