[SERVER-80926] Omit compile timestamp data from C++ macros to improve repeatability of binary artifacts Created: 08/Sep/23  Updated: 29/Oct/23  Resolved: 11/Sep/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Zack Winter Assignee: Zack Winter
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

If we rebuild without changes we want the hash to remain the same. There are C++ macros that are able to pull the timestamp of when the compile is executed that would result in different hashes for the same code.

For example if I build on Sep 8 2023 and a library we depend on uses the "printf("Compiled on %s", _DATE_)", that will expand to "printf("Compiled on %s", "Sep 8 2023")" in the binary image. This will cause the hash of the binary to change if the same code is compiled tomorrow.

The ability to know if the code that was used to compile a binary is the same is convenient in many scenarios. For example, it could be useful if you want to quickly check which host systems contain a binary that has a known vulnerability.

Pass in the compiler options to disable these when compiling with the Bazel toolchain.



 Comments   
Comment by Githook User [ 09/Sep/23 ]

Author:

{'name': 'Zack Winter', 'email': 'zack.winter@mongodb.com', 'username': 'zackwintermdb'}

Message: SERVER-80926 Omit compile timestamp data from C++ macros in bazel
Branch: master
https://github.com/mongodb/mongo/commit/afc6e8492acbdf4ed11221ae786935788971aadb

Generated at Thu Feb 08 06:44:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.