Skip to content

Use of AsyncParsableCommand triggers TBD validation failure #64900

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

Open
MaxDesiatov opened this issue Apr 4, 2023 · 4 comments
Open

Use of AsyncParsableCommand triggers TBD validation failure #64900

MaxDesiatov opened this issue Apr 4, 2023 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@MaxDesiatov
Copy link
Contributor

MaxDesiatov commented Apr 4, 2023

[...] I suspect it might be this PR, but I'm not sure. I'm seeing a new failure around this time:

cmd.exe /C "cd . && D:\a\swift-build\swift-build\BuildRoot\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swiftc.exe -target x86_64-unknown-windows-msvc -j 2 -num-threads 2 -emit-library -o bin\CrossCompilationDestinationsTool.dll -module-name CrossCompilationDestinationsTool -module-link-name CrossCompilationDestinationsTool -emit-module -emit-module-path swift\CrossCompilationDestinationsTool.swiftmodule -emit-dependencies -DCrossCompilationDestinationsTool_EXPORTS -sdk D:\a\swift-build\swift-build/BuildRoot/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk -O -swift-version 5 -libc MD -Xcc -D_CRT_SECURE_NO_WARNINGS -output-file-map Sources\CrossCompilationDestinationsTool\CMakeFiles\CrossCompilationDestinationsTool.dir\Release\output-file-map.json -I D:\a\swift-build\swift-build\BinaryCache\swift-package-manager\swift -I D:\a\swift-build\swift-build\BinaryCache\swift-argument-parser\swift -I D:\a\swift-build\swift-build\BinaryCache\swift-collections\swift -I D:\a\swift-build\swift-build\BinaryCache\swift-system\swift -I D:\a\swift-build\swift-build\SourceCache\swift-system\Sources\CSystem\include -I D:\a\swift-build\swift-build\BinaryCache\swift-tools-support-core\swift -I D:\a\swift-build\swift-build\BinaryCache\swift-llbuild\products\llbuildSwift -I D:\a\swift-build\swift-build\SourceCache\swift-llbuild\products\libllbuild\include -I D:\a\swift-build\swift-build\BinaryCache\swift-crypto\swift -I D:\a\swift-build\swift-build\SourceCache\swift-crypto\Sources\CCryptoBoringSSL\include -I D:\a\swift-build\swift-build\BinaryCache\swift-certificates\swift -I D:\a\swift-build\swift-build\BinaryCache\swift-asn1\swift @CMakeFiles\CrossCompilationDestinationsTool.rsp    -Xlinker -implib:lib\CrossCompilationDestinationsTool.lib  && cd ."
<unknown>:0: error: symbol '$s32CrossCompilationDestinationsTool18InstallDestinationV14ArgumentParser20AsyncParsableCommandAadEP3runyyYaKFTWTu' (async function pointer to protocol witness for ArgumentParser.AsyncParsableCommand.run() async throws -> () in conformance CrossCompilationDestinationsTool.InstallDestination : ArgumentParser.AsyncParsableCommand in CrossCompilationDestinationsTool) is in generated IR file, but not in TBD file

<unknown>:0: error: please submit a bug report (https://swift.org/contributing/#reporting-bugs), and add '-Xfrontend -validate-tbd-against-ir=none' to squash the errors

<unknown>:0: error: symbol '$s32CrossCompilationDestinationsTool04ListC0V14ArgumentParser20AsyncParsableCommandAadEP3runyyYaKFTWTu' (async function pointer to protocol witness for ArgumentParser.AsyncParsableCommand.run() async throws -> () in conformance CrossCompilationDestinationsTool.ListDestinations : ArgumentParser.AsyncParsableCommand in CrossCompilationDestinationsTool) is in generated IR file, but not in TBD file

<unknown>:0: error: please submit a bug report (https://swift.org/contributing/#reporting-bugs), and add '-Xfrontend -validate-tbd-against-ir=none' to squash the errors

Originally posted by @compnerd in swiftlang/swift-package-manager#6361 (comment)

@MaxDesiatov MaxDesiatov added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Apr 4, 2023
@compnerd
Copy link
Member

compnerd commented Apr 4, 2023

Haven't fully reduced this yet, but something like this is along the liens of what is triggering this:

// RUN: %target-swift-frontend -I ... -module-name reduced -parse-as-library -c %s -S -emit-ir -o -
import ArgumentParser
protocol DestinationCommand: AsyncParsableCommand { }
extension DestinationCommand {
    public func run() async throws { }
}
public struct ListDestinations: DestinationCommand {
    public init() {}
}

@compnerd
Copy link
Member

compnerd commented Apr 4, 2023

Reduced:

P.swift

// RUN: %target-swift-frontend -parse-as-library -emit-module -module-name P -emit-module-path %t\P.swiftmodule %s
public protocol P {
    func f() async throws
}

Q.swift

// RUN: %target-swift-frontend -I%t -parse-as-library -module-name reduced -S -emit-ir -o - %s
import P
protocol Q: P {}
extension Q {
    public func f() async throws { }
}
public struct S: Q {
    public init() { }
}

(thanks to help from @aschwaighofer)

@compnerd
Copy link
Member

compnerd commented Apr 4, 2023

Resolving this will likely lead to the removal of the workaround at https://github.com/apple/swift/blob/main/include/swift/SIL/SILLinkage.h#L290-L304

(CC: @jckarter - introduced this in bba87cd)

CC: @slavapestov - 6a83e73

@compnerd
Copy link
Member

compnerd commented Apr 4, 2023

Removing the workaround causes a SIL verification failure:

SIL verification failed: function_ref inside fragile function cannot reference a private or hidden symbol: (SingleFunction && RefF->isExternalDeclaration()) || RefF->hasValidLinkageForFragileRef()

compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 4, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 4, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @dgregor and @aschwaighofer for the discussion on this!
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 4, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @dgregor and @aschwaighofer for the discussion on this!
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 4, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @DougGregor and @aschwaighofer for the discussion on this!
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 5, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @DougGregor and @aschwaighofer for the discussion on this!
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 6, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @DougGregor and @aschwaighofer for the discussion on this!
compnerd added a commit to compnerd/apple-swift that referenced this issue Apr 6, 2023
When a protocol witness thunk is formed to a serialised protocol
containing an `async` function, the async function pointer to the
conformance needs to be made public due to a SIL Verifier check failure
(reference to a non-fragile function from within a public fragile
function).  Add a stop-gap solution of rolling an extra emission for a
private symbol as a public symbol to avoid the error (the underlying
issue has been open for ~6y and counting as of this commit).

This was identified by swift-package-manager (swiftlang#64900).

Thanks to @DougGregor and @aschwaighofer for the discussion on this!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants