In Python, dictionaries and sets are unordered, and as a result their is no guarantee that running this script twice will produce the same output.
Using ordered dicts and explicitly sorting items makes the build more reproducible, and will make it possible to verify that we're not breaking anything when we move the build scripts to Python 3. --- src/amd/common/sid_tables.py | 2 +- src/compiler/nir/nir_algebraic.py | 3 ++- src/compiler/nir/nir_opt_algebraic.py | 3 ++- src/mapi/glapi/gen/glX_proto_size.py | 2 +- src/mapi/glapi/gen/gl_XML.py | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py index 4e53acefa4..ca90f82535 100644 --- a/src/amd/common/sid_tables.py +++ b/src/amd/common/sid_tables.py @@ -65,7 +65,7 @@ class StringTable: fragments = [ '"%s\\0" /* %s */' % ( te[0].encode('string_escape'), - ', '.join(str(idx) for idx in te[2]) + ', '.join(str(idx) for idx in sorted(te[2])) ) for te in self.table ] diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index d6784df004..847c59dbd8 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -25,6 +25,7 @@ from __future__ import print_function import ast +from collections import OrderedDict import itertools import struct import sys @@ -601,7 +602,7 @@ ${pass_name}(nir_shader *shader) class AlgebraicPass(object): def __init__(self, pass_name, transforms): - self.xform_dict = {} + self.xform_dict = OrderedDict() self.pass_name = pass_name error = False diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index db907df854..2f1cba398f 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -23,6 +23,7 @@ # Authors: # Jason Ekstrand (ja...@jlekstrand.net) +from collections import OrderedDict import nir_algebraic import itertools @@ -628,7 +629,7 @@ optimizations = [ 'options->lower_unpack_snorm_4x8'), ] -invert = {'feq': 'fne', 'fne': 'feq', 'fge': 'flt', 'flt': 'fge' } +invert = OrderedDict([('feq', 'fne'), ('fne', 'feq'), ('fge', 'flt'), ('flt', 'fge')]) for left, right in list(itertools.combinations(invert.keys(), 2)) + zip(invert.keys(), invert.keys()): optimizations.append((('inot', ('ior(is_used_once)', (left, a, b), (right, c, d))), diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index e16dbab3e0..8dbb0af86d 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -191,7 +191,7 @@ class glx_enum_function(object): print ' switch( e ) {' - for c in self.count: + for c in sorted(self.count): for e in self.count[c]: first = 1 diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index a5320e90a1..1bab5fee51 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -24,6 +24,7 @@ # Authors: # Ian Romanick <i...@us.ibm.com> +from collections import OrderedDict from decimal import Decimal import xml.etree.ElementTree as ET import re, sys, string @@ -861,7 +862,7 @@ class gl_item_factory(object): class gl_api(object): def __init__(self, factory): - self.functions_by_name = {} + self.functions_by_name = OrderedDict() self.enums_by_name = {} self.types_by_name = {} -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev