Skip to content

Commit c3d23c5

Browse files
committed
Merge branch 'main' of github.com:swiftwasm/swift into maxd/main-merge
2 parents 051f13c + 8fc2598 commit c3d23c5

File tree

7 files changed

+53
-3
lines changed

7 files changed

+53
-3
lines changed

utils/build-script

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ class BuildScriptInvocation(object):
506506
pipes.quote(opt) for opt in cmake.common_options()),
507507
"--build-args=%s" % ' '.join(
508508
pipes.quote(arg) for arg in cmake.build_args()),
509+
"--dsymutil-jobs", str(args.dsymutil_jobs),
509510
]
510511

511512
# Compute any product specific cmake arguments.

utils/build-script-impl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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**"
@@ -3043,6 +3044,25 @@ for host in "${ALL_HOSTS[@]}"; do
30433044
done
30443045
done
30453046

3047+
function printJSONTimestamp() {
3048+
local command=$1
3049+
local kind=$2
3050+
3051+
echo "{ \"command\": \"${command}\", \"${kind}\": \"$(date "+%Y-%m-%dT%H:%M:%S")\" }"
3052+
}
3053+
3054+
function printJSONStartTimestamp() {
3055+
local command=$1
3056+
3057+
printJSONTimestamp ${command} "start"
3058+
}
3059+
3060+
function printJSONEndTimestamp() {
3061+
local command=$1
3062+
3063+
printJSONTimestamp ${command} "end"
3064+
}
3065+
30463066
for host in "${ALL_HOSTS[@]}"; do
30473067
# Check if we should perform this action.
30483068
if ! [[ $(should_execute_action "${host}-extractsymbols") ]]; then
@@ -3075,6 +3095,9 @@ for host in "${ALL_HOSTS[@]}"; do
30753095
# Instead, just echo we do "darwin_intall_extract_symbols".
30763096
if [[ "${DRY_RUN}" ]]; then
30773097
call darwin_install_extract_symbols
3098+
printJSONStartTimestamp dsymutil
3099+
echo xargs -n 1 -P ${DSYMUTIL_JOBS} dsymutil
3100+
printJSONEndTimestamp dsymutil
30783101
else
30793102
set -x
30803103

@@ -3097,13 +3120,16 @@ for host in "${ALL_HOSTS[@]}"; do
30973120
#
30983121
# Exclude shell scripts and static archives.
30993122
# Exclude swift-api-digester dSYM to reduce debug toolchain size.
3100-
# Run sequentially -- dsymutil is multithreaded and can be memory intensive
3123+
# Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
3124+
# as such too many instance can exhaust the memory and slow down/panic the machine
3125+
printJSONStartTimestamp dsymutil
31013126
(cd "${host_symroot}" &&
31023127
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \
31033128
grep -v '.py$' | \
31043129
grep -v '.a$' | \
31053130
grep -v 'swift-api-digester' | \
3106-
xargs -P 1 ${dsymutil_path})
3131+
xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path})
3132+
printJSONEndTimestamp dsymutil
31073133

31083134
# Strip executables, shared libraries and static libraries in
31093135
# `host_install_destdir`.

utils/build_swift/build_swift/defaults.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
__all__ = [
25-
# Command line configuarable
25+
# Command line configurable
2626
'BUILD_VARIANT',
2727
'CMAKE_GENERATOR',
2828
'COMPILER_VENDOR',
@@ -38,6 +38,7 @@
3838
'DARWIN_INSTALL_PREFIX',
3939
'LLVM_MAX_PARALLEL_LTO_LINK_JOBS',
4040
'SWIFT_MAX_PARALLEL_LTO_LINK_JOBS',
41+
'DSYMUTIL_JOBS'
4142

4243
# Constants
4344
]
@@ -62,6 +63,8 @@
6263
DARWIN_INSTALL_PREFIX = ('/Applications/Xcode.app/Contents/Developer/'
6364
'Toolchains/XcodeDefault.xctoolchain/usr')
6465

66+
DSYMUTIL_JOBS = 1
67+
6568

6669
def _system_memory():
6770
"""Returns the system memory as an int. None if the system memory cannot

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,13 @@ def create_argument_parser():
501501
help='the maximum number of parallel link jobs to use when '
502502
'compiling swift tools.')
503503

504+
option('--dsymutil-jobs', store_int,
505+
default=defaults.DSYMUTIL_JOBS,
506+
metavar='COUNT',
507+
help='the maximum number of parallel dsymutil jobs to use when '
508+
'extracting symbols. Tweak with caution, since dsymutil'
509+
'is memory intensive.')
510+
504511
option('--disable-guaranteed-normal-arguments', store_true,
505512
help='Disable guaranteed normal arguments')
506513

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
'distcc': False,
141141
'sccache': False,
142142
'dry_run': False,
143+
'dsymutil_jobs': defaults.DSYMUTIL_JOBS,
143144
'enable_asan': False,
144145
'enable_experimental_differentiable_programming': True,
145146
'enable_experimental_concurrency': True,
@@ -662,6 +663,7 @@ class BuildScriptImplOption(_BaseOption):
662663
IntOption('--llvm-max-parallel-lto-link-jobs'),
663664
IntOption('--swift-tools-max-parallel-lto-link-jobs'),
664665
IntOption('-j', dest='build_jobs'),
666+
IntOption('--dsymutil-jobs', dest='dsymutil_jobs'),
665667

666668
AppendOption('--cross-compile-hosts'),
667669
AppendOption('--extra-cmake-options'),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: %empty-directory(%t)
2+
# RUN: mkdir -p %t
3+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --darwin-install-extract-symbols --dsymutil-jobs 5 --cmake %cmake 2>&1 | %FileCheck %s
4+
5+
# REQUIRES: standalone_build,OS=macosx
6+
7+
# CHECK: --- Extracting symbols ---
8+
# CHECK: { "command": "dsymutil", "start": "
9+
# CHECK-NEXT: xargs -n 1 -P 5 dsymutil
10+
# CHECK-NEXT: { "command": "dsymutil", "end": "

validation-test/compiler_crashers_2_fixed/rdar71816041.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend -emit-ir -primary-file %s -enable-experimental-concurrency
2+
// REQUIRES: concurrency
23

34
func getIntAndString() async -> (Int, String) { (5, "1") }
45

0 commit comments

Comments
 (0)