This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timestamp of compilation

I was searching for a way to include a timestamp in during compilation/preprocessing.
I found the famous __DATE__ and __TIME__, however these are not suitable for version control, because the timezone is missing and they are written in humans.

Is there any standard way the toolchain can put a iso8601 (utc) or unix timestamp into the firmware?

Parents
  • however these are not suitable for version control, because the timezone is missing and they are written in humans.

    No form of time stamp is actually suitable for version control, because there's really no way of knowing who compiled what set of sources, with what collection of local, one-time modifications. Putting a time-stamp on such a hodge-podge collection of source code doesn't constitute version control in any meaningful way.

    It doesn't matter at all when a set of sources was compiled; the task instead is to make sure what was compiled. You need to be able to retrieve the exact same set of source files (and tool versions) at any later time, so you can recreate the same executable. Compilation timestamps don't help with the former, and wreak havoc with the latter. Forget them.

Reply
  • however these are not suitable for version control, because the timezone is missing and they are written in humans.

    No form of time stamp is actually suitable for version control, because there's really no way of knowing who compiled what set of sources, with what collection of local, one-time modifications. Putting a time-stamp on such a hodge-podge collection of source code doesn't constitute version control in any meaningful way.

    It doesn't matter at all when a set of sources was compiled; the task instead is to make sure what was compiled. You need to be able to retrieve the exact same set of source files (and tool versions) at any later time, so you can recreate the same executable. Compilation timestamps don't help with the former, and wreak havoc with the latter. Forget them.

Children
  • Correct.
    But people keep sharing firmware without updating #define VERSION x.x.x.x...
    Then you have conversations about version 5 new and version 5 old... not the best way.
    That why I think the build number or utc build time is a safer way to fix this, since anyone/anything can read this.

    Yet, this seemingly missing feature from compilers could easily be replaced by a call to a third party program or script. If people keep that option enabled in the configuration...
    That script could also insert the parent git hash, so there is some track of the sources.

  • So do that, then!

    Look at the "pre-build step" options...