[clang] [SystemZ] Set source date epoch in clang lit tests for z/OS (PR #238545)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 14:00:06 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-modules

Author: Sean Perry (perry-ca)

<details>
<summary>Changes</summary>

All of these tests run two compiles and then compare the output.  The IR for z/OS includes a timestamp.  That can cause the compares to fail.  Add the source epoch option to ensure the compares don't fail because of the time stamp.

---
Full diff: https://github.com/llvm/llvm-project/pull/238545.diff


7 Files Affected:

- (modified) clang/test/DebugInfo/CXX/determinism.cpp (+2-2) 
- (modified) clang/test/Frontend/ast-main.c (+2-2) 
- (modified) clang/test/Frontend/ast-main.cpp (+2-2) 
- (modified) clang/test/Frontend/ir-support.c (+5-5) 
- (modified) clang/test/Modules/empty.modulemap (+2-2) 
- (modified) clang/test/PCH/designated-init.c (+2-2) 
- (modified) clang/test/VFS/output-file-permissions.c (+2-2) 


``````````diff
diff --git a/clang/test/DebugInfo/CXX/determinism.cpp b/clang/test/DebugInfo/CXX/determinism.cpp
index c0a70a09c95db0..f413f9bc16ed22 100644
--- a/clang/test/DebugInfo/CXX/determinism.cpp
+++ b/clang/test/DebugInfo/CXX/determinism.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o %t1.ll %s
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -o %t2.ll %s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -emit-llvm -debug-info-kind=limited -o %t1.ll %s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -emit-llvm -debug-info-kind=limited -o %t2.ll %s
 // RUN: diff %t1.ll %t2.ll
 
 template <int N> struct C {
diff --git a/clang/test/Frontend/ast-main.c b/clang/test/Frontend/ast-main.c
index 6a64497f4109ca..ff5991c03c9c5b 100644
--- a/clang/test/Frontend/ast-main.c
+++ b/clang/test/Frontend/ast-main.c
@@ -1,6 +1,6 @@
-// RUN: env SDKROOT="/" %clang -emit-llvm -S -o - -x c - < %s | grep -v DIFile > %t1.ll
+// RUN: env SDKROOT="/" %clang -Xclang -source-date-epoch -Xclang 1613676318 -emit-llvm -S -o - -x c - < %s | grep -v DIFile > %t1.ll
 // RUN: env SDKROOT="/" %clang -emit-ast -o %t.ast %s
-// RUN: env SDKROOT="/" %clang -emit-llvm -S -o - -x ast - < %t.ast | grep -v DIFile > %t2.ll
+// RUN: env SDKROOT="/" %clang -Xclang -source-date-epoch -Xclang 1613676318 -emit-llvm -S -o - -x ast - < %t.ast | grep -v DIFile > %t2.ll
 // RUN: diff %t1.ll %t2.ll
 
 int main(void) {
diff --git a/clang/test/Frontend/ast-main.cpp b/clang/test/Frontend/ast-main.cpp
index fc09e6437f93f1..ea4ce52e01a509 100644
--- a/clang/test/Frontend/ast-main.cpp
+++ b/clang/test/Frontend/ast-main.cpp
@@ -1,6 +1,6 @@
-// RUN: env SDKROOT="/" %clang -Wno-error=return-type -emit-llvm -S -o - -x c++ - < %s | grep -v DIFile > %t1.ll
+// RUN: env SDKROOT="/" %clang -Wno-error=return-type -Xclang -source-date-epoch -Xclang 1613676318 -emit-llvm -S -o - -x c++ - < %s | grep -v DIFile > %t1.ll
 // RUN: env SDKROOT="/" %clang -Wno-error=return-type -fno-delayed-template-parsing -emit-ast -o %t.ast %s
-// RUN: env SDKROOT="/" %clang -Wno-error=return-type -emit-llvm -S -o - -x ast - < %t.ast | grep -v DIFile > %t2.ll
+// RUN: env SDKROOT="/" %clang -Wno-error=return-type -Xclang -source-date-epoch -Xclang 1613676318 -emit-llvm -S -o - -x ast - < %t.ast | grep -v DIFile > %t2.ll
 // RUN: diff %t1.ll %t2.ll
 
 // http://llvm.org/bugs/show_bug.cgi?id=15377
diff --git a/clang/test/Frontend/ir-support.c b/clang/test/Frontend/ir-support.c
index d0c7dfa418cad2..c69c04ee341e52 100644
--- a/clang/test/Frontend/ir-support.c
+++ b/clang/test/Frontend/ir-support.c
@@ -4,16 +4,16 @@
 // We strip differing '.file' directives before comparing.
 
 // Reference output:
-// RUN: %clang_cc1 -S -o - %s | grep -v '\.file' > %t.s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -S -o - %s | grep -v '\.file' > %t.s
 
 // LLVM bitcode:
-// RUN: %clang_cc1 -emit-llvm-bc -o %t.bc %s
-// RUN: %clang_cc1 -S -o - %t.bc | grep -v '\.file' > %t.bc.s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -S -o - %t.bc | grep -v '\.file' > %t.bc.s
 // RUN: diff %t.s %t.bc.s
 
 // LLVM IR source code:
-// RUN: %clang_cc1 -emit-llvm -o %t.ll %s
-// RUN: %clang_cc1 -S -o - %t.ll | grep -v '\.file' > %t.ll.s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -emit-llvm -o %t.ll %s
+// RUN: %clang_cc1 -source-date-epoch 1613676318 -S -o - %t.ll | grep -v '\.file' > %t.ll.s
 // RUN: diff %t.s %t.ll.s
 
 int f(void) { return 0; }
diff --git a/clang/test/Modules/empty.modulemap b/clang/test/Modules/empty.modulemap
index 8cad8b67b91155..5cee31da19103f 100644
--- a/clang/test/Modules/empty.modulemap
+++ b/clang/test/Modules/empty.modulemap
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t
 //
 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
-// RUN:   -fno-implicit-modules \
+// RUN:   -fno-implicit-modules -source-date-epoch 1613676318 \
 // RUN:   -emit-module -fmodule-name=empty -o %t/base.pcm \
 // RUN:   %s
 //
 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
-// RUN:   -fno-implicit-modules \
+// RUN:   -fno-implicit-modules -source-date-epoch 1613676318 \
 // RUN:   -emit-module -fmodule-name=empty -o %t/check.pcm \
 // RUN:   %s
 //
diff --git a/clang/test/PCH/designated-init.c b/clang/test/PCH/designated-init.c
index beb4dffe6144bf..7050bb82507c5e 100644
--- a/clang/test/PCH/designated-init.c
+++ b/clang/test/PCH/designated-init.c
@@ -1,7 +1,7 @@
 // Test this without pch.
-// RUN: %clang_cc1 %s -include %s.h -emit-llvm -o %t.withoutpch.ll
+// RUN: %clang_cc1 -source-date-epoch 1613676318 %s -include %s.h -emit-llvm -o %t.withoutpch.ll
 
 // Test with pch.
 // RUN: %clang_cc1 %s.h -emit-pch -o %t.pch
-// RUN: %clang_cc1 %s -include-pch %t.pch -emit-llvm -o %t.withpch.ll
+// RUN: %clang_cc1 -source-date-epoch 1613676318 %s -include-pch %t.pch -emit-llvm -o %t.withpch.ll
 // RUN: diff %t.withoutpch.ll %t.withpch.ll
diff --git a/clang/test/VFS/output-file-permissions.c b/clang/test/VFS/output-file-permissions.c
index 4628024c031155..17bfd7ad25e630 100644
--- a/clang/test/VFS/output-file-permissions.c
+++ b/clang/test/VFS/output-file-permissions.c
@@ -4,13 +4,13 @@
 // rm -f %t-ref.o %t-readonly.o
 
 // Create a reference file
-// RUN: %clang -c %s -o %t-ref.o
+// RUN: env SOURCE_DATE_EPOCH=1789091336 %clang -c %s -o %t-ref.o
 
 // Compile something, mark the output as read-only and expect it to be replaced
 // (permission bits of the file itself are irrelevant)
 // RUN: touch %t-readonly.o
 // RUN: chmod 000 %t-readonly.o
-// RUN: %clang -c %s -o %t-readonly.o
+// RUN: env SOURCE_DATE_EPOCH=1789091336 %clang -c %s -o %t-readonly.o
 // RUN: cmp %t-ref.o %t-readonly.o
 
 void foo() {}

``````````

</details>


https://github.com/llvm/llvm-project/pull/238545


More information about the cfe-commits mailing list