6 years, 9 months ago.

time_t is broken with 2017-q4 releas of gcc tool chain - workaround needed

with gcc-arm-none-eabi-7-2017-q4-major the default typedef of time_t is "long long int". older releases typedef time_t as "long int". mbed lib cannot handle this correctly which causes ctime() localtime() gmtime() to generate bogus results

This applies to exported projects as "GCC (ARM-Embedded)" compiling with GNU Tools for Arm Embedded Processors 7-2017-q4-major 7.2.1 20170904 (release) A testcase is here: https://os.mbed.com/users/bomilkar/code/Testcase_RTC/

sizeof(time_t) results 8 in the 2017-q4 release. With earlier versions the result is 4.

I think this might also affect other functions using time_t (such as file systems).

A (clean) workaround is badly needed.

The obvious answer would seem to be don't use GCC 7, use something earlier. Last I heard the latest mbed only supports up to GCC 6. Slightly older versions (like mbed 5.4) required gcc 4.9. It is completely expected that a project like mbed will take time up update to newer versions.

posted by Graham S. 08 Feb 2018

Interesting! Do you happen to know if/when gcc 7 will be supported? However, "not supported" is not equivalent to "not working". In the case of time_t there is a "#define _USE_LONG_TIME_T" which impacts the typedef as expected, but the functions (ctime(), ...) still don't work. To be honest, I don't understand what's coming from mbed and what is coming with gcc. I was hoping to get some insights to be able to understand and fix the issue. I assume functions such as time(), ctime(), ... are part of (the new) gcc and call functions from the mbed library. But I don't know where to look. Maybe somebody can point me to the right place.

posted by Ronald Niederhagen 09 Feb 2018

Mbed uses stdlib that comes with the compiler; so time.h will come from there. I'll assume this will be fixed when GCC7 will be supported.

posted by Jan Jongboom 12 Feb 2018

How do I know which gcc version is supported/required with a given version of mbed?

posted by Ronald Niederhagen 12 Feb 2018

I'm not sure this is the right place for suggestions like this. Wouldn't it be appropriate to add a gcc version check in one of the (automatically generated) header files? Something like this:

  1. if GNUC != 6
  2. warning expecting GCC version 6
  3. endif
posted by Ronald Niederhagen 22 Feb 2018

1 Answer

5 years, 7 months ago.

this is still broken with mbed 5.12 as of today and using gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu118.04)