Skip to content

Commit

Permalink
scripts/*syscalls.py: sort os.walk() for a more deterministic build
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marc-hb authored and nashif committed Feb 17, 2019
1 parent e6393dd commit d5b2834
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions scripts/parse_syscalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def analyze_headers(multiple_directories):
ret = []

for base_path in multiple_directories:
for root, dirs, files in os.walk(base_path):
for root, dirs, files in os.walk(base_path, topdown=True):
dirs.sort()
files.sort()
for fn in files:

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

parser.add_argument("-i", "--include", required=True, action='append',
help="Base include directory")
help='''include directories recursively scanned
for .h files. Can be specified multiple times:
-i topdir1 -i topdir2 ...''')
parser.add_argument(
"-j", "--json-file", required=True,
help="Write system call prototype information as json to file")
Expand Down
3 changes: 2 additions & 1 deletion scripts/subfolder_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def main():
else:
dirlist.extend(args.directory)
dirlist.extend(os.linesep)
for root, dirs, files in os.walk(args.directory):
for root, dirs, _ in os.walk(args.directory, topdown=True):
dirs.sort()
for subdir in dirs:
if(args.create_links is not None):
directory = os.path.join(root, subdir)
Expand Down

0 comments on commit d5b2834

Please sign in to comment.