Author Topic: script to get the version of the toolchain in use  (Read 1335 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
script to get the version of the toolchain in use
« on: March 18, 2018, 02:11:30 pm »
Code: [Select]
cc=gcc
ld=ld

Code: [Select]
# binutils version
bu_v="`$ld --version | head -n1 | cut -d" " -f4`"

# gcc version
cc_v="`$cc -dumpversion`"

is there a better way (to get the version of binutils)?  :-//
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 825
Re: script to get the version of the toolchain in use
« Reply #1 on: March 18, 2018, 04:31:40 pm »
Define better.

echo $(ld -v)>/dev/null;bu_v=$_
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: script to get the version of the toolchain in use
« Reply #2 on: March 18, 2018, 05:54:21 pm »
Ideally, your build system should explicitly keep track of which toolchain it uses. E.g., here's part of a makefile I use:

Code: [Select]
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-2016q3

You might want to use the toolchain/compiler info within the program too:

Code: [Select]
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");
#else
        printf("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);
#endif

        printf("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[30];

        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
    }
}
 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: script to get the version of the toolchain in use
« Reply #3 on: March 18, 2018, 06:22:04 pm »
Ideally, your build system should explicitly keep track of which toolchain it uses

yup. Ideally. I am building kernels for PPC32, PPC64, HPPA64, MIPS32, MIPS64, and each build needs to choose the right compiler, and to update the environment

Code: [Select]
hppa2.0-unknown-linux-gnu-4.1.2
hppa2.0-unknown-linux-gnu-4.2.4
hppa2.0-unknown-linux-gnu-4.4.7
hppa2.0-unknown-linux-gnu-4.9.3
hppa2.0-unknown-linux-gnu-5.4.0
hppa2.0-unknown-linux-gnu-6.4.0 *
hppa64-unknown-linux-gnu-4.9.4
hppa64-unknown-linux-gnu-6.4.0 *
mips-unknown-linux-gnu-4.1.2
mips-unknown-linux-gnu-5.3.0
mips-unknown-linux-gnu-6.4.0 *
mips64-unknown-linux-gnu-4.1.2
mips64-unknown-linux-gnu-5.3.0 *
mips64-unknown-linux-gnu-6.4.0
powerpc-unknown-linux-gnu-4.1.2
powerpc-unknown-linux-gnu-5.3.0
powerpc-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 report

All 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

 

Offline bson

  • Supporter
  • ****
  • Posts: 2269
  • Country: us
Re: script to get the version of the toolchain in use
« Reply #4 on: March 20, 2018, 04:39:07 am »
You could md5sum the tree, e.g.  tar -cf - -C $BUILD_ROOT gcc-arm-none-eabi-6-2017-q2-update | md5sum

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf