zephyr/scripts
Marc Herbert 725abdf430 gen_app_partitions.py: make generated/app_smem_*.ld files deterministic
Dictionaries are not ordered in Python 3.5 and before, so building twice
in a row could lead to a different partition order, different
build/zephyr/include/generated/app_smem_*.ld files and different
binaries.

Fix with a minor change to the "for" loop in the output function:
make it iterate on sorted(partitions.items()) instead of the raw and
randomly ordered partitions dictionary.

It is easy to reproduce the issue even without downgrading to an
obsolete Python version; pick a test like samples/userspace/shared_mem/
and simply change the code to this:

--- a/scripts/gen_app_partitions.py
+++ b/scripts/gen_app_partitions.py
@@ -159,10 +159,12 @@ def parse_elf_file(partitions):
                     partitions[partition_name][SZ] += size

+import random
 def generate_final_linker(linker_file, partitions):
     string = linker_start_seq
     size_string = ''
-    for partition, item in sorted(partitions.items()):
+    for partition, item in sorted(partitions.items(),
+                                  key=lambda x: random.random()):
         string += data_template.format(partition)
         if LIB in item:
             for lib in item[LIB]:

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-06-27 07:18:09 -04:00
..
checkpatch
ci
coccinelle
dts
footprint
gitlint
kconfig
sanity_chk
support
west_commands
.gitignore
check_link_map.py
checkpatch.pl
checkstack.pl
coccicheck
dir_is_writeable.py
elf_helper.py
file2hex.py
filter-known-issues.py
gen_app_partitions.py gen_app_partitions.py: make generated/app_smem_*.ld files deterministic 2019-06-27 07:18:09 -04:00
gen_cfb_font_header.py
gen_gcov_files.py
gen_kobject_list.py
gen_offset_header.py
gen_priv_stacks.py
gen_relocate_app.py
gen_syscall_header.py
gen_syscalls.py
mergehex.py
parse_syscalls.py
process_gperf.py
qemu-machine-hack.py
requirements.txt
sanitycheck
series-push-hook.sh
spelling.txt
subfolder_list.py
tags.sh
valgrind.supp
waitpid
west-commands.yml
zephyr_module.py