Skip to content

Commit 6e35487

Browse files
authored
Merge pull request #38919 from gottesmm/pr-26b1714e21e106018d965c705a0c01988543a372
[build-script-impl] Do not actually try to extract symbols when we perform a dry-run.
2 parents 8cba09a + 8109819 commit 6e35487

File tree

4 files changed

+43
-37
lines changed

4 files changed

+43
-37
lines changed

utils/build-script-impl

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ KNOWN_SETTINGS=(
240240
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
241241
coverage-db "" "If set, coverage database to use when prioritizing testing"
242242
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
243+
enable-extract-symbol-dry-run-test "" "If we are dry-running, still run the extract symbol phase so that we can test it"
243244
)
244245

245246
components=(
@@ -3267,40 +3268,45 @@ for host in "${ALL_HOSTS[@]}"; do
32673268

32683269
# Copy executables and shared libraries from the `host_install_destdir` to
32693270
# INSTALL_SYMROOT and run dsymutil on them.
3270-
(cd "${CURRENT_INSTALL_DIR}" &&
3271-
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \
3272-
filter_paths "${DARWIN_SYMROOT_PATH_FILTERS}" | \
3273-
cpio --insecure -pdm -v "${host_symroot}")
3274-
3275-
dsymutil_path=
3276-
if [[ -n "${DARWIN_INSTALL_EXTRACT_SYMBOLS_USE_JUST_BUILT_DSYMUTIL}" ]]; then
3277-
dsymutil_path=$(find_just_built_local_host_llvm_tool dsymutil)
3271+
if [[ -n "${DRY_RUN}" ]] && [[ -z "${ENABLE_EXTRACT_SYMBOL_DRY_RUN_TEST}" ]]; then
3272+
echo "DRY_RUN! Coping executables and shared libraries from the `host_install_destdir` to
3273+
INSTALL_SYMROOT and runing dsymutil on them."
32783274
else
3279-
dsymutil_path=$(xcrun_find_tool dsymutil)
3280-
fi
3275+
(cd "${CURRENT_INSTALL_DIR}" &&
3276+
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \
3277+
filter_paths "${DARWIN_SYMROOT_PATH_FILTERS}" | \
3278+
cpio --insecure -pdm -v "${host_symroot}")
3279+
3280+
dsymutil_path=
3281+
if [[ -n "${DARWIN_INSTALL_EXTRACT_SYMBOLS_USE_JUST_BUILT_DSYMUTIL}" ]]; then
3282+
dsymutil_path=$(find_just_built_local_host_llvm_tool dsymutil)
3283+
else
3284+
dsymutil_path=$(xcrun_find_tool dsymutil)
3285+
fi
32813286

3282-
# Run dsymutil on executables and shared libraries.
3283-
#
3284-
# Exclude shell scripts and static archives.
3285-
# Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
3286-
# as such too many instance can exhaust the memory and slow down/panic the machine
3287-
printJSONStartTimestamp dsymutil
3288-
(cd "${host_symroot}" &&
3289-
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -not -name "*.a" -not -name "*.py" -print | \
3290-
xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path})
3291-
printJSONEndTimestamp dsymutil
3292-
3293-
# Strip executables, shared libraries and static libraries in
3294-
# `host_install_destdir`.
3295-
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
3296-
'(' -perm -0111 -or -name "*.a" ')' -type f -print | \
3297-
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool strip) -S
3298-
3299-
# Codesign dylibs after strip tool
3300-
# rdar://45388785
3301-
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
3302-
'(' -name "*.dylib" ')' -type f -print | \
3303-
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool codesign) -f -s -
3287+
# Run dsymutil on executables and shared libraries.
3288+
#
3289+
# Exclude shell scripts and static archives.
3290+
# Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
3291+
# as such too many instance can exhaust the memory and slow down/panic the machine
3292+
printJSONStartTimestamp dsymutil
3293+
(cd "${host_symroot}" &&
3294+
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -not -name "*.a" -not -name "*.py" -print | \
3295+
xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path})
3296+
printJSONEndTimestamp dsymutil
3297+
3298+
# Strip executables, shared libraries and static libraries in
3299+
# `host_install_destdir`.
3300+
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
3301+
'(' -perm -0111 -or -name "*.a" ')' -type f -print | \
3302+
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool strip) -S
3303+
3304+
# Codesign dylibs after strip tool
3305+
# rdar://45388785
3306+
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
3307+
'(' -name "*.dylib" ')' -type f -print | \
3308+
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool codesign) -f -s -
3309+
fi
33043310

33053311
{ set +x; } 2>/dev/null
33063312
fi

validation-test/BuildSystem/dsymutil_jobs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: mkdir -p %t
55
# RUN: mkdir -p %t/destdir
66
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
7-
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --host-target=macosx-%target-cpu --darwin-install-extract-symbols --dsymutil-jobs 5 --cmake %cmake --install-symroot=%t/symroot --install-destdir=%t/destdir --toolchain-prefix= 2>&1 | %FileCheck %s
7+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --enable-extract-symbol-dry-run-test=1 --host-target=macosx-%target-cpu --darwin-install-extract-symbols --dsymutil-jobs 5 --cmake %cmake --install-symroot=%t/symroot --install-destdir=%t/destdir --toolchain-prefix= 2>&1 | %FileCheck %s
88

99
# CHECK: --- Extracting symbols ---
1010
# CHECK: { "command": "dsymutil", "start": "

validation-test/BuildSystem/extractsymbols-darwin-symroot-path-filters.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@
2222
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
2323

2424
# test build-script-impl on its own
25-
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script-impl --dry-run --build-dir=%t/build --workspace=%swift_src_root/.. --cmake %cmake --only-execute macosx-%target-cpu-extractsymbols --host-cc /usr/bin/true --darwin-install-extract-symbols=1 --host-target=macosx-%target-cpu --install-symroot=%t/symroot --install-destdir=%t/destdir --build-jobs=1 --darwin-symroot-path-filters="/lib/ /swift-demangle" 2>&1 | tee %t/build-script-impl-output.txt
25+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script-impl --dry-run --enable-extract-symbol-dry-run-test=1 --build-dir=%t/build --workspace=%swift_src_root/.. --cmake %cmake --only-execute macosx-%target-cpu-extractsymbols --host-cc /usr/bin/true --darwin-install-extract-symbols=1 --host-target=macosx-%target-cpu --install-symroot=%t/symroot --install-destdir=%t/destdir --build-jobs=1 --darwin-symroot-path-filters="/lib/ /swift-demangle" 2>&1 | tee %t/build-script-impl-output.txt
2626
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt %s
2727
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt --check-prefixes CHECK-SKIPPED %s
2828

2929
# ensure build-script pass the argument to build-script-impl
3030
# RUN: %empty-directory(%t/symroot)
3131
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
32-
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/ /swift-demangle" --jobs=1 --host-target=macosx-%target-cpu 2>&1 | tee %t/build-script-output.txt
32+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --enable-extract-symbol-dry-run-test=1 --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/ /swift-demangle" --jobs=1 --host-target=macosx-%target-cpu 2>&1 | tee %t/build-script-output.txt
3333
# RUN: %FileCheck --input-file=%t/build-script-output.txt %s
3434
# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s
3535

3636
# ensure we get all the values if we specify the flag multiple times
3737
# RUN: %empty-directory(%t/symroot)
3838
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
39-
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/" --darwin-symroot-path-filters="/swift-demangle" --jobs=1 --host-target=macosx-%target-cpu 2>&1 | tee %t/build-script-output.txt
39+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --enable-extract-symbol-dry-run-test=1 --cmake %cmake --darwin-install-extract-symbols=1 --install-destdir=%t/destdir --toolchain-prefix="" --install-symroot=%t/symroot --darwin-symroot-path-filters="/lib/" --darwin-symroot-path-filters="/swift-demangle" --jobs=1 --host-target=macosx-%target-cpu 2>&1 | tee %t/build-script-output.txt
4040
# RUN: %FileCheck --input-file=%t/build-script-output.txt %s
4141
# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s
4242

validation-test/BuildSystem/extractsymbols-default-behaviour.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# RUN: chmod a+x %t/destdir/libswiftCompatibility51.a
2222
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
2323

24-
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script-impl --dry-run --build-dir=%t/build --workspace=%swift_src_root/.. --cmake %cmake --only-execute macosx-%target-cpu-extractsymbols --host-cc /usr/bin/true --darwin-install-extract-symbols=1 --host-target=macosx-%target-cpu --install-symroot=%t/symroot --install-destdir=%t/destdir --build-jobs=1 > %t/build-script-impl-output.txt 2>&1
24+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script-impl --dry-run --enable-extract-symbol-dry-run-test=1 --build-dir=%t/build --workspace=%swift_src_root/.. --cmake %cmake --only-execute macosx-%target-cpu-extractsymbols --host-cc /usr/bin/true --darwin-install-extract-symbols=1 --host-target=macosx-%target-cpu --install-symroot=%t/symroot --install-destdir=%t/destdir --build-jobs=1 > %t/build-script-impl-output.txt 2>&1
2525
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt %s
2626
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt --check-prefixes CHECK-SKIPPED %s
2727

0 commit comments

Comments
 (0)