AM62P: Cross-compiling kmscube with linux-sdk-11.00.09.04: ld cannot find crt1.o/crti.o/crtbegin.o

Part Number: AM62P

Tool/software:

Hi, 

I try to cross-compile kmscube with linux-sdk-11.00.09.04 and run the exe on EVM. The kmscube source code is pulled from its official website (Mesa / kmscube · GitLab) and I did not make any adjustments. Kmscube is based on meson build system and I wrote a cross-compile script "arm_cc.txt" to configure compiling tool-chains and rootfs related with linux-sdk.  I attach "arm_cc.txt" below.

[binaries]
c = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc'
cpp = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++'
ar = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ar'
strip = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-strip'
ld = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ld'
pkgconfig = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/x86_64-arago-linux-gnu-pkg-config'
# pkgconfig has two options

[properties]
skip_sanity_check = true
sys_root = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux'
pkg_config_libdir = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux/usr/lib/pkgconfig:/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux/usr/share/pkgconfig'

[built-in options]
c_args = ['--sysroot', '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux']
c_link_args = ['-Wl,-rpath', '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux/usr/lib', '-Wl,--as-needed']

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'armv8-a'
endian = 'little'

When implement cross-compiling, I  firstly use command "meson setup --cross-file arm_cc.txt build" to configure the cross-compiling environment. The relevant log is attached below.

Then I use command "cd build/ " , "meson compile" to build. The error log appears here saying "cannot find crt1.o, crti.o, crtbegin.o". The relevant error log is attached below.

Referring to linux-sdk, I did find crt1.o/crti.o through path "/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/lib". I wonder why this error occurs after I configured the system-root path.

  • Hi,

    I am able to compile kmscube on my target EVM. 

    Here are the steps that I followed:

    1. On the EVM, we cloned the following repo:  https://gitlab.freedesktop.org/mesa/kmscube
    2. Next, cd into kmscube directory
    3. Run meson setup build/ and ninja -C build/
    4. cd into the build directory
    5. run the command: ./kmscube

    Let me know if you have any issues compiling it on the target?

    Best Regards,

    Suren

  • Hi Suren,

    I want to declare that I am trying to cross-compile kmscube on a x86 linux PC and then load the exe into EVM and finally I could run the exe on EVM. I think the process you described above is native-compiling not cross-compiling. The reason I insist to use cross-compiling rather than native-compiling  is our client ask us to provide a cross-compiling environment.

    BR,

    Bomiao

  •  Hi All,

    Now I am able to cross-compile kmscube in linux. The build machine is x86_64 linux with Ubuntu 22.04 virtual machine and the host machine is armv8-a (EVM). The cross compile file for meson is attached below.

    [binaries]
    c = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc'
    cpp = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++'
    ar = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ar'
    strip = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-strip'
    ld = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-ld'
    pkgconfig = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/pkg-config'
    
    [properties]
    skip_sanity_check = true
    sys_root = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux'
    pkg_config_libdir = '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux/usr/lib/pkgconfig:/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux/usr/share/pkgconfig'
    
    [built-in options]
    c_args = ['--sysroot', '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux']
    c_link_args = ['--sysroot', '/home/fanbm1/ti-processor-sdk-linux-am62pxx-evm-11.00.09.04/linux-devkit/sysroots/aarch64-oe-linux']
    
    [host_machine]
    system = 'linux'
    cpu_family = 'aarch64'
    cpu = 'armv8-a'
    endian = 'little'
    
    
    

    Referring to the question "ld cannot find crt1.o/crti.o/crtbegin.o", I solved this via specifying the system root of ld in "built-in options". Additionally, the environment variables related to system root path in linux-sdk (both "../linux-devkit/sysroots/aarch64-oe-linux" and "../linux-devkit/sysroots/x86_64-arago-linux") need to be exported before you start meson build process. 

     In this post, I just want to share my solution and I hope this would be helpful when other developers encounter similar problems in the future.

    This thread can be closed.

    Cheers,

    Bomiao