Files
Karoy Lorentey fa45de1018 Work around another MergeModules crash (#62)
* [utils] Add utility for shuffling sources to help reproduce MergeModules issues

* [Deque] Collapse Sequence/Collection conformances into a single file

The MergeModules phase in the compiler is broken: it isn’t always able to correctly handle circular dependencies across source files, like the ones that keep organically popping up with Sequence/Collection conformances that are defined in separate files.

Such dependencies sometimes triggers a compiler crash, depending on some (unknown) environmental parameters.

Trying to manually find and eliminate these circular dependencies has not proved productive. Instead, roll all Collection conformances into a single, huge source file.

* [Deque] Update CMakeLists
2021-07-08 17:02:00 -07:00

49 lines
883 B
Bash
Executable File

#!/bin/sh
#
# Randomly reorder Swift source files in the specified directory, then
# try rebuilding the package, in a loop.
#
# This script is useful to help reproducing nondeterministic issues
# with the Swift compiler's MergeModules phase, as in
# https://github.com/apple/swift-collections/issues/7
#
set -eu
function shuffle() {
input="$1"
tmp="$(dirname "$input")/tmp"
mkdir "$tmp"
local i=0
ls "$input"/*.swift | sort -R | while read file; do
mv "$file" "$tmp/$i.swift"
i=$(($i + 1))
done
mv "$tmp"/*.swift "$input"
rmdir "$tmp"
}
if [[ -z "${1+set}" || ! -d "$1" ]]; then
echo "Usage: $0 <directory> <build-arguments>..." >&2
exit 1
fi
dir="$1"
shift
cd "$(dirname "$0")/.."
i=0
while true; do
echo
echo "$i"
rm -rf .build
shuffle "$dir"
xcrun swift build "$@"
i="$(($i + 1))"
done