Re: [PATCH v3 7/7] perf docs: Remove the Android cross building document

From: Leo Yan
Date: Fri Jul 12 2024 - 07:02:16 EST


Hi Namhyung,

On 7/12/24 05:58, Namhyung Kim wrote:
On Sat, Jul 06, 2024 at 07:29:12PM +0100, Leo Yan wrote:

[...]

The Android NDK (as time being the latest LTS version is r26d) changes
toolchain to LLVM / Clang, so GCC compilers is not included in the NDK
anymore. Therefore, the Android document contains obsolete info for
building perf binary with NDK.

Do you know if the version prior to the change is still used?

Based on the Android NDK wiki claims [1], since NDK r15 (backed to 26th
July, 2017) "GCC is no longer supported. It will not be removed from the NDK
just yet, but is no longer receiving backports".

Furthermore, the Clang included in the Android NDK is problematic for
cross compilation Aarch64 target. The building reports multiple errors
with the compiler aarch64-linux-android34-clang.

Thus, delete Documentation/android.txt to avoid confusion.

If so, maybe we can keep the document little more and add a note that
this works only for some old versions.

I'm also curious if it's still broken after your fixes.

When I tried Android NDK for cross building perf, it is still broken after
applied this series.

From my testing, now using LLVM for native building works well:

make LLVM=-15 VF=1 DEBUG=1 -C tools/perf

But it failed for cross compilation. Since Android NDK system root does not
contain some dependency libs, we must use extra options to disable some
features (e.g. NO_LIBELF=1 NO_LIBTRACEEVENT=1). The commands I tried for
cross building but failed:

make ARCH=arm64 CC=$NDK_TOOLCHAIN/aarch64-linux-android-clang \
LD=$NDK_TOOLCHAIN/ld.lld AR=$NDK_TOOLCHAIN/llvm-ar \
NM=$NDK_TOOLCHAIN/llvm-nm STRIP=$NDK_TOOLCHAIN/llvm-strip \
OBJCOPY=$NDK_TOOLCHAIN/llvm-objcopy \
OBJDUMP=$NDK_TOOLCHAIN/llvm-objdump \
READELF=$NDK_TOOLCHAIN/llvm-readelf \
HOSTCC=$NDK_TOOLCHAIN/clang \
HOSTCXX=$NDK_TOOLCHAIN/clang++ HOSTAR=$NDK_TOOLCHAIN/llvm-ar \
HOSTLD=$NDK_TOOLCHAIN/ld.lld VF=1 DEBUG=1 NO_LIBELF=1 \
NO_LIBTRACEEVENT=1 EXTRA_CFLAGS=-fgnuc-version=0 \
-C tools/perf

Given the test result, my conclusion is the doc for Android cross building
is not useful for a long while. If we really want to support it, I would
like to suggest to take a separate task for fixing LLVM / Clang cross
compilation.

Thanks,
Leo

[1] https://github.com/android/ndk/wiki/Changelog-r15