Skip to content

Commit d5b2834

Browse files
marc-hbnashif
authored andcommitted
scripts/*syscalls.py: sort os.walk() for a more deterministic build
Found by "disordered --shuffle-dirents=yes". Sorting os.walk() in scripts/subfolder_list.py removes the randomness in the following files: build/zephyr/misc/generated/syscalls_subdirs.txt build/zephyr/CMakeFiles/syscall_list_h_target.dir/ or build.ninja Sorting os.walk() in scripts/parse_syscalls.py removes the randomness in: build/zephyr/misc/generated/syscalls.json build/zephyr/include/generated/syscall_dispatch.c build/zephyr/include/generated/syscall_list.h Note my (limited so far) testing did *not* observe any randomness in any object file that this would address; the main purpose here is to remove a very large amount of noise in diffoscope. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent e6393dd commit d5b2834

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

scripts/parse_syscalls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def analyze_headers(multiple_directories):
2323
ret = []
2424

2525
for base_path in multiple_directories:
26-
for root, dirs, files in os.walk(base_path):
26+
for root, dirs, files in os.walk(base_path, topdown=True):
27+
dirs.sort()
28+
files.sort()
2729
for fn in files:
2830

2931
# toolchain/common.h has the definition of __syscall which we
@@ -52,7 +54,9 @@ def parse_args():
5254
formatter_class=argparse.RawDescriptionHelpFormatter)
5355

5456
parser.add_argument("-i", "--include", required=True, action='append',
55-
help="Base include directory")
57+
help='''include directories recursively scanned
58+
for .h files. Can be specified multiple times:
59+
-i topdir1 -i topdir2 ...''')
5660
parser.add_argument(
5761
"-j", "--json-file", required=True,
5862
help="Write system call prototype information as json to file")

scripts/subfolder_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def main():
4545
else:
4646
dirlist.extend(args.directory)
4747
dirlist.extend(os.linesep)
48-
for root, dirs, files in os.walk(args.directory):
48+
for root, dirs, _ in os.walk(args.directory, topdown=True):
49+
dirs.sort()
4950
for subdir in dirs:
5051
if(args.create_links is not None):
5152
directory = os.path.join(root, subdir)

0 commit comments

Comments
 (0)