* [PATCH v3 0/9] perf build: Support building with Clang
@ 2025-10-06 16:21 Leo Yan
2025-10-06 16:21 ` [PATCH v3 1/9] tools build: Align warning options with perf Leo Yan
` (12 more replies)
0 siblings, 13 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
This series adds support for building perf with Clang, following the
discussion in [1]. Because the Android NDK uses Clang by default,
enabling Clang builds naturally covers Android as well.
The series is organized as follows:
- Patches 1~2: Fix two bugs found with Clang.
- Patches 3~7: Correct CROSS_ARCH, Disable thread safety analysis for
perl header, and dismiss Clang build warnings.
- Patches 8~9: Enable Clang in the Makefile and update the
documentation.
Testing:
Tested with linux-tools-container-builds [2], which based on Arnaldo's
build test container but with several fixes for cross building with
Clang:
- All clang native builds on x86_64 have passed.
- The cross builds for arm64/mips/mips64/mipsel/riscv64 have passed.
Only a pity thing is I cannot build successfully with clang for
ubuntu:20.04-x-powerpc64el (in below log, it only builds with GCC).
The cross config does not work well on Ubuntu 20.04 due to failure
"No gnu/libc-version.h found, please install glibc-dev[el]". I confirmed
that powerpc64el cross build can make success on Ubuntu 24.04, the
failure on Ubuntu 20.04 should not be caused by perf build.
Subject: tools build test for http://localhost/perf/perf-6.17.0-rc6.tar.xz
1 201.44 alpine:3.16 : Ok gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
2 154.82 alpine:3.17 : Ok gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
3 136.07 alpine:3.18 : Ok gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924 , Alpine clang version 16.0.6 flex 2.6.4
4 150.21 alpine:3.19 : Ok gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014 , Alpine clang version 17.0.5 flex 2.6.4
5 143.50 alpine:3.20 : Ok gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309 , Alpine clang version 17.0.6 flex 2.6.4
6 146.08 amazonlinux:2023 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5) , clang version 15.0.7 (AWS 15.0.7-3.amzn2023.0.4) flex 2.6.4
7 147.19 amazonlinux:devel : Ok gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4) , clang version 15.0.6 (Amazon Linux 15.0.6-3.amzn2023.0.2) flex 2.6.4
8 117.92 debian:11 : Ok gcc (Debian 10.2.1-6) 10.2.1 20210110 , Debian clang version 13.0.1-6~deb11u1 flex 2.6.4
9 121.54 debian:12 : Ok gcc (Debian 12.2.0-14+deb12u1) 12.2.0 , Debian clang version 14.0.6 flex 2.6.4
10 128.64 debian:experimental : Ok gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
11 96.47 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
12 72.89 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
13 73.31 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
14 71.69 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
15 151.92 fedora:35 : Ok gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-3) , clang version 13.0.1 (Fedora 13.0.1-1.fc35) flex 2.6.4
16 146.99 fedora:36 : Ok gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) , clang version 14.0.5 (Fedora 14.0.5-2.fc36) flex 2.6.4
17 139.58 fedora:37 : Ok gcc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1) , clang version 15.0.7 (Fedora 15.0.7-2.fc37) flex 2.6.4
18 142.00 fedora:38 : Ok gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7) , clang version 16.0.6 (Fedora 16.0.6-4.fc38) flex 2.6.4
19 140.18 fedora:39 : Ok gcc (GCC) 13.3.1 20240913 (Red Hat 13.3.1-3) , clang version 17.0.6 (Fedora 17.0.6-2.fc39) flex 2.6.4
20 139.38 fedora:40 : Ok gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) , clang version 18.1.8 (Fedora 18.1.8-2.fc40) flex 2.6.4
21 136.26 fedora:41 : Ok gcc (GCC) 14.3.1 20250808 (Red Hat 14.3.1-3) , clang version 19.1.7 (Fedora 19.1.7-5.fc41) flex 2.6.4
22 135.38 fedora:42 : Ok gcc (GCC) 15.2.1 20250808 (Red Hat 15.2.1-1) , clang version 20.1.8 (Fedora 20.1.8-4.fc42) flex 2.6.4
23 127.55 fedora:rawhide : Ok gcc (GCC) 15.2.1 20250924 (Red Hat 15.2.1-2) , clang version 21.1.2 (Fedora 21.1.2-1.fc44) flex 2.6.4
24 180.17 opensuse:15.4 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
25 169.40 opensuse:15.5 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
26 167.36 opensuse:15.6 : Ok gcc (SUSE Linux) 7.5.0 , clang version 17.0.6 flex 2.6.4
27 154.82 opensuse:tumbleweed : Ok gcc (SUSE Linux) 15.2.0 , clang version 21.1.2 flex 2.6.4
28 145.89 oraclelinux:8 : Ok gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-28.0.1) , clang version 19.1.7 ( 19.1.7-2.module+el8.10.0+90583+7e562d96) flex 2.6.1
29 139.68 oraclelinux:9 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5.0.1) , clang version 19.1.7 ( 19.1.7-2.el9) flex 2.6.4
30 40.17 ubuntu:20.04 : Ok gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 flex 2.6.4
31 20.83 ubuntu:20.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0 flex 2.6.4
32 127.75 ubuntu:22.04 : Ok gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
33 92.25 ubuntu:22.04-x-riscv64 : Ok riscv64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
34 126.64 ubuntu:24.04 : Ok gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 , Ubuntu clang version 18.1.3 (1ubuntu1) flex 2.6.4
35 130.95 ubuntu:25.04 : Ok gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0 , Ubuntu clang version 20.1.2 (0ubuntu1) flex 2.6.4
[1] https://lore.kernel.org/linux-perf-users/20240715143342.52236-1-leo.yan@arm.com/
[2] https://github.com/Leo-Yan/linux-tools-container-builds/tree/fix-riscv64-cross-build
---
Changes in v3:
- Fixed build failure with musl lib.
- Disabled thread safety analysis for perl head.
- Link to v2: https://lore.kernel.org/r/20250930-perf_build_android_ndk-v2-0-2ea440b7ef01@arm.com
Changes in v2:
- Dropped the patch for dismissing warning in bpftool.
- Refined the document. (Ian)
- Link to v1: https://lore.kernel.org/r/20250925-perf_build_android_ndk-v1-0-8b35aadde3dc@arm.com
---
Leo Yan (9):
tools build: Align warning options with perf
perf python: split Clang options when invoking Popen
perf build: Correct CROSS_ARCH for clang
perf build: Disable thread safety analysis for perl header
perf test coresight: Dismiss clang warning for memcpy thread
perf test coresight: Dismiss clang warning for thread loop
perf test coresight: Dismiss clang warning for unroll loop thread
perf build: Support build with clang
perf docs: Document building with Clang
tools/build/feature/Makefile | 6 +-
tools/perf/Documentation/Build.txt | 15 ++++
tools/perf/Documentation/android.txt | 80 ++--------------------
tools/perf/Makefile.config | 33 ++++++++-
tools/perf/Makefile.perf | 2 +-
tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
.../shell/coresight/memcpy_thread/memcpy_thread.c | 2 +
.../shell/coresight/thread_loop/thread_loop.c | 4 +-
.../unroll_loop_thread/unroll_loop_thread.c | 4 +-
tools/perf/util/scripting-engines/Build | 2 +-
tools/perf/util/setup.py | 5 +-
11 files changed, 70 insertions(+), 85 deletions(-)
---
base-commit: c17dda8013495d8132c976cbf349be9949d0fbd1
change-id: 20250915-perf_build_android_ndk-500b53bea895
Best regards,
--
Leo Yan <leo.yan@arm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/9] tools build: Align warning options with perf
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 2/9] perf python: split Clang options when invoking Popen Leo Yan
` (11 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
The feature test programs are built without enabling '-Wall -Werror'
options. As a result, a feature may appear to be available, but later
building in perf can fail with stricter checks.
Make the feature test program use the same warning options as perf.
Fixes: 1925459b4d92 ("tools build: Fix feature Makefile issues with 'O='")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/build/feature/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b41a42818d8ac232ade78ecb41363d26ce2a9471..bd615a708a0aa89ddbe87401f04bd736e384a9c4 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -316,10 +316,10 @@ $(OUTPUT)test-libcapstone.bin:
$(BUILD) # -lcapstone provided by $(FEATURE_CHECK_LDFLAGS-libcapstone)
$(OUTPUT)test-compile-32.bin:
- $(CC) -m32 -o $@ test-compile.c
+ $(CC) -m32 -Wall -Werror -o $@ test-compile.c
$(OUTPUT)test-compile-x32.bin:
- $(CC) -mx32 -o $@ test-compile.c
+ $(CC) -mx32 -Wall -Werror -o $@ test-compile.c
$(OUTPUT)test-zlib.bin:
$(BUILD) -lz
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/9] perf python: split Clang options when invoking Popen
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
2025-10-06 16:21 ` [PATCH v3 1/9] tools build: Align warning options with perf Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 3/9] perf build: Correct CROSS_ARCH for clang Leo Yan
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
When passing a list to subprocess.Popen, each element maps to one argv
token. Current code bundles multiple Clang flags into a single element,
something like:
cmd = ['clang',
'--target=x86_64-linux-gnu -fintegrated-as -Wno-cast-function-type-mismatch',
'test-hello.c']
So Clang only sees one long, invalid option instead of separate flags,
as a result, the script cannot capture any log via PIPE.
Fix this by using shlex.split() to separate the string so each option
becomes its own argv element. The fixed list will be:
cmd = ['clang',
'--target=x86_64-linux-gnu',
'-fintegrated-as',
'-Wno-cast-function-type-mismatch',
'test-hello.c']
Fixes: 09e6f9f98370 ("perf python: Fix splitting CC into compiler and options")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/util/setup.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index dd289d15acfd62ff058bbaed7e565bb958e3a3c8..9cae2c472f4ad4d9579e8528b8bb0152df6fe20e 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -1,6 +1,7 @@
from os import getenv, path
from subprocess import Popen, PIPE
from re import sub
+import shlex
cc = getenv("CC")
assert cc, "Environment variable CC not set"
@@ -22,7 +23,9 @@ assert srctree, "Environment variable srctree, for the Linux sources, not set"
src_feature_tests = f'{srctree}/tools/build/feature'
def clang_has_option(option):
- cc_output = Popen([cc, cc_options + option, path.join(src_feature_tests, "test-hello.c") ], stderr=PIPE).stderr.readlines()
+ cmd = shlex.split(f"{cc} {cc_options} {option}")
+ cmd.append(path.join(src_feature_tests, "test-hello.c"))
+ cc_output = Popen(cmd, stderr=PIPE).stderr.readlines()
return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o) or (b"unknown warning option" in o))] == [ ]
if cc_is_clang:
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 3/9] perf build: Correct CROSS_ARCH for clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
2025-10-06 16:21 ` [PATCH v3 1/9] tools build: Align warning options with perf Leo Yan
2025-10-06 16:21 ` [PATCH v3 2/9] perf python: split Clang options when invoking Popen Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header Leo Yan
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
Clang's -dumpmachine outputs "aarch64-unknown-linux-gnu", which does not
match the MultiArch convention. This prevents the build system from
detecting installed packages.
Fix by stripping the trailing '-' from CROSS_COMPILE when setting
CROSS_ARCH.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/build/feature/Makefile | 2 +-
tools/perf/Makefile.perf | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index bd615a708a0aa89ddbe87401f04bd736e384a9c4..214ccaee69181cce1f8e736b85c8dc940efa6c19 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -94,7 +94,7 @@ else
# paths are used instead.
ifdef CROSS_COMPILE
ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
- CROSS_ARCH = $(shell $(CC) -dumpmachine)
+ CROSS_ARCH = $(notdir $(CROSS_COMPILE:%-=%))
PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e2150acc2c13325f93a2d5cd4a60b4a6bfeedc94..47bc9d8a91df90535408c427909bcb3f7cd50970 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -194,7 +194,7 @@ else
# paths are used instead.
ifdef CROSS_COMPILE
ifeq ($(PKG_CONFIG_LIBDIR)$(PKG_CONFIG_PATH)$(PKG_CONFIG_SYSROOT_DIR),)
- CROSS_ARCH = $(shell $(CC) -dumpmachine)
+ CROSS_ARCH = $(notdir $(CROSS_COMPILE:%-=%))
PKG_CONFIG_LIBDIR := /usr/local/$(CROSS_ARCH)/lib/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/local/lib/$(CROSS_ARCH)/pkgconfig/
PKG_CONFIG_LIBDIR := $(PKG_CONFIG_LIBDIR):/usr/lib/$(CROSS_ARCH)/pkgconfig/
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (2 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 3/9] perf build: Correct CROSS_ARCH for clang Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 17:56 ` Ian Rogers
2025-10-06 16:21 ` [PATCH v3 5/9] perf test coresight: Dismiss clang warning for memcpy thread Leo Yan
` (8 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
When build with perl5, it reports error:
In file included from /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7933:
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/inline.h:298:5: error:
mutex 'PL_env_mutex.lock' is not held on every path through
here [-Werror,-Wthread-safety-analysis]
298 | ENV_UNLOCK;
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7091:31: note:
expanded from macro 'ENV_UNLOCK'
7091 | # define ENV_UNLOCK PERL_REENTRANT_UNLOCK("env"...
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:6465:7: note:
expanded from macro 'PERL_REENTRANT_UNLOCK'
6465 | } STMT_END
| ^
/usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:865:28: note:
expanded from macro 'STMT_END'
865 | # define STMT_END while (0)
| ^
The error is caused by perl header but not perf code, disable thread
safety analysis if including the header.
Though GCC does not support the thread safety analysis option, this
negative warning flag is silently ignored by it.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
tools/perf/util/scripting-engines/Build | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Build b/tools/perf/scripts/perl/Perf-Trace-Util/Build
index 9b0e5a8b5070f1a1640518fae75557f824ef21ee..01a1a0ed51aefd721b4bc7eba728c29a8ffcd551 100644
--- a/tools/perf/scripts/perl/Perf-Trace-Util/Build
+++ b/tools/perf/scripts/perl/Perf-Trace-Util/Build
@@ -2,7 +2,7 @@ perf-util-y += Context.o
CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef
-CFLAGS_Context.o += -Wno-switch-default -Wno-shadow
+CFLAGS_Context.o += -Wno-switch-default -Wno-shadow -Wno-thread-safety-analysis
ifeq ($(CC_NO_CLANG), 1)
CFLAGS_Context.o += -Wno-unused-command-line-argument
diff --git a/tools/perf/util/scripting-engines/Build b/tools/perf/util/scripting-engines/Build
index 2282fe3772f3bdc35056cb5e66efb3462dc1c2e3..24f087b0cd11b3e06a338c394dc2c650bc2c60b1 100644
--- a/tools/perf/util/scripting-engines/Build
+++ b/tools/perf/util/scripting-engines/Build
@@ -3,7 +3,7 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y)
endif
perf-util-$(CONFIG_LIBPYTHON) += trace-event-python.o
-CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
+CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum -Wno-thread-safety-analysis
# -Wno-declaration-after-statement: The python headers have mixed code with declarations (decls after asserts, for instance)
CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-deprecated-declarations -Wno-switch-enum -Wno-declaration-after-statement
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 5/9] perf test coresight: Dismiss clang warning for memcpy thread
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (3 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 6/9] perf test coresight: Dismiss clang warning for thread loop Leo Yan
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
memcpy_thread.c:30:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
30 | }
| ^
Dismiss the warning with returning NULL from the thread function.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c b/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c
index 5f886cd09e6b3a62b5690dade94f1f8cae3279d2..7e879217be30a86431989dbf1f36d2134ef259cc 100644
--- a/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c
+++ b/tools/perf/tests/shell/coresight/memcpy_thread/memcpy_thread.c
@@ -27,6 +27,8 @@ static void *thrfn(void *arg)
}
for (i = 0; i < len; i++)
memcpy(dst, src, a->size * 1024);
+
+ return NULL;
}
static pthread_t new_thr(void *(*fn) (void *arg), void *arg)
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 6/9] perf test coresight: Dismiss clang warning for thread loop
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (4 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 5/9] perf test coresight: Dismiss clang warning for memcpy thread Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 7/9] perf test coresight: Dismiss clang warning for unroll loop thread Leo Yan
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:37:8: note: use constraint modifier "w"
37 | "add %[i], %[i], #1\n"
| ^~~~
| %w[i]
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:37:14: note: use constraint modifier "w"
37 | "add %[i], %[i], #1\n"
| ^~~~
| %w[i]
thread_loop.c:41:23: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:38:8: note: use constraint modifier "w"
38 | "cmp %[i], %[len]\n"
| ^~~~
| %w[i]
thread_loop.c:41:38: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
41 | : /* in */ [i] "r" (i), [len] "r" (len)
| ^
thread_loop.c:38:14: note: use constraint modifier "w"
38 | "cmp %[i], %[len]\n"
| ^~~~~~
| %w[len]
Use the modifier "w" for 32-bit register access.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/tests/shell/coresight/thread_loop/thread_loop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c b/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c
index e05a559253ca9d9366ad321d520349042fb07fca..86f3f548b00631682767665fc5e9d5b8551a3634 100644
--- a/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c
+++ b/tools/perf/tests/shell/coresight/thread_loop/thread_loop.c
@@ -34,8 +34,8 @@ static void *thrfn(void *arg)
}
asm volatile(
"loop:\n"
- "add %[i], %[i], #1\n"
- "cmp %[i], %[len]\n"
+ "add %w[i], %w[i], #1\n"
+ "cmp %w[i], %w[len]\n"
"blt loop\n"
: /* out */
: /* in */ [i] "r" (i), [len] "r" (len)
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 7/9] perf test coresight: Dismiss clang warning for unroll loop thread
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (5 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 6/9] perf test coresight: Dismiss clang warning for thread loop Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 8/9] perf build: Support build with clang Leo Yan
` (5 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
clang-18.1.3 on Ubuntu 24.04.2 reports warning:
unroll_loop_thread.c:35:25: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
35 | : /* in */ [in] "r" (in)
| ^
unroll_loop_thread.c:39:1: warning: non-void function does not return a value [-Wreturn-type]
39 | }
| ^
Use the modifier "w" for 32-bit register access and return NULL at the
end of thread function.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
.../tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c b/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c
index 0fc7bf1a25af3607b40f091f62176134ddb7f9f6..8f4e1c985ca38ab545a05189432a14a6d888d34c 100644
--- a/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c
+++ b/tools/perf/tests/shell/coresight/unroll_loop_thread/unroll_loop_thread.c
@@ -20,7 +20,7 @@ static void *thrfn(void *arg)
for (i = 0; i < 10000; i++) {
asm volatile (
// force an unroll of thia add instruction so we can test long runs of code
-#define SNIP1 "add %[in], %[in], #1\n"
+#define SNIP1 "add %w[in], %w[in], #1\n"
// 10
#define SNIP2 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1 SNIP1
// 100
@@ -36,6 +36,8 @@ static void *thrfn(void *arg)
: /* clobber */
);
}
+
+ return NULL;
}
static pthread_t new_thr(void *(*fn) (void *arg), void *arg)
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 8/9] perf build: Support build with clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (6 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 7/9] perf test coresight: Dismiss clang warning for unroll loop thread Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 16:21 ` [PATCH v3 9/9] perf docs: Document building with Clang Leo Yan
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
Add support for building perf with clang. For cross compilation, the
Makefile dynamically selects target flag for corresponding arch.
This patch has been verified on x86_64 machine with Ubuntu distro, it
can build successfully for native target, and for cross building Arm64
and s390.
Example: native build on x86_64 / Ubuntu machine:
$ HOSTCC=clang CC=clang CXX=clang++ make -C tools/perf
Example: cross building s390 target on x86_64 / Ubuntu machine:
# Install x390x cross toolchain and headers
$ sudo apt-get install gcc-s390x-linux-gnu g++-s390x-linux-gnu \
libc6-dev-s390x-cross linux-libc-dev-s390x-cross
# Build with clang
$ HOSTCC=clang CC=clang CXX=clang++ \
ARCH=s390 CROSS_COMPILE=s390x-linux-gnu- \
make -C tools/perf NO_LIBELF=1 NO_LIBTRACEEVENT=1 NO_LIBPYTHON=1
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/Makefile.config | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5a5832ee7b53c604ec0d90c5ca7e2bee5bfa6a17..616e71b3d897493a2b14612cdcf4a872e2296f4d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -23,8 +23,39 @@ HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
# borrowed from kernel headers depends on it, e.g. put_unaligned_*().
CFLAGS += -fno-strict-aliasing
-# Enabled Wthread-safety analysis for clang builds.
+# Set target flag and options when using clang as compiler.
ifeq ($(CC_NO_CLANG), 0)
+ CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
+ CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
+ CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu
+ CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu
+ CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu
+ CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
+ CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
+ CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
+ CLANG_TARGET_FLAGS_x86_64 := x86_64-linux-gnu
+
+ # Default to host architecture if ARCH is not explicitly given.
+ ifeq ($(ARCH), $(HOSTARCH))
+ CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple)
+ else
+ CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
+ endif
+
+ ifeq ($(CROSS_COMPILE),)
+ ifeq ($(CLANG_TARGET_FLAGS),)
+ $(error Specify CROSS_COMPILE or add CLANG_TARGET_FLAGS for $(ARCH))
+ else
+ CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
+ endif # CLANG_TARGET_FLAGS
+ else
+ CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
+ endif # CROSS_COMPILE
+
+ CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
+ CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as
+
+ # Enabled Wthread-safety analysis for clang builds.
CFLAGS += -Wthread-safety
endif
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 9/9] perf docs: Document building with Clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (7 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 8/9] perf build: Support build with clang Leo Yan
@ 2025-10-06 16:21 ` Leo Yan
2025-10-06 17:57 ` [PATCH v3 0/9] perf build: Support " Ian Rogers
` (3 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-06 16:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers, Bill Wendling,
Justin Stitt, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, James Clark
Cc: linux-kernel, linux-perf-users, llvm, linux-riscv, Leo Yan
Add example commands for building perf with Clang.
Since recent Android NDK releases use Clang as the default compiler, a
separate Android specific document is no longer needed; point to the
general build documentation instead.
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/Documentation/Build.txt | 15 +++++++
tools/perf/Documentation/android.txt | 80 +++---------------------------------
2 files changed, 21 insertions(+), 74 deletions(-)
diff --git a/tools/perf/Documentation/Build.txt b/tools/perf/Documentation/Build.txt
index 83dc87c662b63ecc17553a15cc15a6b8d6f01d83..57b226e7fc2f8e849dfe58b3af31891f58dfd0af 100644
--- a/tools/perf/Documentation/Build.txt
+++ b/tools/perf/Documentation/Build.txt
@@ -99,3 +99,18 @@ configuration paths for cross building:
In this case, the variable PKG_CONFIG_SYSROOT_DIR can be used alongside the
variable PKG_CONFIG_LIBDIR or PKG_CONFIG_PATH to prepend the sysroot path to
the library paths for cross compilation.
+
+5) Build with Clang
+===================
+By default, the makefile uses GCC as compiler. With specifying environment
+variables HOSTCC, CC and CXX, it allows to build perf with Clang.
+
+Using Clang for a native build:
+
+ $ HOSTCC=clang CC=clang CXX=clang++ make -C tools/perf
+
+Specifying ARCH and CROSS_COMPILE for cross compilation:
+
+ $ HOSTCC=clang CC=clang CXX=clang++ \
+ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
+ make -C tools/perf
diff --git a/tools/perf/Documentation/android.txt b/tools/perf/Documentation/android.txt
index 24a59998fc91e814ad96f658d3481d88d798b60c..3f3cc7ac3d139c5517ec9458f13c06249c701429 100644
--- a/tools/perf/Documentation/android.txt
+++ b/tools/perf/Documentation/android.txt
@@ -1,78 +1,10 @@
How to compile perf for Android
-=========================================
+===============================
-I. Set the Android NDK environment
-------------------------------------------------
+There are two ways to build perf and run it on Android:
-(a). Use the Android NDK
-------------------------------------------------
-1. You need to download and install the Android Native Development Kit (NDK).
-Set the NDK variable to point to the path where you installed the NDK:
- export NDK=/path/to/android-ndk
+- Method 1: Build perf with static linking. See Build.txt, section
+ "4) Cross compilation" for how to build a static perf binary.
-2. Set cross-compiling environment variables for NDK toolchain and sysroot.
-For arm:
- export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
- export NDK_SYSROOT=${NDK}/platforms/android-24/arch-arm
-For x86:
- export NDK_TOOLCHAIN=${NDK}/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-
- export NDK_SYSROOT=${NDK}/platforms/android-24/arch-x86
-
-This method is only tested for Android NDK versions Revision 11b and later.
-perf uses some bionic enhancements that are not included in prior NDK versions.
-You can use method (b) described below instead.
-
-(b). Use the Android source tree
------------------------------------------------
-1. Download the master branch of the Android source tree.
-Set the environment for the target you want using:
- source build/envsetup.sh
- lunch
-
-2. Build your own NDK sysroot to contain latest bionic changes and set the
-NDK sysroot environment variable.
- cd ${ANDROID_BUILD_TOP}/ndk
-For arm:
- ./build/tools/build-ndk-sysroot.sh --abi=arm
- export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-arm
-For x86:
- ./build/tools/build-ndk-sysroot.sh --abi=x86
- export NDK_SYSROOT=${ANDROID_BUILD_TOP}/ndk/build/platforms/android-3/arch-x86
-
-3. Set the NDK toolchain environment variable.
-For arm:
- export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/arm-linux-androideabi-
-For x86:
- export NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN}/i686-linux-android-
-
-II. Compile perf for Android
-------------------------------------------------
-You need to run make with the NDK toolchain and sysroot defined above:
-For arm:
- make WERROR=0 ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} EXTRA_CFLAGS="-pie --sysroot=${NDK_SYSROOT}"
-For x86:
- make WERROR=0 ARCH=x86 CROSS_COMPILE=${NDK_TOOLCHAIN} EXTRA_CFLAGS="-pie --sysroot=${NDK_SYSROOT}"
-
-III. Install perf
------------------------------------------------
-You need to connect to your Android device/emulator using adb.
-Install perf using:
- adb push perf /data/perf
-
-If you also want to use perf-archive you need busybox tools for Android.
-For installing perf-archive, you first need to replace #!/bin/bash with #!/system/bin/sh:
- sed 's/#!\/bin\/bash/#!\/system\/bin\/sh/g' perf-archive >> /tmp/perf-archive
- chmod +x /tmp/perf-archive
- adb push /tmp/perf-archive /data/perf-archive
-
-IV. Environment settings for running perf
-------------------------------------------------
-Some perf features need environment variables to run properly.
-You need to set these before running perf on the target:
- adb shell
- # PERF_PAGER=cat
-
-IV. Run perf
-------------------------------------------------
-Run perf on your device/emulator to which you previously connected using adb:
- # ./data/perf
+- Method 2: Download the Android NDK and use the bundled Clang to
+ build perf. See Build.txt, section "5) Build with clang" for details.
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header
2025-10-06 16:21 ` [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header Leo Yan
@ 2025-10-06 17:56 ` Ian Rogers
2025-10-06 18:48 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 17+ messages in thread
From: Ian Rogers @ 2025-10-06 17:56 UTC (permalink / raw)
To: Leo Yan
Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 6, 2025 at 9:21 AM Leo Yan <leo.yan@arm.com> wrote:
>
> When build with perl5, it reports error:
>
> In file included from /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7933:
> /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/inline.h:298:5: error:
> mutex 'PL_env_mutex.lock' is not held on every path through
> here [-Werror,-Wthread-safety-analysis]
> 298 | ENV_UNLOCK;
> | ^
> /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7091:31: note:
> expanded from macro 'ENV_UNLOCK'
> 7091 | # define ENV_UNLOCK PERL_REENTRANT_UNLOCK("env"...
> | ^
> /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:6465:7: note:
> expanded from macro 'PERL_REENTRANT_UNLOCK'
> 6465 | } STMT_END
> | ^
> /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:865:28: note:
> expanded from macro 'STMT_END'
> 865 | # define STMT_END while (0)
> | ^
>
> The error is caused by perl header but not perf code, disable thread
> safety analysis if including the header.
>
> Though GCC does not support the thread safety analysis option, this
> negative warning flag is silently ignored by it.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> tools/perf/util/scripting-engines/Build | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Build b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> index 9b0e5a8b5070f1a1640518fae75557f824ef21ee..01a1a0ed51aefd721b4bc7eba728c29a8ffcd551 100644
> --- a/tools/perf/scripts/perl/Perf-Trace-Util/Build
> +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> @@ -2,7 +2,7 @@ perf-util-y += Context.o
>
> CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
> CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef
> -CFLAGS_Context.o += -Wno-switch-default -Wno-shadow
> +CFLAGS_Context.o += -Wno-switch-default -Wno-shadow -Wno-thread-safety-analysis
I wasn't able to reproduce this on Debian with perf-tools-next and:
make -C tools/perf O=/tmp/perf DEBUG=1 CC=clang CXX=clang++
HOSTCC=clang LIBPERL=1 clean all
but my libperl is 5.40. I'm a little concerned that the warning may
cause an unrecognized compiler option warning/error with GCC given
progress on thread-safety-analysis has ended there. Anyway, these
aren't blockers.
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
>
> ifeq ($(CC_NO_CLANG), 1)
> CFLAGS_Context.o += -Wno-unused-command-line-argument
> diff --git a/tools/perf/util/scripting-engines/Build b/tools/perf/util/scripting-engines/Build
> index 2282fe3772f3bdc35056cb5e66efb3462dc1c2e3..24f087b0cd11b3e06a338c394dc2c650bc2c60b1 100644
> --- a/tools/perf/util/scripting-engines/Build
> +++ b/tools/perf/util/scripting-engines/Build
> @@ -3,7 +3,7 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y)
> endif
> perf-util-$(CONFIG_LIBPYTHON) += trace-event-python.o
>
> -CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
> +CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum -Wno-thread-safety-analysis
>
> # -Wno-declaration-after-statement: The python headers have mixed code with declarations (decls after asserts, for instance)
> CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-deprecated-declarations -Wno-switch-enum -Wno-declaration-after-statement
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/9] perf build: Support building with Clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (8 preceding siblings ...)
2025-10-06 16:21 ` [PATCH v3 9/9] perf docs: Document building with Clang Leo Yan
@ 2025-10-06 17:57 ` Ian Rogers
2025-10-06 18:50 ` Arnaldo Carvalho de Melo
` (2 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: Ian Rogers @ 2025-10-06 17:57 UTC (permalink / raw)
To: Leo Yan
Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 6, 2025 at 9:21 AM Leo Yan <leo.yan@arm.com> wrote:
>
> This series adds support for building perf with Clang, following the
> discussion in [1]. Because the Android NDK uses Clang by default,
> enabling Clang builds naturally covers Android as well.
>
> The series is organized as follows:
>
> - Patches 1~2: Fix two bugs found with Clang.
> - Patches 3~7: Correct CROSS_ARCH, Disable thread safety analysis for
> perl header, and dismiss Clang build warnings.
> - Patches 8~9: Enable Clang in the Makefile and update the
> documentation.
>
> Testing:
>
> Tested with linux-tools-container-builds [2], which based on Arnaldo's
> build test container but with several fixes for cross building with
> Clang:
>
> - All clang native builds on x86_64 have passed.
> - The cross builds for arm64/mips/mips64/mipsel/riscv64 have passed.
>
> Only a pity thing is I cannot build successfully with clang for
> ubuntu:20.04-x-powerpc64el (in below log, it only builds with GCC).
> The cross config does not work well on Ubuntu 20.04 due to failure
> "No gnu/libc-version.h found, please install glibc-dev[el]". I confirmed
> that powerpc64el cross build can make success on Ubuntu 24.04, the
> failure on Ubuntu 20.04 should not be caused by perf build.
>
> Subject: tools build test for http://localhost/perf/perf-6.17.0-rc6.tar.xz
>
> 1 201.44 alpine:3.16 : Ok gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
> 2 154.82 alpine:3.17 : Ok gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
> 3 136.07 alpine:3.18 : Ok gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924 , Alpine clang version 16.0.6 flex 2.6.4
> 4 150.21 alpine:3.19 : Ok gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014 , Alpine clang version 17.0.5 flex 2.6.4
> 5 143.50 alpine:3.20 : Ok gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309 , Alpine clang version 17.0.6 flex 2.6.4
> 6 146.08 amazonlinux:2023 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5) , clang version 15.0.7 (AWS 15.0.7-3.amzn2023.0.4) flex 2.6.4
> 7 147.19 amazonlinux:devel : Ok gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4) , clang version 15.0.6 (Amazon Linux 15.0.6-3.amzn2023.0.2) flex 2.6.4
> 8 117.92 debian:11 : Ok gcc (Debian 10.2.1-6) 10.2.1 20210110 , Debian clang version 13.0.1-6~deb11u1 flex 2.6.4
> 9 121.54 debian:12 : Ok gcc (Debian 12.2.0-14+deb12u1) 12.2.0 , Debian clang version 14.0.6 flex 2.6.4
> 10 128.64 debian:experimental : Ok gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 11 96.47 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 12 72.89 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 13 73.31 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 14 71.69 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 15 151.92 fedora:35 : Ok gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-3) , clang version 13.0.1 (Fedora 13.0.1-1.fc35) flex 2.6.4
> 16 146.99 fedora:36 : Ok gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) , clang version 14.0.5 (Fedora 14.0.5-2.fc36) flex 2.6.4
> 17 139.58 fedora:37 : Ok gcc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1) , clang version 15.0.7 (Fedora 15.0.7-2.fc37) flex 2.6.4
> 18 142.00 fedora:38 : Ok gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7) , clang version 16.0.6 (Fedora 16.0.6-4.fc38) flex 2.6.4
> 19 140.18 fedora:39 : Ok gcc (GCC) 13.3.1 20240913 (Red Hat 13.3.1-3) , clang version 17.0.6 (Fedora 17.0.6-2.fc39) flex 2.6.4
> 20 139.38 fedora:40 : Ok gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) , clang version 18.1.8 (Fedora 18.1.8-2.fc40) flex 2.6.4
> 21 136.26 fedora:41 : Ok gcc (GCC) 14.3.1 20250808 (Red Hat 14.3.1-3) , clang version 19.1.7 (Fedora 19.1.7-5.fc41) flex 2.6.4
> 22 135.38 fedora:42 : Ok gcc (GCC) 15.2.1 20250808 (Red Hat 15.2.1-1) , clang version 20.1.8 (Fedora 20.1.8-4.fc42) flex 2.6.4
> 23 127.55 fedora:rawhide : Ok gcc (GCC) 15.2.1 20250924 (Red Hat 15.2.1-2) , clang version 21.1.2 (Fedora 21.1.2-1.fc44) flex 2.6.4
> 24 180.17 opensuse:15.4 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
> 25 169.40 opensuse:15.5 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
> 26 167.36 opensuse:15.6 : Ok gcc (SUSE Linux) 7.5.0 , clang version 17.0.6 flex 2.6.4
> 27 154.82 opensuse:tumbleweed : Ok gcc (SUSE Linux) 15.2.0 , clang version 21.1.2 flex 2.6.4
> 28 145.89 oraclelinux:8 : Ok gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-28.0.1) , clang version 19.1.7 ( 19.1.7-2.module+el8.10.0+90583+7e562d96) flex 2.6.1
> 29 139.68 oraclelinux:9 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5.0.1) , clang version 19.1.7 ( 19.1.7-2.el9) flex 2.6.4
> 30 40.17 ubuntu:20.04 : Ok gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 flex 2.6.4
> 31 20.83 ubuntu:20.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0 flex 2.6.4
> 32 127.75 ubuntu:22.04 : Ok gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
> 33 92.25 ubuntu:22.04-x-riscv64 : Ok riscv64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
> 34 126.64 ubuntu:24.04 : Ok gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 , Ubuntu clang version 18.1.3 (1ubuntu1) flex 2.6.4
> 35 130.95 ubuntu:25.04 : Ok gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0 , Ubuntu clang version 20.1.2 (0ubuntu1) flex 2.6.4
>
> [1] https://lore.kernel.org/linux-perf-users/20240715143342.52236-1-leo.yan@arm.com/
> [2] https://github.com/Leo-Yan/linux-tools-container-builds/tree/fix-riscv64-cross-build
>
> ---
> Changes in v3:
> - Fixed build failure with musl lib.
> - Disabled thread safety analysis for perl head.
> - Link to v2: https://lore.kernel.org/r/20250930-perf_build_android_ndk-v2-0-2ea440b7ef01@arm.com
>
> Changes in v2:
> - Dropped the patch for dismissing warning in bpftool.
> - Refined the document. (Ian)
> - Link to v1: https://lore.kernel.org/r/20250925-perf_build_android_ndk-v1-0-8b35aadde3dc@arm.com
For the series:
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> Leo Yan (9):
> tools build: Align warning options with perf
> perf python: split Clang options when invoking Popen
> perf build: Correct CROSS_ARCH for clang
> perf build: Disable thread safety analysis for perl header
> perf test coresight: Dismiss clang warning for memcpy thread
> perf test coresight: Dismiss clang warning for thread loop
> perf test coresight: Dismiss clang warning for unroll loop thread
> perf build: Support build with clang
> perf docs: Document building with Clang
>
> tools/build/feature/Makefile | 6 +-
> tools/perf/Documentation/Build.txt | 15 ++++
> tools/perf/Documentation/android.txt | 80 ++--------------------
> tools/perf/Makefile.config | 33 ++++++++-
> tools/perf/Makefile.perf | 2 +-
> tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> .../shell/coresight/memcpy_thread/memcpy_thread.c | 2 +
> .../shell/coresight/thread_loop/thread_loop.c | 4 +-
> .../unroll_loop_thread/unroll_loop_thread.c | 4 +-
> tools/perf/util/scripting-engines/Build | 2 +-
> tools/perf/util/setup.py | 5 +-
> 11 files changed, 70 insertions(+), 85 deletions(-)
> ---
> base-commit: c17dda8013495d8132c976cbf349be9949d0fbd1
> change-id: 20250915-perf_build_android_ndk-500b53bea895
>
> Best regards,
> --
> Leo Yan <leo.yan@arm.com>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header
2025-10-06 17:56 ` Ian Rogers
@ 2025-10-06 18:48 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-06 18:48 UTC (permalink / raw)
To: Ian Rogers
Cc: Leo Yan, Namhyung Kim, Jiri Olsa, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 06, 2025 at 10:56:43AM -0700, Ian Rogers wrote:
> On Mon, Oct 6, 2025 at 9:21 AM Leo Yan <leo.yan@arm.com> wrote:
> >
> > When build with perl5, it reports error:
> >
> > In file included from /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7933:
> > /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/inline.h:298:5: error:
> > mutex 'PL_env_mutex.lock' is not held on every path through
> > here [-Werror,-Wthread-safety-analysis]
> > 298 | ENV_UNLOCK;
> > | ^
> > /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:7091:31: note:
> > expanded from macro 'ENV_UNLOCK'
> > 7091 | # define ENV_UNLOCK PERL_REENTRANT_UNLOCK("env"...
> > | ^
> > /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:6465:7: note:
> > expanded from macro 'PERL_REENTRANT_UNLOCK'
> > 6465 | } STMT_END
> > | ^
> > /usr/lib/perl5/5.42.0/x86_64-linux-thread-multi/CORE/perl.h:865:28: note:
> > expanded from macro 'STMT_END'
> > 865 | # define STMT_END while (0)
> > | ^
> >
> > The error is caused by perl header but not perf code, disable thread
> > safety analysis if including the header.
> >
> > Though GCC does not support the thread safety analysis option, this
> > negative warning flag is silently ignored by it.
> >
> > Signed-off-by: Leo Yan <leo.yan@arm.com>
> > ---
> > tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> > tools/perf/util/scripting-engines/Build | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Build b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> > index 9b0e5a8b5070f1a1640518fae75557f824ef21ee..01a1a0ed51aefd721b4bc7eba728c29a8ffcd551 100644
> > --- a/tools/perf/scripts/perl/Perf-Trace-Util/Build
> > +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> > @@ -2,7 +2,7 @@ perf-util-y += Context.o
> >
> > CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
> > CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef
> > -CFLAGS_Context.o += -Wno-switch-default -Wno-shadow
> > +CFLAGS_Context.o += -Wno-switch-default -Wno-shadow -Wno-thread-safety-analysis
>
> I wasn't able to reproduce this on Debian with perf-tools-next and:
> make -C tools/perf O=/tmp/perf DEBUG=1 CC=clang CXX=clang++
> HOSTCC=clang LIBPERL=1 clean all
> but my libperl is 5.40. I'm a little concerned that the warning may
> cause an unrecognized compiler option warning/error with GCC given
> progress on thread-safety-analysis has ended there. Anyway, these
> aren't blockers.
>
> Reviewed-by: Ian Rogers <irogers@google.com>
I was a bit wary and saw this on only, IIRC Manjaro Linux, and since
libperl support is opt-in, I left it in the backburner, but having it
building there as well may help detecting some other stuff with things
only enabled/present there, so thanks Leo and Ian, for the patch and the
Reviewed-by, applying.
- Arnaldo
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/9] perf build: Support building with Clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (9 preceding siblings ...)
2025-10-06 17:57 ` [PATCH v3 0/9] perf build: Support " Ian Rogers
@ 2025-10-06 18:50 ` Arnaldo Carvalho de Melo
2025-10-07 18:06 ` Leo Yan
2025-10-06 19:50 ` Arnaldo Carvalho de Melo
2025-10-10 2:27 ` patchwork-bot+linux-riscv
12 siblings, 1 reply; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-06 18:50 UTC (permalink / raw)
To: Leo Yan
Cc: Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 06, 2025 at 05:21:22PM +0100, Leo Yan wrote:
> This series adds support for building perf with Clang, following the
> discussion in [1]. Because the Android NDK uses Clang by default,
> enabling Clang builds naturally covers Android as well.
>
> The series is organized as follows:
>
> - Patches 1~2: Fix two bugs found with Clang.
> - Patches 3~7: Correct CROSS_ARCH, Disable thread safety analysis for
> perl header, and dismiss Clang build warnings.
> - Patches 8~9: Enable Clang in the Makefile and update the
> documentation.
>
> Testing:
>
> Tested with linux-tools-container-builds [2], which based on Arnaldo's
> build test container but with several fixes for cross building with
> Clang:
>
> - All clang native builds on x86_64 have passed.
> - The cross builds for arm64/mips/mips64/mipsel/riscv64 have passed.
>
> Only a pity thing is I cannot build successfully with clang for
> ubuntu:20.04-x-powerpc64el (in below log, it only builds with GCC).
> The cross config does not work well on Ubuntu 20.04 due to failure
> "No gnu/libc-version.h found, please install glibc-dev[el]". I confirmed
> that powerpc64el cross build can make success on Ubuntu 24.04, the
> failure on Ubuntu 20.04 should not be caused by perf build.
>
> Subject: tools build test for http://localhost/perf/perf-6.17.0-rc6.tar.xz
I shed a tear ;-)
And thanks for fixing the ubuntu cross builds, I'll apply those patches
you made available thru github,
Thanks a lot!
- Arnaldo
> 1 201.44 alpine:3.16 : Ok gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219 , Alpine clang version 13.0.1 flex 2.6.4
> 2 154.82 alpine:3.17 : Ok gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924 , Alpine clang version 15.0.7 flex 2.6.4
> 3 136.07 alpine:3.18 : Ok gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924 , Alpine clang version 16.0.6 flex 2.6.4
> 4 150.21 alpine:3.19 : Ok gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014 , Alpine clang version 17.0.5 flex 2.6.4
> 5 143.50 alpine:3.20 : Ok gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309 , Alpine clang version 17.0.6 flex 2.6.4
> 6 146.08 amazonlinux:2023 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5) , clang version 15.0.7 (AWS 15.0.7-3.amzn2023.0.4) flex 2.6.4
> 7 147.19 amazonlinux:devel : Ok gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4) , clang version 15.0.6 (Amazon Linux 15.0.6-3.amzn2023.0.2) flex 2.6.4
> 8 117.92 debian:11 : Ok gcc (Debian 10.2.1-6) 10.2.1 20210110 , Debian clang version 13.0.1-6~deb11u1 flex 2.6.4
> 9 121.54 debian:12 : Ok gcc (Debian 12.2.0-14+deb12u1) 12.2.0 , Debian clang version 14.0.6 flex 2.6.4
> 10 128.64 debian:experimental : Ok gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 11 96.47 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 15.2.0-4) 15.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 12 72.89 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 13 73.31 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 14 71.69 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 14.2.0-13) 14.2.0 , Debian clang version 19.1.7 (7) flex 2.6.4
> 15 151.92 fedora:35 : Ok gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-3) , clang version 13.0.1 (Fedora 13.0.1-1.fc35) flex 2.6.4
> 16 146.99 fedora:36 : Ok gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) , clang version 14.0.5 (Fedora 14.0.5-2.fc36) flex 2.6.4
> 17 139.58 fedora:37 : Ok gcc (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1) , clang version 15.0.7 (Fedora 15.0.7-2.fc37) flex 2.6.4
> 18 142.00 fedora:38 : Ok gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7) , clang version 16.0.6 (Fedora 16.0.6-4.fc38) flex 2.6.4
> 19 140.18 fedora:39 : Ok gcc (GCC) 13.3.1 20240913 (Red Hat 13.3.1-3) , clang version 17.0.6 (Fedora 17.0.6-2.fc39) flex 2.6.4
> 20 139.38 fedora:40 : Ok gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3) , clang version 18.1.8 (Fedora 18.1.8-2.fc40) flex 2.6.4
> 21 136.26 fedora:41 : Ok gcc (GCC) 14.3.1 20250808 (Red Hat 14.3.1-3) , clang version 19.1.7 (Fedora 19.1.7-5.fc41) flex 2.6.4
> 22 135.38 fedora:42 : Ok gcc (GCC) 15.2.1 20250808 (Red Hat 15.2.1-1) , clang version 20.1.8 (Fedora 20.1.8-4.fc42) flex 2.6.4
> 23 127.55 fedora:rawhide : Ok gcc (GCC) 15.2.1 20250924 (Red Hat 15.2.1-2) , clang version 21.1.2 (Fedora 21.1.2-1.fc44) flex 2.6.4
> 24 180.17 opensuse:15.4 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
> 25 169.40 opensuse:15.5 : Ok gcc (SUSE Linux) 7.5.0 , clang version 15.0.7 flex 2.6.4
> 26 167.36 opensuse:15.6 : Ok gcc (SUSE Linux) 7.5.0 , clang version 17.0.6 flex 2.6.4
> 27 154.82 opensuse:tumbleweed : Ok gcc (SUSE Linux) 15.2.0 , clang version 21.1.2 flex 2.6.4
> 28 145.89 oraclelinux:8 : Ok gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-28.0.1) , clang version 19.1.7 ( 19.1.7-2.module+el8.10.0+90583+7e562d96) flex 2.6.1
> 29 139.68 oraclelinux:9 : Ok gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5.0.1) , clang version 19.1.7 ( 19.1.7-2.el9) flex 2.6.4
> 30 40.17 ubuntu:20.04 : Ok gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 flex 2.6.4
> 31 20.83 ubuntu:20.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0 flex 2.6.4
> 32 127.75 ubuntu:22.04 : Ok gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
> 33 92.25 ubuntu:22.04-x-riscv64 : Ok riscv64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 , Ubuntu clang version 14.0.0-1ubuntu1.1 flex 2.6.4
> 34 126.64 ubuntu:24.04 : Ok gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 , Ubuntu clang version 18.1.3 (1ubuntu1) flex 2.6.4
> 35 130.95 ubuntu:25.04 : Ok gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0 , Ubuntu clang version 20.1.2 (0ubuntu1) flex 2.6.4
>
> [1] https://lore.kernel.org/linux-perf-users/20240715143342.52236-1-leo.yan@arm.com/
> [2] https://github.com/Leo-Yan/linux-tools-container-builds/tree/fix-riscv64-cross-build
>
> ---
> Changes in v3:
> - Fixed build failure with musl lib.
> - Disabled thread safety analysis for perl head.
> - Link to v2: https://lore.kernel.org/r/20250930-perf_build_android_ndk-v2-0-2ea440b7ef01@arm.com
>
> Changes in v2:
> - Dropped the patch for dismissing warning in bpftool.
> - Refined the document. (Ian)
> - Link to v1: https://lore.kernel.org/r/20250925-perf_build_android_ndk-v1-0-8b35aadde3dc@arm.com
>
> ---
> Leo Yan (9):
> tools build: Align warning options with perf
> perf python: split Clang options when invoking Popen
> perf build: Correct CROSS_ARCH for clang
> perf build: Disable thread safety analysis for perl header
> perf test coresight: Dismiss clang warning for memcpy thread
> perf test coresight: Dismiss clang warning for thread loop
> perf test coresight: Dismiss clang warning for unroll loop thread
> perf build: Support build with clang
> perf docs: Document building with Clang
>
> tools/build/feature/Makefile | 6 +-
> tools/perf/Documentation/Build.txt | 15 ++++
> tools/perf/Documentation/android.txt | 80 ++--------------------
> tools/perf/Makefile.config | 33 ++++++++-
> tools/perf/Makefile.perf | 2 +-
> tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +-
> .../shell/coresight/memcpy_thread/memcpy_thread.c | 2 +
> .../shell/coresight/thread_loop/thread_loop.c | 4 +-
> .../unroll_loop_thread/unroll_loop_thread.c | 4 +-
> tools/perf/util/scripting-engines/Build | 2 +-
> tools/perf/util/setup.py | 5 +-
> 11 files changed, 70 insertions(+), 85 deletions(-)
> ---
> base-commit: c17dda8013495d8132c976cbf349be9949d0fbd1
> change-id: 20250915-perf_build_android_ndk-500b53bea895
>
> Best regards,
> --
> Leo Yan <leo.yan@arm.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/9] perf build: Support building with Clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (10 preceding siblings ...)
2025-10-06 18:50 ` Arnaldo Carvalho de Melo
@ 2025-10-06 19:50 ` Arnaldo Carvalho de Melo
2025-10-10 2:27 ` patchwork-bot+linux-riscv
12 siblings, 0 replies; 17+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-10-06 19:50 UTC (permalink / raw)
To: Leo Yan
Cc: Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 06, 2025 at 05:21:22PM +0100, Leo Yan wrote:
> This series adds support for building perf with Clang, following the
> discussion in [1]. Because the Android NDK uses Clang by default,
> enabling Clang builds naturally covers Android as well.
>
> The series is organized as follows:
>
> - Patches 1~2: Fix two bugs found with Clang.
> - Patches 3~7: Correct CROSS_ARCH, Disable thread safety analysis for
> perl header, and dismiss Clang build warnings.
> - Patches 8~9: Enable Clang in the Makefile and update the
> documentation.
>
> Testing:
>
> Tested with linux-tools-container-builds [2], which based on Arnaldo's
> build test container but with several fixes for cross building with
> Clang:
>
> - All clang native builds on x86_64 have passed.
> - The cross builds for arm64/mips/mips64/mipsel/riscv64 have passed.
>
> Only a pity thing is I cannot build successfully with clang for
> ubuntu:20.04-x-powerpc64el (in below log, it only builds with GCC).
> The cross config does not work well on Ubuntu 20.04 due to failure
> "No gnu/libc-version.h found, please install glibc-dev[el]". I confirmed
> that powerpc64el cross build can make success on Ubuntu 24.04, the
> failure on Ubuntu 20.04 should not be caused by perf build.
Thaanks, applied, testing it.
- Arnaldo
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/9] perf build: Support building with Clang
2025-10-06 18:50 ` Arnaldo Carvalho de Melo
@ 2025-10-07 18:06 ` Leo Yan
0 siblings, 0 replies; 17+ messages in thread
From: Leo Yan @ 2025-10-07 18:06 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
James Clark, linux-kernel, linux-perf-users, llvm, linux-riscv
On Mon, Oct 06, 2025 at 03:50:34PM -0300, Arnaldo Carvalho de Melo wrote:
[...]
> I shed a tear ;-)
>
> And thanks for fixing the ubuntu cross builds, I'll apply those patches
> you made available thru github,
>
> Thanks a lot!
You are very welcome! And very appreciate you shared build container
scripts, this would be a big benefit for CI test! (I have enabled the
test on my local machine and works pretty well).
Thanks,
Leo
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/9] perf build: Support building with Clang
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
` (11 preceding siblings ...)
2025-10-06 19:50 ` Arnaldo Carvalho de Melo
@ 2025-10-10 2:27 ` patchwork-bot+linux-riscv
12 siblings, 0 replies; 17+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-10-10 2:27 UTC (permalink / raw)
To: Leo Yan
Cc: linux-riscv, acme, namhyung, jolsa, irogers, adrian.hunter,
nathan, nick.desaulniers+lkml, morbo, justinstitt, paul.walmsley,
palmer, aou, alex, james.clark, linux-kernel, linux-perf-users,
llvm
Hello:
This series was applied to riscv/linux.git (fixes)
by Arnaldo Carvalho de Melo <acme@redhat.com>:
On Mon, 06 Oct 2025 17:21:22 +0100 you wrote:
> This series adds support for building perf with Clang, following the
> discussion in [1]. Because the Android NDK uses Clang by default,
> enabling Clang builds naturally covers Android as well.
>
> The series is organized as follows:
>
> - Patches 1~2: Fix two bugs found with Clang.
> - Patches 3~7: Correct CROSS_ARCH, Disable thread safety analysis for
> perl header, and dismiss Clang build warnings.
> - Patches 8~9: Enable Clang in the Makefile and update the
> documentation.
>
> [...]
Here is the summary with links:
- [v3,1/9] tools build: Align warning options with perf
https://git.kernel.org/riscv/c/53d067feb8c4
- [v3,2/9] perf python: split Clang options when invoking Popen
https://git.kernel.org/riscv/c/c6a43bc3e8f6
- [v3,3/9] perf build: Correct CROSS_ARCH for clang
https://git.kernel.org/riscv/c/ed33e5e43c1e
- [v3,4/9] perf build: Disable thread safety analysis for perl header
https://git.kernel.org/riscv/c/e7e86d7697c6
- [v3,5/9] perf test coresight: Dismiss clang warning for memcpy thread
https://git.kernel.org/riscv/c/50b7e7082a3d
- [v3,6/9] perf test coresight: Dismiss clang warning for thread loop
https://git.kernel.org/riscv/c/244a1ac76a67
- [v3,7/9] perf test coresight: Dismiss clang warning for unroll loop thread
https://git.kernel.org/riscv/c/9ec46fc93803
- [v3,8/9] perf build: Support build with clang
https://git.kernel.org/riscv/c/4772e66cb45e
- [v3,9/9] perf docs: Document building with Clang
https://git.kernel.org/riscv/c/0a75ba3e842c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-10-10 2:27 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-06 16:21 [PATCH v3 0/9] perf build: Support building with Clang Leo Yan
2025-10-06 16:21 ` [PATCH v3 1/9] tools build: Align warning options with perf Leo Yan
2025-10-06 16:21 ` [PATCH v3 2/9] perf python: split Clang options when invoking Popen Leo Yan
2025-10-06 16:21 ` [PATCH v3 3/9] perf build: Correct CROSS_ARCH for clang Leo Yan
2025-10-06 16:21 ` [PATCH v3 4/9] perf build: Disable thread safety analysis for perl header Leo Yan
2025-10-06 17:56 ` Ian Rogers
2025-10-06 18:48 ` Arnaldo Carvalho de Melo
2025-10-06 16:21 ` [PATCH v3 5/9] perf test coresight: Dismiss clang warning for memcpy thread Leo Yan
2025-10-06 16:21 ` [PATCH v3 6/9] perf test coresight: Dismiss clang warning for thread loop Leo Yan
2025-10-06 16:21 ` [PATCH v3 7/9] perf test coresight: Dismiss clang warning for unroll loop thread Leo Yan
2025-10-06 16:21 ` [PATCH v3 8/9] perf build: Support build with clang Leo Yan
2025-10-06 16:21 ` [PATCH v3 9/9] perf docs: Document building with Clang Leo Yan
2025-10-06 17:57 ` [PATCH v3 0/9] perf build: Support " Ian Rogers
2025-10-06 18:50 ` Arnaldo Carvalho de Melo
2025-10-07 18:06 ` Leo Yan
2025-10-06 19:50 ` Arnaldo Carvalho de Melo
2025-10-10 2:27 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).