-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[embedded] Mark all functions as 'nounwind' in embedded Swift, add dependency tests #70344
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
7 commits
Select commit
Hold shift + click to select a range
4e56d81
[embedded] Mark all functions as 'nounwind' in embedded Swift, add de…
kubamracek 6e3c5a8
[embedded] Add missing a.out generation+running into embedded/depende…
kubamracek c076b58
[embedded] When checking expected dependencies, use the .o file inste…
kubamracek f8d4526
[embedded] Consider Linux mangling (no _ prefix) in test/embedded/dep…
kubamracek bb7823c
[embedded] Fix test command in test/embedded/dependencies.swift, add …
kubamracek 9e8db64
[embedded] Don't apply 'nounwind' if C++ interop is enabled
kubamracek fdc69fb
[embedded] Actually, use 'nounwind' even with C++ interop on, add com…
kubamracek 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o | ||
|
||
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt | ||
|
||
// Linux/ELF doesn't use the "_" prefix in symbol mangling. | ||
// RUN: if [ %target-os == "linux-gnu" ]; then sed -E -i -e 's/^_(.*)$/\1/' %t/allowed-dependencies.txt; fi | ||
|
||
// RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt | ||
|
||
// Fail if there is any entry in actual-dependencies.txt that's not in allowed-dependencies.txt | ||
// RUN: test -z "`comm -13 %t/allowed-dependencies.txt %t/actual-dependencies.txt`" | ||
|
||
// DEP: ___stack_chk_fail | ||
// DEP: ___stack_chk_guard | ||
// DEP: _free | ||
// DEP: _memset | ||
// DEP: _putchar | ||
// DEP: _posix_memalign | ||
|
||
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o | ||
// RUN: %target-clang %t/a.o %t/print.o -o %t/a.out | ||
// RUN: %target-run %t/a.out | %FileCheck %s | ||
|
||
// REQUIRES: swift_in_compiler | ||
// REQUIRES: executable_test | ||
// REQUIRES: optimized_stdlib | ||
// REQUIRES: OS=macosx || OS=linux-gnu | ||
|
||
@_silgen_name("putchar") | ||
func putchar(_: UInt8) | ||
|
||
public func print(_ s: StaticString, terminator: StaticString = "\n") { | ||
var p = s.utf8Start | ||
while p.pointee != 0 { | ||
putchar(p.pointee) | ||
p += 1 | ||
} | ||
p = terminator.utf8Start | ||
while p.pointee != 0 { | ||
putchar(p.pointee) | ||
p += 1 | ||
} | ||
} | ||
|
||
class MyClass { | ||
func foo() { print("MyClass.foo") } | ||
} | ||
|
||
class MySubClass: MyClass { | ||
override func foo() { print("MySubClass.foo") } | ||
} | ||
|
||
@main | ||
struct Main { | ||
static var objects: [MyClass] = [] | ||
static func main() { | ||
print("Hello Embedded Swift!") | ||
// CHECK: Hello Embedded Swift! | ||
objects.append(MyClass()) | ||
objects.append(MySubClass()) | ||
for o in objects { | ||
o.foo() | ||
} | ||
// CHECK: MyClass.foo | ||
// CHECK: MySubClass.foo | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that applied only to Swift functions, and not the imported C++ functions? In this case you can enable
nounwind
for Swift functions even when C++ interop is enabled, as exceptions are always caught at the boundary between Swift and a call to C++.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, this only applies to SILFunctions, not imported C++ functions. @eeckstein is that correct?