On Mon, May 16, 2022 at 07:54:02PM +0300, Vladimir Oltean wrote:

> I also compile the Linux kernel so I won't set KBUILD_OUTPUT unless I
> want to garble my toolchain sysroot with junk.

Um, the header files that ship with the toolchain are not "junk".
They are essential to the compiler (unless you are building bare metal
programs without any libraries at all, not even C runtime!)

> The main problem is that
> incdefs.sh guesses incorrectly where the header files are, if I don't
> point KBUILD_OUTPUT to them.

Yes, I see that the script does the wrong thing when KBUILD_OUTPUT is
set but the path does not exist.  In this case the script uses the
build system headers, and that is wrong.  Instead, it should throw an
error.
 
> But ok, maybe I'm doing something wrong. How do you set up a cross
> compilation environment that works for linuxptp and for the kernel?

Cross toolchains built for Linux always include header files. If you
want to use the headers from the toolchain, just set CROSS_COMPILE and
KBUILD_OUTPUT appropriately.  Examples:

   # arm 32 bit:
   LINARO=gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
   export CROSS_COMPILE=/opt/x-tools/$LINARO/bin/arm-linux-gnueabihf-
   export KBUILD_OUTPUT=/opt/x-tools/$LINARO/arm-linux-gnueabihf/libc

   # arm 64 bit:
   LINARO=gcc-linaro-6.5.0-2018.12-x86_64_aarch64-linux-gnu
   export CROSS_COMPILE=/opt/x-tools/$LINARO/bin/aarch64-linux-gnu-
   export KBUILD_OUTPUT=/opt/x-tools/$LINARO/aarch64-linux-gnu/libc

   # bonus: native compile with older kernel headers:
   cd ~/git/linux
   git checkout v3.0
   make INSTALL_HDR_PATH=~/build/linuxptp/l3oh headers_install
   export KBUILD_OUTPUT=~/build/linuxptp/l3oh

If you want to cross compile your own kernel and use its headers, then
have your build system install the kernel headers, like:

   make INSTALL_HDR_PATH=/path/in/staging/area headers_install

and then set KBUILD_OUTPUT to that path for the linuxptp recipe.
Example from the the SLIM build system:

   
https://github.com/richardcochran/slim/blob/6fa2d2edc552409f0f6d2bd811259fe933646892/pkg/linux/makefile#L73

Thanks,
Richard




_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to