This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Keystone2: gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux toolchain

Expert 1800 points

Hello,

We are using   linaro tool chain as recommended in MCSDK UG wiki.

We see weird effects in some 64 bit calculations.  We compile with gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/arm-linux-gnueabihf-g++ with flags "-Os -Wall -std=c++11".  Compiling it with -O2 fails as well, but -O1 works.

It would be nice to know if you had any such experience with this compiler.  Do you have any recommendations for using the optimization flags with this compiler?

Please advice.

Thanks

Rams

  • Hi Rams,

    As it is known the "-O2" optimization option adds wide list of optimization flags which are described in the g++ man page:
    http://linux.die.net/man/1/g++
    Probably one or more added flags are incompatible with the 64 bit calculations but could you specify what exact operation causing the issue.
    Also could try to some newer gcc-linaro version? (For example: Linaro GCC 4.9-2015.05 or gcc-linaro-5.1-2015.08)

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev,

    Thanks for your response.   If you see below piece of code, compiling with O2 or Os gives weird results for below operation whereas compiling with O1 seem to work.  If we remove inline from foo that also helps.  

    20000 + -27 = 115964136965

    #include <cstdio>
    #include <cstdlib>
    #include <cstdint>
    
    // remove "inline" and it works
    inline int64_t foo(const int64_t a, const int64_t b)
    {
        int64_t res = a + b;
        printf("%lld + %lld = %lld\n", a, b, res);
        return res;
    }
    
    uint64_t bar(uint32_t a, uint32_t b, uint64_t c)
    {
        int32_t diff = a - b;
    
        int64_t diff27 = static_cast<int64_t>(diff) * 27;
        //int64_t diff27 = static_cast<int64_t>(diff) - 26; // swap with this and it works
    
        int64_t e = foo(c,diff27);
    
        return e;
    }
    
    int main(int argc, char** argv)
    {
        uint32_t a = atoi(argv[1]);
        uint32_t b = atoi(argv[2]);
        uint64_t c = atoi(argv[3]);
    
        bar(a,b,c);
    
        return 0;
    }

    We were considering to upgrade the gcc-linaro version.  We tested this piece of code with linaro 5.2 and it had no problems.  But we feel it might be risky to upgrade compiler for this release cycle.  We have not upgraded to newest compiler as TI MCSDK development wiki recommends to use 4.7 version and this is the version shipped with MCSDK.  Are there any specific reason why TI is still using 4.7 version? 

    Regards

    Rams

  • Rams,

    According to history of the "MCSDK UG Chapter Tools" article the recommendation of gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313 is add at 26 April 2013 when this was the latest gcc-linaro-arm-linux-gnueabihf version. I think this is the reason why 4.7 version recommended in the article.

    BR
    Tsvetolin Shulev