diff options
author | Petr Hosek <phosek@chromium.org> | 2019-02-11 08:48:47 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2019-02-11 08:48:47 +0000 |
commit | 1405ac457b8b583215cf92d73fbe4479f7c86029 (patch) | |
tree | 61e8c6ac8706efd51eac7f763d82fc9279501580 /libcxx/utils/merge_archives.py | |
parent | 0cc50c6b87c42da96d8e10d56e9b09be71b95a3f (diff) | |
download | bcm5719-llvm-1405ac457b8b583215cf92d73fbe4479f7c86029.tar.gz bcm5719-llvm-1405ac457b8b583215cf92d73fbe4479f7c86029.zip |
[libcxx] Preserve order, avoid duplicates when merging static archives
glob can return files in arbitrary order which breaks deterministic
builds. Rather, use `ar t` to list the files in each archive and
preserve the original order. Using `ar q` results in duplicate entries
in the archive, instead use `ar r` to avoid duplicates.
Differential Revision: https://reviews.llvm.org/D58024
llvm-svn: 353671
Diffstat (limited to 'libcxx/utils/merge_archives.py')
-rwxr-xr-x | libcxx/utils/merge_archives.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libcxx/utils/merge_archives.py b/libcxx/utils/merge_archives.py index a307494d87a..e57afab201f 100755 --- a/libcxx/utils/merge_archives.py +++ b/libcxx/utils/merge_archives.py @@ -78,6 +78,7 @@ def execute_command_verbose(cmd, cwd=None, verbose=False): sys.stderr.write('%s\n' % report) if exitCode != 0: exit_with_cleanups(exitCode) + return out def main(): parser = ArgumentParser( @@ -119,15 +120,15 @@ def main(): global temp_directory_root temp_directory_root = tempfile.mkdtemp('.libcxx.merge.archives') + files = [] for arc in archives: - execute_command_verbose([ar_exe, 'x', arc], cwd=temp_directory_root, - verbose=args.verbose) - - files = glob.glob(os.path.join(temp_directory_root, '*.o*')) - if not files: - print_and_exit('Failed to glob for %s' % temp_directory_root) - cmd = [ar_exe, 'qcs', args.output] + files - execute_command_verbose(cmd, cwd=temp_directory_root, verbose=args.verbose) + execute_command_verbose([ar_exe, 'x', arc], + cwd=temp_directory_root, verbose=args.verbose) + out = execute_command_verbose([ar_exe, 't', arc]) + files.extend(out.splitlines()) + + execute_command_verbose([ar_exe, 'rcsD', args.output] + files, + cwd=temp_directory_root, verbose=args.verbose) if __name__ == '__main__': |