1From 7bef5b905abe36adfd4e4cc16bc830376f50e8f6 Mon Sep 17 00:00:00 2001
2From: Viktor Kleinik <vkleinik@cisco.com>
3Date: Sun, 7 Mar 2021 17:22:26 +0000
4Subject: [PATCH 04/10] Use BUILD_DATE to improve reproducibility
5
6The C preprocessor variable BUILD_DATE contains the actual
7build date or some reproducible value. It depends on whether
8SOURCE_DATE_EPOCH environment variable was set previously or not.
9In this way, reproducibility can be improved when needed.
10
11Upstream-Status: Backport [https://sourceforge.net/p/oprofile/oprofile/ci/864e02eab12cdc523b2dcd3f7b87a27abc16eefc/]
12Signed-off-by: Viktor Kleinik <vkleinik@cisco.com>
13---
14 libutil/op_version.c   | 2 +-
15 pe_counting/ocount.cpp | 4 ++--
16 pe_profiling/operf.cpp | 4 ++--
17 3 files changed, 5 insertions(+), 5 deletions(-)
18
19diff --git a/libutil/op_version.c b/libutil/op_version.c
20index 99a844e4..a257e9c4 100644
21--- a/libutil/op_version.c
22+++ b/libutil/op_version.c
23@@ -19,6 +19,6 @@ void show_version(char const * app_name)
24 {
25 	/* Do not change the version format: it is documented in html doc */
26 	printf("%s: " PACKAGE " " VERSION " compiled on "
27-	       __DATE__ " " __TIME__ "\n", app_name);
28+	       BUILD_DATE "\n", app_name);
29 	exit(EXIT_SUCCESS);
30 }
31diff --git a/pe_counting/ocount.cpp b/pe_counting/ocount.cpp
32index 2470745d..ae89fe61 100644
33--- a/pe_counting/ocount.cpp
34+++ b/pe_counting/ocount.cpp
35@@ -660,8 +660,8 @@ static int _process_ocount_and_app_args(int argc, char * const argv[])
36 			__print_usage_and_exit(NULL);
37 			break;
38 		case 'v':
39-			cout << argv[0] << ": " << PACKAGE << " " << VERSION << " compiled on " << __DATE__
40-			     << " " << __TIME__ << endl;
41+			cout << argv[0] << ": " << PACKAGE << " " << VERSION << " compiled on "
42+			     << BUILD_DATE << endl;
43 			exit(EXIT_SUCCESS);
44 			break;
45 		default:
46diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
47index 00834409..f0f9c209 100644
48--- a/pe_profiling/operf.cpp
49+++ b/pe_profiling/operf.cpp
50@@ -1342,8 +1342,8 @@ static int _process_operf_and_app_args(int argc, char * const argv[])
51 			__print_usage_and_exit(NULL);
52 			break;
53 		case 'v':
54-			cout << argv[0] << ": " << PACKAGE << " " << VERSION << " compiled on " << __DATE__
55-			     << " " << __TIME__ << endl;
56+			cout << argv[0] << ": " << PACKAGE << " " << VERSION << " compiled on "
57+			     << BUILD_DATE << endl;
58 			exit(EXIT_SUCCESS);
59 			break;
60 		default:
61--
622.31.0
63
64