Skip to content

[build-script-impl] Do not actually try to extract symbols when we perform a dry-run. #38919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ KNOWN_SETTINGS=(
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
coverage-db "" "If set, coverage database to use when prioritizing testing"
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
enable-extract-symbol-dry-run-test "" "If we are dry-running, still run the extract symbol phase so that we can test it"
)

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

# Copy executables and shared libraries from the `host_install_destdir` to
# INSTALL_SYMROOT and run dsymutil on them.
(cd "${CURRENT_INSTALL_DIR}" &&
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \
filter_paths "${DARWIN_SYMROOT_PATH_FILTERS}" | \
cpio --insecure -pdm -v "${host_symroot}")

dsymutil_path=
if [[ -n "${DARWIN_INSTALL_EXTRACT_SYMBOLS_USE_JUST_BUILT_DSYMUTIL}" ]]; then
dsymutil_path=$(find_just_built_local_host_llvm_tool dsymutil)
if [[ -n "${DRY_RUN}" ]] && [[ -z "${ENABLE_EXTRACT_SYMBOL_DRY_RUN_TEST}" ]]; then
echo "DRY_RUN! Coping executables and shared libraries from the `host_install_destdir` to
INSTALL_SYMROOT and runing dsymutil on them."
else
dsymutil_path=$(xcrun_find_tool dsymutil)
fi
(cd "${CURRENT_INSTALL_DIR}" &&
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -print | \
filter_paths "${DARWIN_SYMROOT_PATH_FILTERS}" | \
cpio --insecure -pdm -v "${host_symroot}")

dsymutil_path=
if [[ -n "${DARWIN_INSTALL_EXTRACT_SYMBOLS_USE_JUST_BUILT_DSYMUTIL}" ]]; then
dsymutil_path=$(find_just_built_local_host_llvm_tool dsymutil)
else
dsymutil_path=$(xcrun_find_tool dsymutil)
fi

# Run dsymutil on executables and shared libraries.
#
# Exclude shell scripts and static archives.
# Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
# as such too many instance can exhaust the memory and slow down/panic the machine
printJSONStartTimestamp dsymutil
(cd "${host_symroot}" &&
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -not -name "*.a" -not -name "*.py" -print | \
xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path})
printJSONEndTimestamp dsymutil

# Strip executables, shared libraries and static libraries in
# `host_install_destdir`.
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
'(' -perm -0111 -or -name "*.a" ')' -type f -print | \
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool strip) -S

# Codesign dylibs after strip tool
# rdar://45388785
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
'(' -name "*.dylib" ')' -type f -print | \
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool codesign) -f -s -
# Run dsymutil on executables and shared libraries.
#
# Exclude shell scripts and static archives.
# Tweak carefully the amount of parallelism -- dsymutil can be memory intensive and
# as such too many instance can exhaust the memory and slow down/panic the machine
printJSONStartTimestamp dsymutil
(cd "${host_symroot}" &&
find ./"${CURRENT_PREFIX}" -perm -0111 -type f -not -name "*.a" -not -name "*.py" -print | \
xargs -n 1 -P ${DSYMUTIL_JOBS} ${dsymutil_path})
printJSONEndTimestamp dsymutil

# Strip executables, shared libraries and static libraries in
# `host_install_destdir`.
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
'(' -perm -0111 -or -name "*.a" ')' -type f -print | \
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool strip) -S

# Codesign dylibs after strip tool
# rdar://45388785
find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \
'(' -name "*.dylib" ')' -type f -print | \
xargs -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool codesign) -f -s -
fi

{ set +x; } 2>/dev/null
fi
Expand Down
2 changes: 1 addition & 1 deletion validation-test/BuildSystem/dsymutil_jobs.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: mkdir -p %t
# RUN: mkdir -p %t/destdir
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
# 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
# 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

# CHECK: --- Extracting symbols ---
# CHECK: { "command": "dsymutil", "start": "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
# RUN: mkdir -p %t/symroot/macosx-%target-cpu

# test build-script-impl on its own
# 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
# 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
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt %s
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt --check-prefixes CHECK-SKIPPED %s

# ensure build-script pass the argument to build-script-impl
# RUN: %empty-directory(%t/symroot)
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
# 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
# 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
# RUN: %FileCheck --input-file=%t/build-script-output.txt %s
# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s

# ensure we get all the values if we specify the flag multiple times
# RUN: %empty-directory(%t/symroot)
# RUN: mkdir -p %t/symroot/macosx-%target-cpu
# 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
# 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
# RUN: %FileCheck --input-file=%t/build-script-output.txt %s
# RUN: %FileCheck --input-file=%t/build-script-output.txt --check-prefixes CHECK-SKIPPED %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# RUN: chmod a+x %t/destdir/libswiftCompatibility51.a
# RUN: mkdir -p %t/symroot/macosx-%target-cpu

# 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
# 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
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt %s
# RUN: %FileCheck --input-file=%t/build-script-impl-output.txt --check-prefixes CHECK-SKIPPED %s

Expand Down