-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Build] allow to generate symbols for a subset of binaries #37120
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# REQUIRES: standalone_build,OS=macosx | ||
|
||
# RUN: %empty-directory(%t) | ||
# RUN: mkdir -p %t | ||
# 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 | ||
|
||
# REQUIRES: standalone_build,OS=macosx | ||
# 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 --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": " | ||
# CHECK-NEXT: xargs -n 1 -P 5 dsymutil | ||
# CHECK-NEXT: { "command": "dsymutil", "end": " | ||
# CHECK: xargs -n 1 -P 5 {{.*}}dsymutil | ||
# CHECK: { "command": "dsymutil", "end": " |
111 changes: 111 additions & 0 deletions
111
validation-test/BuildSystem/extractsymbols-darwin-symroot-path-filters.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# REQUIRES: standalone_build | ||
# REQUIRES: OS=macosx | ||
|
||
# RUN: %empty-directory(%t) | ||
# RUN: mkdir -p %t | ||
# RUN: split-file %s %t | ||
|
||
# Even though we are running build-script with dry-run, | ||
# symbol extraction runs real commands against the file system. | ||
# Thus we generate a series of files | ||
# to exercise the filtering logic | ||
# RUN: mkdir -p %t/destdir/bin | ||
# RUN: mkdir -p %t/destdir/lib | ||
edymtt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# RUN: %swiftc_driver %t/hello.swift -o %t/destdir/bin/swift-demangle | ||
# RUN: %swiftc_driver %t/hello.swift -o %t/destdir/bin/swift-def-to-yaml-converter | ||
# RUN: ln -s %t/destdir/swift-demangle %t/destdir/bin/swift-api-digester | ||
# RUN: cp %t/swift-util.py %t/destdir/bin | ||
# RUN: chmod a+x %t/destdir/bin/swift-util.py | ||
# RUN: %swiftc_driver %t/dylib.swift -emit-library -o %t/destdir/lib/libswiftDemangle.dylib | ||
# RUN: %swiftc_driver %t/dylib.swift -emit-library -o %t/destdir/lib/lib_InternalSwiftScan.dylib | ||
# RUN: %swiftc_driver %t/dylib.swift -emit-library -static -o %t/destdir/lib/libswiftASTSectionImporter.a | ||
# RUN: mkdir -p %t/symroot/macosx-%target-cpu | ||
|
||
# test build-script-impl on its own | ||
# RUN: 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: %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 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 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 | ||
|
||
|
||
# CHECK: --- Extracting symbols --- | ||
|
||
# Ensure we copy all the files in lib and the swift-demangle executable | ||
# CHECK-LABEL: cpio | ||
# CHECK-DAG: swift-demangle | ||
# CHECK-DAG: libswiftDemangle.dylib | ||
# CHECK-DAG: lib_InternalSwiftScan.dylib | ||
|
||
# Ensure we generate symbols for the file in the symroot | ||
# CHECK-LABEL: "command": "dsymutil", "start" | ||
# CHECK-DAG: dsymutil {{.*}}swift-demangle | ||
# CHECK-DAG: dsymutil {{.*}}libswiftDemangle.dylib | ||
# CHECK-DAG: dsymutil {{.*}}lib_InternalSwiftScan.dylib | ||
|
||
# Ensure we strip the files in the installation directory | ||
# (which are not subject to the filters) | ||
# CHECK-LABEL: xcrun_find_tool strip | ||
# CHECK-DAG: strip {{.*}}swift-demangle | ||
# CHECK-DAG: strip {{.*}}swift-def-to-yaml-converter | ||
# CHECK-DAG: strip {{.*}}libswiftDemangle.dylib | ||
# CHECK-DAG: strip {{.*}}lib_InternalSwiftScan.dylib | ||
# CHECK-DAG: strip {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-DAG: strip {{.*}}swift-util.py | ||
|
||
# Ensure we codesign dylibs | ||
# CHECK-LABEL: xcrun_find_tool codesign | ||
# CHECK-DAG: codesign {{.*}}libswiftDemangle.dylib | ||
# CHECK-DAG: codesign {{.*}}lib_InternalSwiftScan.dylib | ||
|
||
|
||
# CHECK-SKIPPED: --- Extracting symbols --- | ||
|
||
# Ensure we don't copy files not included by the filters | ||
# CHECK-SKIPPED-LABEL: cpio | ||
# CHECK-SKIPPED-NOT: swift-util.py | ||
# CHECK-SKIPPED-NOT: swift-def-to-yaml-converter | ||
# CHECK-SKIPPED-NOT: libswiftASTSectionImporter.a | ||
# CHECK-SKIPPED-NOT: swift-api-digester | ||
|
||
# Ensure we don't generate symbols for files we did not copy | ||
# CHECK-SKIPPED-LABEL: "command": "dsymutil", "start" | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-def-to-yaml-converter | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-util.py | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-api-digester | ||
|
||
# Ensure we don't strip symlinks | ||
# CHECK-SKIPPED-LABEL: xcrun_find_tool strip | ||
# CHECK-SKIPPED-NOT: strip {{.*}}swift-api-digester | ||
|
||
# Ensure we don't codesign executables, symlinks, | ||
# static archives and python scripts | ||
# CHECK-SKIPPED-LABEL: xcrun_find_tool codesign | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-demangle | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-util.py | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-api-digester | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-def-to-yaml-converter | ||
|
||
#--- hello.swift | ||
print("hello") | ||
|
||
#--- dylib.swift | ||
func greet(person: String) -> String { | ||
return "Hello \(person)" | ||
} | ||
#--- swift-util.py | ||
print("hello") |
93 changes: 93 additions & 0 deletions
93
validation-test/BuildSystem/extractsymbols-default-behaviour.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# REQUIRES: standalone_build | ||
# REQUIRES: OS=macosx | ||
|
||
# RUN: %empty-directory(%t) | ||
# RUN: mkdir -p %t | ||
# RUN: split-file %s %t | ||
|
||
# Even though we are running build-script with dry-run, | ||
# symbol extraction runs real commands against the file system. | ||
# Thus we generate a series of files | ||
# to target each of the cases handled by the code | ||
# RUN: mkdir -p %t/destdir | ||
edymtt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# RUN: %swiftc_driver %t/hello.swift -o %t/destdir/swift-demangle | ||
# RUN: ln -s %t/destdir/swift-demangle %t/destdir/swift-api-digester | ||
# RUN: cp %t/swift-util.py %t/destdir/ | ||
# RUN: chmod a+x %t/destdir/swift-util.py | ||
# RUN: %swiftc_driver %t/dylib.swift -emit-library -o %t/destdir/libswiftDemangle.dylib | ||
# RUN: %swiftc_driver %t/dylib.swift -emit-library -static -o %t/destdir/libswiftASTSectionImporter.a | ||
# Targets marked with INSTALL_WITH_SHARED are executable (e.g. compatibility libraries) | ||
# RUN: cp %t/destdir/libswiftASTSectionImporter.a %t/destdir/libswiftCompatibility51.a | ||
# RUN: chmod a+x %t/destdir/libswiftCompatibility51.a | ||
# RUN: mkdir -p %t/symroot/macosx-%target-cpu | ||
|
||
# RUN: 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: %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 | ||
|
||
# CHECK: --- Extracting symbols --- | ||
|
||
# Ensure we copy executable regular files to the symroot | ||
# CHECK-LABEL: cpio | ||
edymtt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# CHECK-DAG: swift-demangle | ||
# CHECK-DAG: swift-util.py | ||
# CHECK-DAG: libswiftDemangle.dylib | ||
# CHECK-DAG: libswiftCompatibility51.a | ||
|
||
# Ensure we extract symbols only for executables and | ||
# and dylibs | ||
# CHECK-LABEL: command": "dsymutil", "start" | ||
# CHECK-DAG: dsymutil {{.*}}swift-demangle | ||
# CHECK-DAG: dsymutil {{.*}}libswiftDemangle.dylib | ||
|
||
# Ensure we strip executables, shared libraries and static | ||
# libraries | ||
# CHECK-LABEL: xcrun_find_tool strip | ||
# CHECK-DAG: strip {{.*}}swift-demangle | ||
# CHECK-DAG: strip {{.*}}libswiftDemangle.dylib | ||
# CHECK-DAG: strip {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-DAG: strip {{.*}}libswiftCompatibility51.a | ||
# CHECK-DAG: strip {{.*}}swift-util.py | ||
|
||
# Ensure we codesign dylibds | ||
# CHECK-LABEL: xcrun_find_tool codesign | ||
# CHECK: codesign {{.*}}libswiftDemangle.dylib | ||
|
||
# CHECK-SKIPPED: --- Extracting symbols --- | ||
|
||
# Ensure symroot does not contain symlinks and static archives | ||
# that are not executable | ||
# CHECK-SKIPPED-LABEL: cpio | ||
# CHECK-SKIPPED-NOT: swift-api-digester | ||
# CHECK-SKIPPED-NOT: libswiftASTSectionImporter.a | ||
|
||
# Ensure we don't extract symbols for static archives, symlinks | ||
# and Python scripts | ||
# CHECK-SKIPPED-LABEL: command": "dsymutil", "start" | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}libswiftCompatibility51.a | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-util.py | ||
# CHECK-SKIPPED-NOT: dsymutil {{.*}}swift-api-digester | ||
|
||
# Ensure we don't strip symlinks | ||
# CHECK-SKIPPED-LABEL: xcrun_find_tool strip | ||
# CHECK-SKIPPED-NOT: strip {{.*}}swift-api-digester | ||
|
||
# Ensure we don't codesign executables, symlinks, | ||
# static archives and python scripts | ||
# CHECK-SKIPPED-LABEL: xcrun_find_tool codesign | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-demangle | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}libswiftASTSectionImporter.a | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}libswiftCompatibility51.a | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-util.py | ||
# CHECK-SKIPPED-NOT: codesign {{.*}}swift-api-digester | ||
|
||
#--- hello.swift | ||
print("hello") | ||
|
||
#--- dylib.swift | ||
func greet(person: String) -> String { | ||
return "Hello \(person)" | ||
} | ||
#--- swift-util.py | ||
print("hello") |
24 changes: 24 additions & 0 deletions
24
validation-test/BuildSystem/extractsymbols-dry-run-does-not-fail.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# REQUIRES: standalone_build | ||
# REQUIRES: OS=macosx | ||
|
||
# As a result of incremental changes, | ||
# in dry-run mode the symbol extraction | ||
# still runs some real commands against the installation | ||
# and symbol directories (e.g. find and cpio) | ||
# This test explictly checks that such commands | ||
# do not cause build-script to fail when run | ||
# against empty directories (which is the typical | ||
# scenario in dry-run) | ||
# RUN: %empty-directory(%t) | ||
# RUN: mkdir -p %t | ||
# RUN: mkdir -p %t/destdir | ||
# RUN: mkdir -p %t/symroot/macosx-%target-cpu | ||
# RUN: 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 2>&1 | %FileCheck %s | ||
|
||
# CHECK: --- Extracting symbols --- | ||
|
||
# CHECK-NOT: {{^}}echo dsymutil | ||
|
||
# CHECK-NOT: {{^[^\+].*}}strip | ||
|
||
# CHECK-NOT: {{^[^\+].*}}codesign |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.