apple / swift-argument-parser

Straightforward, type-safe argument parsing for Swift
Apache License 2.0
3.31k stars 311 forks source link

fatalErrror trying to run tests on Windows #584

Open dabrahams opened 1 year ago

dabrahams commented 1 year ago

Replace this paragraph with a short description of the incorrect incorrect behavior. If this is a regression, please note the last version that the behavior was correct in addition to your current version.

ArgumentParser version: the main branch Swift version: Swift version 5.9-dev (LLVM ad32770d6738638, Swift 753d54576e043ca) Target: aarch64-unknown-windows-msvc

Checklist

Steps to Reproduce

Check it out on Windows. "swift test"

Expected behavior

All tests pass.

Actual behavior

Building for debugging...
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import ArgumentParserToolInfo
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\DumpHelpGenerator.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.JSONEncoder
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\MessageInfo.swift:13:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import class Foundation.NSError
                     ^
C:\Users\dave\src\swift-argument-parser\Sources\ArgumentParser\Usage\UsageGenerator.swift:12:22: warning: using '@_implementationOnly' without enabling library evolution for 'ArgumentParser' may lead to instability during execution
@_implementationOnly import protocol Foundation.LocalizedError
                     ^
error: emit-module command failed with exit code 1 (use -v to see invocation)
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:14:1: error: 'main' attribute cannot be used in a module that contains top-level code
@main
^
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:1:1: note: top-level code defined in this source file
//===----------------------------------------------------------*- swift -*-===//
^
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:1:1: note: pass '-parse-as-library' to compiler invocation if this is intentional
//===----------------------------------------------------------*- swift -*-===//
^
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:14:1: error: 'main' attribute cannot be used in a module that contains top-level code
@main
^
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:1:1: note: top-level code defined in this source file
//===----------------------------------------------------------*- swift -*-===//
^
C:\Users\dave\src\swift-argument-parser\Examples\repeat\Repeat.swift:1:1: note: pass '-parse-as-library' to compiler invocation if this is intentional
//===----------------------------------------------------------*- swift -*-===//
^
error: fatalError

error: fatalError
rauhul commented 1 year ago

@compnerd any ideas here? All of the errors listed here seem wrong

The warnings about @_implementationOnly are correct and that should be removed in favor of import acls

compnerd commented 1 year ago

@rauhul hmm, I think that the @_implementationOnly import are predating the import ACLs - the intent is to avoid leaking the imports into the clients, and as long as that is done, I don't see a problem in changing them.

The fatal error is related to the missing -parse-as-library due to the use of @main which is a long standing issue.

rauhul commented 1 year ago

Correct the use of implementation only was to avoid leaking api, but it also can produce complete broken code for non resilient libraries.

The fatal error is related to the missing -parse-as-library due to the use of @main which is a long standing issue.

Is this a windows specific thing?

compnerd commented 1 year ago

The fatal error is related to the missing -parse-as-library due to the use of @main which is a long standing issue.

Is this a windows specific thing?

No, this is a general Swift issue. https://github.com/apple/swift/issues/56843 was the original bit of discussion around this, and there has always been a requirement to pass -parse-as-library for the use of @main.

dabrahams commented 12 months ago

@compnerd I'm a bit confused. @main seems to work on Mac (and Linux IIRC) without that flag. Is this due to Windows having a stricter symbol linking model? If it's going to be a general requirement we should diagnose failures to pass the flag (on all platforms) rather than trapping in the compiler, right?

compnerd commented 12 months ago

@dabrahams no this behavior is not windows specific. The issue is reported by the frontend if you note. This really should be diagnosed on all platforms.