Hello Lianbo
Thanks for your review.
In the patch, we don't expect the CC env to be always defined, this is tested with "if(NULL == cc_env)", in the case it is not defined, we retrieve the compiler version like it was done before with a call to "gcc --version" and if it is defined we replace "gcc" by the content of CC env variable (binary to the compiler actually used for compilation, not necessarily the native gcc installed on the host machine).
I have looked at GDB_CONF_FLAGS, but from what I understand ,it defines the target architecture (arm, x86, MIPS...) not the compiler version:
#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
#define GDB_TARGET_ARM_ON_X86 "GDB_CONF_FLAGS=--target=arm-elf-linux"
#define GDB_TARGET_ARM_ON_X86_64 "GDB_CONF_FLAGS=--target=arm-elf-linux CFLAGS=-m32 CXXFLAGS=-m32"
#define GDB_TARGET_X86_ON_X86_64 "GDB_CONF_FLAGS=--target=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32"
#define GDB_TARGET_PPC_ON_PPC64 "GDB_CONF_FLAGS=--target=ppc-elf-linux CFLAGS=-m32 CXXFLAGS=-m32"
#define GDB_TARGET_ARM64_ON_X86_64 "GDB_CONF_FLAGS=--target=aarch64-elf-linux" /* TBD */
#define GDB_TARGET_PPC64_ON_X86_64 "GDB_CONF_FLAGS=--target=powerpc64le-unknown-linux-gnu"
#define GDB_TARGET_MIPS_ON_X86 "GDB_CONF_FLAGS=--target=mipsel-elf-linux"
#define GDB_TARGET_MIPS_ON_X86_64 "GDB_CONF_FLAGS=--target=mipsel-elf-linux CFLAGS=-m32 CXXFLAGS=-m32"
#define GDB_TARGET_RISCV64_ON_X86_64 "GDB_CONF_FLAGS=--target=riscv64-unknown-linux-gnu"
#define GDB_TARGET_LOONGARCH64_ON_X86_64 "GDB_CONF_FLAGS=--target=loongarch64-unknown-linux-gnu"
The end result of this patch is to correct the value of variable "char *compiler_version" defined in generated file build_data.c, this value depends on the compiler used in compilation.
Examples:
- When building with the native gcc compiler install on my host machine running with Ubuntu:
char *compiler_version = "gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
- When building with the generated compiler (not the native gcc) used on the Yocto project for a x86 machine:
char *compiler_version = "x86_64-poky-linux-gcc (GCC) 15.1.0";
- When building with the native gcc compiler install on a host machine running with a Red Hat system:
char·*compiler_version·=·"gcc·(GCC)·11.4.1·20231218·(Red·Hat·11.4.1-3)";
Best regards
Kéléfa Sané