Re: [PATCHv2 3/3] perf: add helper makefile for cross compiling libs

From: Ingo Molnar
Date: Thu Oct 29 2015 - 05:46:59 EST



* Rabin Vincent <rabin.vincent@xxxxxxxx> wrote:

> It's easy to cross-compile a minimal perf binary without any external
> libraries (other than a C library of course). But many useful features
> depend on external libraries, so to get them one needs to either
> cross-compile a bunch of libraries manually and send in the correct
> paths or integrate the perf build into some external build system.
>
> In order to make it easier for people to qucikly get up and running with
> a fairly full featured cross-compiled mainline perf, provide a helper makefile
> which can be used to download and build the required libraries, which can then
> be used in a static build of perf.
>
> For example, assuming an arm-linux-gcc cross-compiler is present in the
> PATH, the following is what one seens if one tries to build a static
> perf for ARM:
>
> $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
>
> Auto-detecting system features:
> ... dwarf: [ OFF ]
> ... glibc: [ on ]
> ... gtk2: [ OFF ]
> ... libaudit: [ OFF ]
> ... libbfd: [ OFF ]
> ... libelf: [ OFF ]
> ... libnuma: [ OFF ]
> ... numa_num_possible_cpus: [ OFF ]
> ... libperl: [ OFF ]
> ... libpython: [ OFF ]
> ... libslang: [ OFF ]
> ... libunwind: [ OFF ]
> ... libdw-dwarf-unwind: [ OFF ]
> ... zlib: [ OFF ]
> ... lzma: [ OFF ]
> ... get_cpuid: [ OFF ]
>
> By using the new Makefile.cross first, we get many important features:
>
> $ make ARCH=arm CROSS_COMPILE=arm-linux- -f Makefile.cross
> $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
>
> Auto-detecting system features:
> ... dwarf: [ on ]
> ... glibc: [ on ]
> ... gtk2: [ OFF ]
> ... libaudit: [ on ]
> ... libbfd: [ on ]
> ... libelf: [ on ]
> ... libnuma: [ OFF ]
> ... numa_num_possible_cpus: [ OFF ]
> ... libperl: [ OFF ]
> ... libpython: [ OFF ]
> ... libslang: [ on ]
> ... libunwind: [ on ]
> ... libdw-dwarf-unwind: [ OFF ]
> ... zlib: [ on ]
> ... lzma: [ on ]
> ... get_cpuid: [ OFF ]

That's really nice!

Would it be possible to add a gcc and glibc building portion as well? That would
make it entirely self-hosting.

Something like:

make ARCH=arm BOOTSTRAP=1

... would magically fetch everything needed, and (given enough Internet bandwidth
and a fast enough machine) build a whole cross-environment from scratch.

Personally I'd even use this to bootstrap kernel cross-builds.

It could also be used to cross-build to the host architecture as well: it would
make it easier to test perf on the latest GCC and glibc versions. (Which the host
distribution does not carry.)

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/