Skip to content

Windows,C++: non-deterministic compilation because time/date macros are not redacted #5750

@laszlocsomor

Description

@laszlocsomor

Description of the problem / feature request:

The macros __DATE__, __TIME__, and __TIMESTAMP__ have the value "redacted" on Linux with GCC, but they are not overridden on Windows with MSVC.

This leads to non-deterministic compilation (i.e. compilation result depends on current date and time).

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  $ cat foo.cc
#include <stdio.h>

int main(void) {
  printf("__DATE__=(%s)\n__TIME__=(%s)\n__TIMESTAMP__=(%s)\n",
         __DATE__, __TIME__, __TIMESTAMP__);
  return 0;
}


  $ cat BUILD
cc_binary(
    name = "foo",
    srcs = ["foo.cc"],
)

On Linux:

  $ bazel run -c opt --nostamp //:foo
(...)
INFO: Build completed successfully, 6 total actions
__DATE__=(redacted)
__TIME__=(redacted)
__TIMESTAMP__=(redacted)

On Windows:

C:\src\tmp>bazel run -c opt --nostamp //:foo
(...)
INFO: Build completed successfully, 1 total action
__DATE__=(Aug  3 2018)
__TIME__=(09:28:07)
__TIMESTAMP__=(Fri Aug  3 09:27:28 2018)

What operating system are you running Bazel on?

Linux and Windows 10

What's the output of bazel info release?

  $ bazel info release
release 0.16.0

C:\src\tmp>bazel info release
release 0.16.0

Metadata

Metadata

Assignees

Labels

P3We're not considering working on this, but happy to review a PR. (No assignee)help wantedSomeone outside the Bazel team could own thisplatform: windowsstaleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions