Conflicting options '-Wwarning' and '-suppress-warnings'

I'm trying to use SE-0443's new flag -Wwarning with a nightly toolchain (swiftlang/swift:nightly-main-jammy as of yesterday, Dec 17) and I'm getting the above mentioned error when compiling swift-nio:

❯ dsh swiftlang/swift:nightly-main-jammy
# bash
################################################################
#                                                              #
# Swift Nightly Docker Image                                   #
# Tag: swift-DEVELOPMENT-SNAPSHOT-2024-12-13-a                 #
#                                                              #
################################################################
root@orbstack:/host# swift build -Xswiftc -Wwarning -Xswiftc concurrency
Building for debugging...
error: conflicting options '-Wwarning' and '-suppress-warnings'
error: conflicting options '-Wwarning' and '-suppress-warnings'
error: conflicting options '-Wwarning' and '-suppress-warnings'
[1/76] Compiling c-nioatomics.c
root@orbstack:/host#

(dsh is an alias for docker run ... --entrypoint sh ...)

SE-0443 says

It is forbidden to combine -suppress-warnings with -Wwarning or -Werror. The compiler will produce an error if these options are present in the command line together.

However, there's nowhere that I can see in NIO's - nor its dependencies' - manifests that is actually setting -suppress-warnings. It's unclear to me what's causing the conflict or how to resolve it.

This doesn't seem to be a universal problem with -Wwarning though. Trying the same command for another package does not raise this exact error:

root@orbstack:/host# swift build -Xswiftc -Wwarning -Xswiftc concurrency
Building for debugging...
<unknown>:0: warning: unknown warning group: 'concurrency'
<unknown>:0: warning: unknown warning group: 'concurrency'
/host/Sources/SemanticVersion/SemanticVersion.swift:143:1: warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
141 |
142 |
143 | extension Array: Comparable where Element == SemanticVersion.PreReleaseIdentifier {
    | |- warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
    | `- note: add '@retroactive' to silence this warning
144 |     public static func < (lhs: Self, rhs: Self) -> Bool {
145 |         // Per section 11.4 of the semver spec, compare left to right until a
<unknown>:0: warning: unknown warning group: 'concurrency'
<unknown>:0: warning: unknown warning group: 'concurrency'
<unknown>:0: warning: unknown warning group: 'concurrency'
/host/Sources/SemanticVersion/SemanticVersion.swift:143:1: warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
141 |
142 |
143 | extension Array: Comparable where Element == SemanticVersion.PreReleaseIdentifier {
    | |- warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
    | `- note: add '@retroactive' to silence this warning
144 |     public static func < (lhs: Self, rhs: Self) -> Bool {
145 |         // Per section 11.4 of the semver spec, compare left to right until a
[9/9] Emitting module SemanticVersion
Build complete! (3.14s)

It does however complain about the error group concurrency. I've also tried -Wwarning deprecated, which is explicitly mentioned in SE-0443`, but it raises the same problem.

I thought that perhaps the group names are entirely different and tried printing them via swift build -Xswiftc -print-diagnostic-groups but it's not showing them:

root@orbstack:/host# swift build -Xswiftc -print-diagnostic-groups
Building for debugging...
/host/Sources/SemanticVersion/SemanticVersion.swift:143:1: warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
141 |
142 |
143 | extension Array: Comparable where Element == SemanticVersion.PreReleaseIdentifier {
    | |- warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
    | `- note: add '@retroactive' to silence this warning
144 |     public static func < (lhs: Self, rhs: Self) -> Bool {
145 |         // Per section 11.4 of the semver spec, compare left to right until a
/host/Sources/SemanticVersion/SemanticVersion.swift:143:1: warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
141 |
142 |
143 | extension Array: Comparable where Element == SemanticVersion.PreReleaseIdentifier {
    | |- warning: extension declares a conformance of imported type 'Array' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'Swift' introduce this conformance in the future
    | `- note: add '@retroactive' to silence this warning
144 |     public static func < (lhs: Self, rhs: Self) -> Bool {
145 |         // Per section 11.4 of the semver spec, compare left to right until a
[9/9] Emitting module SemanticVersion
Build complete! (3.16s)
root@orbstack:/host#

So while the compiler doesn't complain about the flags being unsupported I still get the feeling I'm not using a toolchain that's got all the right bits available.

Is that perhaps what's happening here? Or is there something else I'm doing wrong?

(As far as I can see there's no upcoming feature flag for SE-0443 that I should be setting in order to enable support for -Wwarning.)

Any pointers greatly appreciated!

2 Likes

I'm afraid I can't help you with the compilation flags specific to swift-nio. But the warnings related to "unknown warning group: 'concurrency'," occur because that diagnostic group does not exist. In the proposal, the groups mentioned were only intended as examples. For the actual group names and their corresponding warnings, you can refer to the documentation provided here.
Also currently, there is no dedicated group for concurrency-related warnings. This is why, when you enable the -print-diagnostic-groups option, you don't see any group names associated with concurrency.

SwiftPM suppresses warnings for remote dependencies:

That's good to know, thank you! It means that what I'm trying to do won't be possible anyway, at least not until there is such a group.

Oh, I see, thank you Boris!

But doesn't that mean every package with any dependencies (which typically are always remote) will fail, because (as I understand it) -Xswiftc flags are applied to all dependencies as well?

It would seem that the only way to use -Wwarning then is by applying it in the package manifest. Command line use would seem impossible, which would be quite problematic for CI use, wouldn't it?

Yah, it seems like -Wwarning should potentially get the same treatment as -warnings-as-errors, so that it doesn't apply to dependencies.

3 Likes