Re: [PATCH v2] perf docs: Mark the Android document as obsolete

From: Leo Yan
Date: Mon Jul 15 2024 - 16:38:56 EST


On 7/15/2024 9:06 PM, Ian Rogers wrote:

[...]

> So if I add (somewhat taken from tools/testing/selftests/lib.mk):
> ```
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 5271a4c1d2b3..9edf5f41d6e4 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -19,6 +19,35 @@ detected_var = $(shell echo "$(1)=$($(1))" >>
> $(OUTPUT).config-detected)
> CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
> HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
>
> +CLANG := clang
> +
> +CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
> +CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
> +CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
> +CLANG_TARGET_FLAGS_i386 := i386-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),)
> +CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple)
> +else
> +CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
> +endif
> +
> +ifeq ($(CLANG_TARGET_FLAGS),)
> +$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk)
> +else
> +CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
> +endif # CLANG_TARGET_FLAGS
> +
> +CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
> +
> # Enabled Wthread-safety analysis for clang builds.
> ifeq ($(CC_NO_CLANG), 0)
> CFLAGS += -Wthread-safety
> ```
> I was able to build with:
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
> O=/tmp/perf NO_LIBELF=1 NO_LIBTRACEEVENT=1 NO_LIBPYTHON=1 CC=clang
> CXX=clang++

This command doesn't work for me.

Built with 'CROSS_COMPILE=aarch64-linux-gnu-' option, the perf tool is still
built with GCC:

$ strings perf | grep GCC
GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

After removing the option 'CROSS_COMPILE=aarch64-linux-gnu-', still failed
building.

Anyway, thanks a lot for sharing.

Leo

> Obviously not a complete fix as it is unconditionally forcing CC to
> clang, but I don't think we're too far from having a clang/llvm cross
> compile build that can work.
>
> Thanks,
> Ian