From 493a903252056327928cf4fab49fe54fd64b67ed Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Wed, 20 Jun 2018 09:31:45 +0200
Subject: [PATCH] Make sure same method produces bit-equal source code

- defined ordering of headers
- lbm split kernels produced different ordering of assignments due to
  usage of a set
---
 cpu/cpujit.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/cpu/cpujit.py b/cpu/cpujit.py
index c5fddc2c3..f78c22dd2 100644
--- a/cpu/cpujit.py
+++ b/cpu/cpujit.py
@@ -175,7 +175,8 @@ def read_config():
     create_folder(config['cache']['object_cache'], False)
 
     if 'env' not in config['compiler']:
-        config['compiler']['env'] = {}
+        shutil.rmtree(config['cache']['object_cache'], ignore_errors=True)
+        create_folder(config['cache']['object_cache'], False)
 
     if config['compiler']['os'] == 'windows':
         from pystencils.cpu.msvc_detection import get_environment
@@ -413,11 +414,14 @@ class ExtensionModuleCode:
         self._function_names.append(name if name is not None else ast.function_name)
 
     def write_to_file(self, restrict_qualifier, function_prefix, file):
-        headers = {'<math.h>', '<stdint.h>', '"Python.h"'}
+        headers = {'<math.h>', '<stdint.h>'}
         for ast in self._ast_nodes:
             headers.update(get_headers(ast))
+        header_list = list(headers)
+        header_list.sort()
+        header_list.insert(0, '"Python.h"')
 
-        includes = "\n".join(["#include %s" % (include_file,) for include_file in headers])
+        includes = "\n".join(["#include %s" % (include_file,) for include_file in header_list])
         print(includes, file=file)
         print("\n", file=file)
         print("#define RESTRICT %s" % (restrict_qualifier,), file=file)
-- 
GitLab