Control: tags -1 upstream patch
Running the affected files through llvm-bcanalyzer says the difference
is in the ordering of OPENCL_EXTENSION_TYPES, and this makes sense as
these are stored in a hash map (i.e. unordered):
http://sources.debian.net/src/llvm-toolchain-5.0/1:5.0%7E%2Brc2-1/clang/lib/Serialization/ASTWriter.cpp/?hl=4156#L4151
http://sources.debian.net/src/llvm-toolchain-5.0/1:5.0%7E%2Brc2-1/clang/include/clang/Sema/Sema.h/?hl=8408#L8402
This suggests the attached patch, but this has *not* been tested as llvm
is currently BD-Uninstallable.
It also implies that the affected versions are clang 4.0 and later
(since https://reviews.llvm.org/D21698 ), including current upstream,
but I haven't actually tested that. Hence, this particular issue
probably *isn't* the reason *current* beignet is unreproducible, but
will affect it after the planned llvm 3.x removal.
(Not related to this bug, but it looks weird that static_cast<unsigned>
is on I.first in WriteOpenCLExtensionType and on I.second in
WriteOpenCLExtensionDecl (and has been since this feature was first
added) - might be worth asking upstream why?)
Description: Make ordering of OPENCL_EXTENSION_TYPES reproducible
Author: Rebecca N. Palmer <rebecca_pal...@zoho.com>
Bug-Debian: https://bugs.debian.org/877359
Forwarded: no
--- llvm-toolchain-5.0-5.0.orig/clang/lib/Serialization/ASTWriter.cpp
+++ llvm-toolchain-5.0-5.0/clang/lib/Serialization/ASTWriter.cpp
@@ -4153,9 +4153,13 @@ void ASTWriter::WriteOpenCLExtensionType
return;
RecordData Record;
+ // Sort to allow reproducible .pch files - https://bugs.debian.org/877359
+ std::map<TypeID, std::set<std::string>> sortedOpenCLTypeExtMap;
for (const auto &I : SemaRef.OpenCLTypeExtMap) {
- Record.push_back(
- static_cast<unsigned>(getTypeID(I.first->getCanonicalTypeInternal())));
+ sortedOpenCLTypeExtMap[getTypeID(I.first->getCanonicalTypeInternal())]=I.second;
+ }
+ for (const auto &I : sortedOpenCLTypeExtMap) {
+ Record.push_back(static_cast<unsigned>(I.first));
Record.push_back(I.second.size());
for (auto Ext : I.second)
AddString(Ext, Record);
@@ -4168,8 +4172,12 @@ void ASTWriter::WriteOpenCLExtensionDecl
return;
RecordData Record;
+ std::map<DeclID, std::set<std::string>> sortedOpenCLDeclExtMap;
for (const auto &I : SemaRef.OpenCLDeclExtMap) {
- Record.push_back(getDeclID(I.first));
+ sortedOpenCLDeclExtMap[getDeclID(I.first)]=I.second;
+ }
+ for (const auto &I : sortedOpenCLDeclExtMap) {
+ Record.push_back(I.first);
Record.push_back(static_cast<unsigned>(I.second.size()));
for (auto Ext : I.second)
AddString(Ext, Record);