Source the SDK environment-setup script before building
Set up the cross-build environment from a Yocto SDK by sourcing its environment-setup script, and see what it exports in the shell.
The SDK installer unpacks a toolchain and a sysroot. A single script puts them on your path, and every build that follows depends on it.
source /opt/poky/5.0/environment-setup-cortexa72-poky-linux
echo "$CC"
echo "$ARCH $CROSS_COMPILE"aarch64-poky-linux-gcc -mcpu=cortex-a72 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 --sysroot=/opt/poky/5.0/sysroots/cortexa72-poky-linux
arm64 aarch64-poky-linux-The script is named after the target and exists once per SDK. The path and flags match a Yocto 5.0 (Scarthgap) SDK for a Cortex-A72 machine and differ with your build. It exports CC, CXX, LD, CFLAGS, LDFLAGS, PKG_CONFIG_SYSROOT_DIR, ARCH and CROSS_COMPILE, so a Makefile or the kernel build that honors those variables cross-compiles without more arguments.
You have to source it in each new shell, because it only sets environment variables for that shell. Do not source it in the shell where you run host builds, since CC would then point at the cross compiler for the next make. Use unset or a new terminal to leave. See the Yocto SDK manual.