How to build from source a cross compiler and how to use it?

I’ve tried to build from source an ocaml cross compiler, which runs on x86-64 linux and generates codes for aarch64 linux. But things just don’t work well.

If anyone has ever done something similar, could you please share what you know?

Below are some details about my steps and the output.

  1. Build the cross compiler
    Pass the following options to ‘configure’:
    –build x86_64-linux --host x86_64-linux --target aarch64-wrs-linux
    export CC=‘gcc’
    make world.opt

(the above commands run successfully, but I’m not sure if the generated compiler is a working cross compiler)

  1. Use the cross compiler to build a helloworld program
    ocamlopt -cc ‘aarch64-wrs-linux-gcc -mcpu=cortex-a57 -march=armv8-a+crc -mbranch-protection=standard --sysroot=/PATH/TO/recipe-sysroot’ -o helloworld helloworld.ml

However, what I got is:
/PATH/TO/SYSROOT/usr/bin/aarch64-wrs-linux/…/…/libexec/aarch64-wrs-linux/gcc/aarch64-wrs-linux/12.3.0/ld: /tmp/camlstartupd48e18.o: Relocations in generic ELF (EM: 62)
/PATH/TO/SYSROOT/usr/bin/aarch64-wrs-linux/…/…/libexec/aarch64-wrs-linux/gcc/aarch64-wrs-linux/12.3.0/ld: /tmp/camlstartupd48e18.o: Relocations in generic ELF (EM: 62)
/PATH/TO/SYSROOT/usr/bin/aarch64-wrs-linux/…/…/libexec/aarch64-wrs-linux/gcc/aarch64-wrs-linux/12.3.0/ld: /tmp/camlstartupd48e18.o: Relocations in generic ELF (EM: 62)
/PATH/TO/SYSROOT/usr/bin/aarch64-wrs-linux/…/…/libexec/aarch64-wrs-linux/gcc/aarch64-wrs-linux/12.3.0/ld: /tmp/camlsta
rtupd48e18.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

Anyone has any clue? Thanks in advance.