From nobody Fri Jun 12 17:19:39 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C70113F412E; Wed, 13 May 2026 15:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687426; cv=none; b=E4PveUM+Xm3UQoP2Qp8z8oxpYkXTiP6y2zmaGbLSrbrY9Hsticx+vV5WZxnj+P4neGG96uasqnbB74ecRTZUOT5IbSPpFY8xk/z9lQtd9GaJQhWC1P9jDcpewTkYZ8qPAF9xbVS3gWS+8Lx+qK2sxJ2Wp1w7RaFmv46vs+6byNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687426; c=relaxed/simple; bh=ziH4xLtifV0/DQOr7pUtbkcleeUszvi4D9h06AQrwuI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oALgbd+IdPHTb4b745Glgl7gyEiFKl1Hm9+HnLwiiLHdMoLELewFaRGs7ZGu2Kd1c8moz6kb8PDQM8S37NFZPaqIAe1twXq4e70VHuWLeUzMmz2a8EO+IEqWpN7WIxfXtvUp74UJ8sfI8Lw3OFCplE3v+3C8tCaFoG0Ya+VCxWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from Lee.localdomain (unknown [39.152.152.253]) by APP-01 (Coremail) with SMTP id qwCowACHMm6MnQRqEXQgEA--.35827S3; Wed, 13 May 2026 23:50:08 +0800 (CST) From: Li Guan To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, palmer@dabbelt.com, pjw@kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Li Guan Subject: [PATCH 1/3] perf build: Fix cross-arch build failures by isolating auxtrace objects Date: Wed, 13 May 2026 23:48:49 +0800 Message-ID: <20260513154851.1085334-2-guanli.oerv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> References: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowACHMm6MnQRqEXQgEA--.35827S3 X-Coremail-Antispam: 1UD129KBjvJXoW3GF4Duw4ktF4UXr45Gr4rKrg_yoWxZFWkpw 4kur15Zw1rGa1ay3sxZFn0gFy3twn5KFWF9F1fKw15Zr4xArWFqF4xtr1qgry7Jw1kt3yY 9F4jgrWDur4FvFJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQY14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84 ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMxCIbckI1I0E14v26r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AK xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbn2-7UUUUU== X-CM-SenderInfo: hjxd0znlorv2ny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" Currently, tools/perf/util/Build hardcodes architecture-specific hardware tracing objects (e.g., intel-pt.o, arm-spe.o, cs-etm-base.o) into the generic perf-util-y list. When compiling on architectures that lack these features (such as RISC-V), the compiler skips generating these objects, causing the linker to fail with "No such file or directory" or undefined references. Fix this by decoupling the architecture-specific hardware tracing drivers from the generic build process: 1. In Makefile.config, explicitly export CONFIG_PERF_XYZ feature flags only for their corresponding target architectures. 2. In util/Build, conditionally link these hardware tracing objects based on the newly exported feature flags. 3. In util/auxtrace.c, provide __weak stub functions returning -ENOSYS for the arch-specific processing routines. This ensures successful linking and graceful degradation when specific drivers are omitted. Signed-off-by: Li Guan --- tools/perf/Makefile.config | 21 ++++++++++++ tools/perf/util/Build | 20 +++++------ tools/perf/util/auxtrace.c | 70 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/auxtrace.h | 6 ++++ 4 files changed, 107 insertions(+), 10 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 06d7a3f999..13f4b98b2e 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -107,6 +107,27 @@ ifeq ($(SRCARCH),loongarch) endif endif =20 +ifndef NO_AUXTRACE + ifeq ($(SRCARCH),x86) + $(call detected,CONFIG_PERF_INTEL_PT) + $(call detected,CONFIG_PERF_AMD_PT) + endif + + ifeq ($(SRCARCH),arm64) + $(call detected,CONFIG_PERF_ARM_SPE) + $(call detected,CONFIG_PERF_HISI_PTT) + $(call detected,CONFIG_PERF_CS_ETM) + endif + + ifeq ($(SRCARCH),s390) + $(call detected,CONFIG_PERF_S390_CPUMSF) + endif +endif + +ifeq ($(SRCARCH),arm64) + $(call detected,CONFIG_PERF_ARM64_UNWIND_SUPPORT) +endif + ifeq ($(ARCH),s390) CFLAGS +=3D -fPIC endif diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 70cc91d008..79ade6066d 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -132,21 +132,21 @@ perf-util-$(CONFIG_LIBTRACEEVENT) +=3D kvm-stat.o perf-util-y +=3D kvm-stat-arch/ perf-util-y +=3D lock-contention.o perf-util-y +=3D auxtrace.o -perf-util-y +=3D intel-pt-decoder/ -perf-util-y +=3D intel-pt.o -perf-util-y +=3D intel-bts.o -perf-util-y +=3D arm-spe.o -perf-util-y +=3D arm-spe-decoder/ -perf-util-y +=3D hisi-ptt.o -perf-util-y +=3D hisi-ptt-decoder/ -perf-util-y +=3D s390-cpumsf.o +perf-util-$(CONFIG_PERF_INTEL_PT) +=3D intel-pt-decoder/ +perf-util-$(CONFIG_PERF_INTEL_PT) +=3D intel-pt.o +perf-util-$(CONFIG_PERF_INTEL_PT) +=3D intel-bts.o +perf-util-$(CONFIG_PERF_ARM_SPE) +=3D arm-spe.o +perf-util-$(CONFIG_PERF_ARM_SPE) +=3D arm-spe-decoder/ +perf-util-$(CONFIG_PERF_HISI_PTT) +=3D hisi-ptt.o +perf-util-$(CONFIG_PERF_HISI_PTT) +=3D hisi-ptt-decoder/ +perf-util-$(CONFIG_PERF_S390_CPUMSF) +=3D s390-cpumsf.o perf-util-y +=3D powerpc-vpadtl.o =20 ifdef CONFIG_LIBOPENCSD perf-util-y +=3D cs-etm.o perf-util-y +=3D cs-etm-decoder/ endif -perf-util-y +=3D cs-etm-base.o +perf-util-$(CONFIG_PERF_CS_ETM) +=3D cs-etm-base.o =20 perf-util-y +=3D parse-branch-options.o perf-util-y +=3D parse-regs-options.o @@ -168,7 +168,7 @@ perf-util-y +=3D clockid.o perf-util-y +=3D list_sort.o perf-util-y +=3D mutex.o perf-util-y +=3D sharded_mutex.o -perf-util-y +=3D intel-tpebs.o +perf-util-$(CONFIG_PERF_INTEL_PT) +=3D intel-tpebs.o =20 perf-util-$(CONFIG_PERF_BPF_SKEL) +=3D bpf_counter.o perf-util-$(CONFIG_PERF_BPF_SKEL) +=3D bpf_counter_cgroup.o diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index a224687ffb..f6e426c3c5 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -51,6 +51,7 @@ #include "cs-etm.h" #include "intel-pt.h" #include "intel-bts.h" +#include "intel-tpebs.h" #include "arm-spe.h" #include "hisi-ptt.h" #include "s390-cpumsf.h" @@ -2960,3 +2961,72 @@ bool auxtrace__evsel_is_auxtrace(struct perf_session= *session, =20 return session->auxtrace->evsel_is_auxtrace(session, evsel); } + +/* + * Stub functions for architecture-specific features to support cross-plat= form building. + * These weak symbols are overridden by strong symbols when the correspond= ing + * architecture-specific code is compiled in. + */ +#ifndef HAVE_ARCH_X86_64_SUPPORT +int __weak intel_pt_process_auxtrace_info(union perf_event *event __maybe_= unused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} + +int __weak intel_bts_process_auxtrace_info(union perf_event *event __maybe= _unused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} + +int __weak evsel__tpebs_open(struct evsel *evsel __maybe_unused) +{ + return -EOPNOTSUPP; +} + +void __weak evsel__tpebs_close(struct evsel *evsel __maybe_unused) +{ +} + +int __weak evsel__tpebs_read(struct evsel *evsel __maybe_unused, + int cpu_map_idx __maybe_unused, + int thread __maybe_unused) +{ + return -EOPNOTSUPP; +} + +int __weak insn_decode(void *insn __maybe_unused, const void *kaddr __mayb= e_unused, + int len __maybe_unused, int mode __maybe_unused) +{ + return -EOPNOTSUPP; +} +#endif + +#ifndef HAVE_ARCH_ARM64_SUPPORT +int __weak arm_spe_process_auxtrace_info(union perf_event *event __maybe_u= nused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} + +int __weak hisi_ptt_process_auxtrace_info(union perf_event *event __maybe_= unused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} + +int __weak cs_etm__process_auxtrace_info(union perf_event *event __maybe_u= nused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} +#endif + +#ifndef HAVE_ARCH_S390_SUPPORT +int __weak s390_cpumsf_process_auxtrace_info(union perf_event *event __may= be_unused, + struct perf_session *session __maybe_unused) +{ + return -EOPNOTSUPP; +} +#endif diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 6947f3f284..474e9445b4 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h @@ -699,4 +699,10 @@ void itrace_synth_opts__clear_time_range(struct itrace= _synth_opts *opts) opts->range_num =3D 0; } =20 +/* + * Prototypes for architecture-specific functions that require weak stubs + * to support cross-platform builds on non-x86 architectures. + */ +int insn_decode(void *insn, const void *kaddr, int len, int mode); + #endif --=20 2.54.0 From nobody Fri Jun 12 17:19:39 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2A4129D265; Wed, 13 May 2026 15:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687424; cv=none; b=kjQEnShMX8f12ucXZjkrCehX/eHjnxNxNuuhkEjdCf8eUg40IwDt4w9DsD1/LA7VgSqeG5KjPI0DbEoSHErhHyPqSmPEUfIjagHeyB0fZZMZOAU+6m0f3afCpC5YUWQ0CvLGntPG3rnIjD5Vq/wYTB+Iug01cywtEfVJkiv24dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687424; c=relaxed/simple; bh=eyA1KLhJADVxE+cMb/ou9bRwJWwO3SYP+u4TA06xkw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u2QU0lHdwD84jbaavr9w+lkHRANVHOtwnzAF25eZCcdtEB9gxRedMKMojB2CWIU1ibLM2Dted5n5xdBK3+mNkxfYRhTR2CtCrElPK8CYdOZPEytPAHS/BUPTdmNAvJOCzBQtayWapzUj3HcpzyoC7dlWUuxxGFwIj6K2CLZ6aWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from Lee.localdomain (unknown [39.152.152.253]) by APP-01 (Coremail) with SMTP id qwCowACHMm6MnQRqEXQgEA--.35827S4; Wed, 13 May 2026 23:50:11 +0800 (CST) From: Li Guan To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, palmer@dabbelt.com, pjw@kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Li Guan Subject: [PATCH 2/3] perf riscv: Fix discarded const qualifier error in _get_field() Date: Wed, 13 May 2026 23:48:50 +0800 Message-ID: <20260513154851.1085334-3-guanli.oerv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> References: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowACHMm6MnQRqEXQgEA--.35827S4 X-Coremail-Antispam: 1UD129KBjvJXoW7tryfuFy5urWUtw1DAr47urg_yoW8XFyfpr s7Cwn0qa4rurnIkr4jvrZ29FW5urs3Wa4Svrsay3yavr4YgryfJFyrtw15KF1Uur4UJws0 kr15u395Ar48Ar7anT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1l84 ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j 6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7 AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE 2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcV C2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kfnx nUUI43ZEXa7VUj5Ef7UUUUU== X-CM-SenderInfo: hjxd0znlorv2ny6l223fol2u1dvotugofq/ When building perf for the RISC-V architecture (e.g., with GCC 14), the build fails due to strict type checking on pointer assignments. The compiler flags the return value of strrchr() being assigned to a non-const pointer while processing a const string, triggering -Werror=3Ddiscarded-qualifiers: arch/riscv/util/header.c:24:15: error: assignment discards =E2=80=98con= st=E2=80=99 qualifier from pointer target type [-Werror=3Ddiscarded-qualifi= ers] 24 | line2 =3D strrchr(line, ' '); | ^ arch/riscv/util/header.c:29:12: error: assignment discards =E2=80=98con= st=E2=80=99 qualifier from pointer target type [-Werror=3Ddiscarded-qualifi= ers] 29 | nl =3D strrchr(line, '\n'); | ^ Resolve this by adding an explicit (char *) cast to the strrchr() return values, which satisfies the compiler's qualifier checks without altering the runtime behavior. Signed-off-by: Li Guan --- tools/perf/arch/riscv/util/header.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/riscv/util/header.c b/tools/perf/arch/riscv/ut= il/header.c index 4b839203d4..d01ba64aec 100644 --- a/tools/perf/arch/riscv/util/header.c +++ b/tools/perf/arch/riscv/util/header.c @@ -21,12 +21,12 @@ static char *_get_field(const char *line) { char *line2, *nl; =20 - line2 =3D strrchr(line, ' '); + line2 =3D (char *)strrchr(line, ' '); if (!line2) return NULL; =20 line2++; - nl =3D strrchr(line, '\n'); + nl =3D (char *)strrchr(line, '\n'); if (!nl) return NULL; =20 --=20 2.54.0 From nobody Fri Jun 12 17:19:39 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1E7B401493; Wed, 13 May 2026 15:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687425; cv=none; b=ChoU5AAcbNTUv0YVeg7OA+PwzROhoO4lsM9GzpIO01A6OzAvEd2T5mCgh47juOW1oBtn/zaLqeoxL+adgEhAtnfbBOtr0uJjTU8f9ymwu0KzCxGn5BY8notMKGvywZeUXPaeJlxVaEN4YX5ipRC4JB2rjWyyg/qH7l8DsHfQM3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778687425; c=relaxed/simple; bh=AfI9pfMVssm/KgEkahsqPoEM0bifhlJN582tQcirdRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdkipUjI/s2mATJ82so8cPYGPQ6V8Cgt6NTmiteOMJrLHJgUXrjcZtE9DnG6txn0bL1dtuct/BWq1zZAUT2pRrV8Son1bqqkloQlGgXLlFxuRwlQjGWJWnIVYp/8ojc2t5rWu4pt+H9cG2mnQOCoJu5F/ob18f5urSfRiK8THeM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from Lee.localdomain (unknown [39.152.152.253]) by APP-01 (Coremail) with SMTP id qwCowACHMm6MnQRqEXQgEA--.35827S5; Wed, 13 May 2026 23:50:11 +0800 (CST) From: Li Guan To: acme@kernel.org, namhyung@kernel.org Cc: irogers@google.com, adrian.hunter@intel.com, palmer@dabbelt.com, pjw@kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Li Guan Subject: [PATCH 3/3] perf script: Provide weak stubs for instruction decoding Date: Wed, 13 May 2026 23:48:51 +0800 Message-ID: <20260513154851.1085334-4-guanli.oerv@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> References: <20260513154851.1085334-1-guanli.oerv@isrc.iscas.ac.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowACHMm6MnQRqEXQgEA--.35827S5 X-Coremail-Antispam: 1UD129KBjvJXoW7tr48JF4DZF13uFy5Wr47XFb_yoW8XF4kp3 9ru3y5Zr1UXF4avw1fG3ZYqr1a9r9aqF1SgFyIk39rWr43Jw1xtry2kF9Ygr17Ar48JryU AF129FZ5WryrAFJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r4UJwAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVj vjDU0xZFpf9x0JUHWlkUUUUU= X-CM-SenderInfo: hjxd0znlorv2ny6l223fol2u1dvotugofq/ Content-Type: text/plain; charset="utf-8" When cross-compiling perf for architectures that do not yet implement hardware-specific instruction decoding (such as RISC-V and ARM64), the linker fails with undefined references to `dump_insn` and `arch_is_uncond_branch` in builtin-script.c. Provide global __weak stubs for these functions to ensure successful linking across all architectures. Architectures that support these features will automatically override these weak symbols. Signed-off-by: Li Guan --- tools/perf/builtin-script.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index c8ac9f01a3..80a8f0e80b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -4608,3 +4608,25 @@ int cmd_script(int argc, const char **argv) out: return err; } + +/* + * Provide weak stubs for architectures that have not yet implemented + * instruction decoding. This prevents linker errors (undefined + * references) on non-x86 architectures (like ARM64, RISC-V) when + * building perf script. + */ +const char * __weak dump_insn(struct perf_insn *x __maybe_unused, + u64 ip __maybe_unused, + u8 *inbuf __maybe_unused, + int inlen __maybe_unused, + int *lenp __maybe_unused) +{ + return NULL; +} + +int __weak arch_is_uncond_branch(const unsigned char *buf __maybe_unused, + size_t len __maybe_unused, + int x86_64 __maybe_unused) +{ + return 0; +} --=20 2.54.0