@@ -71,6 +71,7 @@ KNOWN_SETTINGS=(
7171 swift-tools-num-parallel-lto-link-jobs " " " The number of parallel link jobs to use when compiling swift tools"
7272 use-gold-linker " " " Enable using the gold linker"
7373 workspace " ${HOME} /src" " source directory containing llvm, clang, swift"
74+ dsymutil-jobs " 1" " number of parallel invocations of dsymutil"
7475
7576 # # Build Tools
7677 host-cc " " " the path to CC, the 'clang' compiler for the host platform. **This argument is required**"
@@ -3015,6 +3016,25 @@ for host in "${ALL_HOSTS[@]}"; do
30153016 done
30163017done
30173018
3019+ function printJSONTimestamp {
3020+ local command=$1
3021+ local kind=$2
3022+
3023+ echo " { \" command\" : \" ${command} \" , \" ${kind} \" : \" $( date " +%Y-%m-%dT%H:%M:%S" ) \" }"
3024+ }
3025+
3026+ function printJSONStartTimestamp {
3027+ local command=$1
3028+
3029+ printJSONTimestamp ${command} " start"
3030+ }
3031+
3032+ function printJSONEndTimestamp {
3033+ local command=$1
3034+
3035+ printJSONTimestamp ${command} " end"
3036+ }
3037+
30183038for host in " ${ALL_HOSTS[@]} " ; do
30193039 # Check if we should perform this action.
30203040 if ! [[ $( should_execute_action " ${host} -extractsymbols" ) ]]; then
@@ -3030,6 +3050,7 @@ for host in "${ALL_HOSTS[@]}"; do
30303050 host_install_destdir=$( get_host_install_destdir ${host} )
30313051 host_install_prefix=$( get_host_install_prefix ${host} )
30323052
3053+
30333054 if [[ " ${DARWIN_INSTALL_EXTRACT_SYMBOLS} " ]] && [[ $( host_has_darwin_symbols ${host} ) ]]; then
30343055 echo " --- Extracting symbols ---"
30353056
@@ -3047,6 +3068,9 @@ for host in "${ALL_HOSTS[@]}"; do
30473068 # Instead, just echo we do "darwin_intall_extract_symbols".
30483069 if [[ " ${DRY_RUN} " ]]; then
30493070 call darwin_install_extract_symbols
3071+ printJSONStartTimestamp dsymutil
3072+ echo xargs -n 1 -P ${DSYMUTIL_JOBS} dsymutil
3073+ printJSONEndTimestamp dsymutil
30503074 else
30513075 set -x
30523076
@@ -3069,13 +3093,16 @@ for host in "${ALL_HOSTS[@]}"; do
30693093 #
30703094 # Exclude shell scripts and static archives.
30713095 # Exclude swift-api-digester dSYM to reduce debug toolchain size.
3072- # Run sequentially -- dsymutil is multithreaded and can be memory intensive
3096+ # Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
3097+ # as such too many instance can exhaust the memory and slow down/panic the machine
3098+ printJSONStartTimestamp dsymutil
30733099 (cd " ${host_symroot} " &&
30743100 find ./" ${CURRENT_PREFIX} " -perm -0111 -type f -print | \
30753101 grep -v ' .py$' | \
30763102 grep -v ' .a$' | \
30773103 grep -v ' swift-api-digester' | \
3078- xargs -P 1 ${dsymutil_path} )
3104+ xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path} )
3105+ printJSONEndTimestamp dsymutil
30793106
30803107 # Strip executables, shared libraries and static libraries in
30813108 # `host_install_destdir`.
0 commit comments