script to get the version of the toolchain in use - Page 1
Forum section: electronics / general

author: legacy
author_rank: Super Contributor
timestamp: March 18, 2018, 02:11:30 pm
content: Code:cc=gccld=ldCode:# binutils versionbu_v="`$ld --version | head -n1 | cut -d" " -f4`"# gcc versioncc_v="`$cc -dumpversion`"is there a better way (to get the version of binutils)?

author: cv007
author_rank: Frequent Contributor
timestamp: March 18, 2018, 04:31:40 pm
content: Define better.echo $(ld -v)>/dev/null;bu_v=$_

author: andyturk
author_rank: Frequent Contributor
timestamp: March 18, 2018, 05:54:21 pm
content: Ideally, your build system should explicitly keep track of which toolchain it uses. E.g., here's part of a makefile I use:Code:BINUTILS_ROOT = /usr/local/arm/gcc-arm-none-eabi-7-2017-q4-major#BINUTILS_ROOT = /usr/local/arm/gcc-arm-none-eabi-6-2017-q1-update#BINUTILS_ROOT = /usr/local/arm/gcc-arm-none-eabi-5_4-2016q3You might want to use the toolchain/compiler info within the program too:Code:extern "C" char __init_array_start;extern "C" char __etext;extern "C" char __stext;extern "C" char __main_stack_base__;extern "C" char __data_start__;extern "C" char __data_end__;extern "C" char __bss_start__;extern "C" char __bss_end__;extern "C" char __fini_array_end;extern "C" uint32_t SystemCoreClock;extern "C" char __HeapBase;extern "C" char __HeapLimit;void InfoCommand::run(int argc, char **argv) {if (argc == 0) {printf("%-20s", _name);printf("-- toolchain/target information\r\n");} else {printf("system clock : %d MHz\r\n", SystemCoreClock / 1000000);#if defined(__VERSION__)printf("compiler version : " __VERSION__ "\r\n");#endif#if defined(__OPTIMIZE__)printf("optimization : on\r\n");#elseprintf("optimization : off\r\n");#endif#if defined(TARGET_MCU)printf("mcu : " TARGET_MCU "\r\n");#endif#if defined(ARCHITECTURE)printf("Architecture : %s\r\n", ARCHITECTURE);#endifprintf("git commit : %s\r\n", GIT_COMMIT);printf("git version : %s\r\n", GIT_VERSION);printf("app name : %s\r\n", APP_NAME);printf("compiled : %s\r\n", BUILD_TIME);printf("by : %s\r\n", APP_AUTHOR);kernel_version_t kernel_info;char buf;Kernel::get_info(kernel_info, buf, sizeof(buf));printf("RTX version : %s\r\n", buf);#define MEM(fmt, start, end) \printf(fmt " : %08x - %08x (%dK)\r\n", (start), (end), \(1023 + ((end) - (start))) >> 10)MEM(".text", &__stext, &__etext);MEM(".data", &__data_start__, &__data_end__);MEM(".bss ", &__bss_start__, &__bss_end__);MEM("heap ", &__HeapBase, &__HeapLimit);#undef MEM}}

author: legacy
author_rank: Super Contributor
timestamp: March 18, 2018, 06:22:04 pm
content: Quote from: andyturk on March 18, 2018, 05:54:21 pmyup. Ideally. I am building kernels for PPC32, PPC64, HPPA64, MIPS32, MIPS64, and each build needs to choose the right compiler, and to update the environmentCode:hppa2.0-unknown-linux-gnu-4.1.2hppa2.0-unknown-linux-gnu-4.2.4hppa2.0-unknown-linux-gnu-4.4.7hppa2.0-unknown-linux-gnu-4.9.3hppa2.0-unknown-linux-gnu-5.4.0hppa2.0-unknown-linux-gnu-6.4.0 *hppa64-unknown-linux-gnu-4.9.4hppa64-unknown-linux-gnu-6.4.0 *mips-unknown-linux-gnu-4.1.2mips-unknown-linux-gnu-5.3.0mips-unknown-linux-gnu-6.4.0 *mips64-unknown-linux-gnu-4.1.2mips64-unknown-linux-gnu-5.3.0 *mips64-unknown-linux-gnu-6.4.0powerpc-unknown-linux-gnu-4.1.2powerpc-unknown-linux-gnu-5.3.0powerpc-unknown-linux-gnu-6.4.0 *(binutils has a similar list)but I need to be sure each kernel is compiled by the right compiler; this information MUST be used by the script that builds the kernel, it must refuse to compile with the wrong toolchain, and it must report this information in a reportAll of these points, because I have engaged some friends to help me with the development & test, and I want to be sure they do their job in the right way

author: bson
author_rank: Unknown
timestamp: March 20, 2018, 04:39:07 am
content: You could md5sum the tree, e.g. tar -cf - -C $BUILD_ROOT gcc-arm-none-eabi-6-2017-q2-update | md5sum