Skip to content

perf build: Fix builds with clang and BUILD_NONDISTRO

Ian Rogers linux-perf-users lkml llvm sashiko-reviews 1 version Applied

Status from this message: Thanks, applied to perf-tools-next, for v7.4.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 4 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/9perf libbfd: Fix the clang -Wthread-safety build failuretools/perf/util/libbfd.c+2 -20 replies
2/9perf symbol: Fix the build when demangling with libbfdtools/perf/util/libbfd.c tools/perf/util/libbfd.h tools/perf/util/symbol.c+41 -30 replies
3/9perf libbfd: Include the headers that are usedtools/perf/util/libbfd.c+16 -42 replies
4/9perf pmu: Include the headers that are usedtools/perf/util/pmu.c+4 -10 replies
5/9perf build: Only pass clang flags to CXX when CXX is clangtools/perf/Makefile.config+8 -10 replies
6/9perf build: Use the given CC rather than clang in clang buildstools/perf/Makefile.config+2 -20 replies
7/9perf build: Check the version of the compiler that is usedtools/perf/util/Build+1 -10 replies
8/9perf build: Remove leftovers of removed build optionstools/perf/Makefile.perf tools/perf/tests/make+0 -60 replies
9/9perf test: Add build tests for clang and libbfd demanglingtools/perf/tests/make+45 -20 replies

Reviews trailers per patch

None of the 9 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNamhyung Kim
SeriesA-b
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/9] perf build: Fix builds with clang and BUILD_NONDISTRO

Several perf build configurations are broken, and stayed broken because the build test suite doesn't cover them.

Three of them fail outright:

  $ make CC=clang BUILD_NONDISTRO=1
  util/libbfd.c:56:1: error: mutex 'bfd_mutex' is still held at the end
  of function [-Werror,-Wthread-safety-analysis]
  $ make BUILD_NONDISTRO=1 NO_DEMANGLE=1
  util/symbol.c:2714: error: 'DMGL_PARAMS' undeclared
  $ make CC=clang-19
  *** Specify CROSS_COMPILE or add CLANG_TARGET_FLAGS for x86_64

A fourth is worse for being silent. "make CC=clang" appends clang's --target= and -fintegrated-as to CXX, but CXX is only set to clang++ by "make LLVM=1", so it is still g++ and rejects both. Feature tests are allowed to fail, so nothing is reported: the build succeeds and just quietly drops libllvm and C++ demangling support.

  $ make CC=clang && grep LIBLLVM .config-detected
  (nothing, whereas a gcc build reports CONFIG_LIBLLVM=y)

The patches are grouped as:

1-2 Fix the two build failures, in libbfd.c and symbol.c. 3-4 Include the headers that are used directly rather than relying
on other headers to drag them in. No functional change.
5-7 Fix the clang handling in Makefile.config: don't give clang's
flags to a non-clang CXX, and use the CC that was asked for instead of hard coding "clang" when picking the target triple and when testing the compiler version.
8 Remove three build test entries left behind by the removal of
the options they tested. None of them define what to build, so each silently repeats "make_pure" and the suite spends six builds appearing to cover options that no longer exist.
9 Add build tests for the configurations above, so they don't
break again. As a build that loses a feature still succeeds, the clang tests also check that libLLVM is still built in.

Testing:

- 13 build configurations (gcc, clang, versioned clang, LLVM=1, BUILD_NONDISTRO, NO_DEMANGLE, NO_LIBDW, NO_LIBELF, DEBUG, asan, refcount checking) pass, where two failed before the series.
- Every patch builds on its own, so the series stays bisectable.
- Each fix was confirmed by reintroducing the bug and checking that the test added in patch 9 fails:

     CXX flags given to g++     make_clang             fails on libLLVM
     libbfd thread safety       make_clang_nondistro   fails to compile
     symbol.c demangling        make_nondistro_no_demangle  likewise

Ian Rogers (9):
perf libbfd: Fix the clang -Wthread-safety build failure perf symbol: Fix the build when demangling with libbfd perf libbfd: Include the headers that are used
perf pmu: Include the headers that are used
perf build: Only pass clang flags to CXX when CXX is clang perf build: Use the given CC rather than clang in clang builds perf build: Check the version of the compiler that is used perf build: Remove leftovers of removed build options perf test: Add build tests for clang and libbfd demangling

 tools/perf/Makefile.config | 13 +++++++---
 tools/perf/Makefile.perf   |  3 ---
 tools/perf/tests/make      | 50 ++++++++++++++++++++++++++++++++++----
 tools/perf/util/Build      |  2 +-
 tools/perf/util/libbfd.c   | 41 ++++++++++++++++++++++++++-----
 tools/perf/util/libbfd.h   |  9 +++++++
 tools/perf/util/pmu.c      |  5 +++-
 tools/perf/util/symbol.c   | 18 +++++++++++---
 8 files changed, 119 insertions(+), 22 deletions(-)

base-commit: 91b0782fc9e9d2f0a40b5256146e014802fdbb36

Signature · 1 line
2.55.0.1032.g73a4cd73de-goog