swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.27k stars 1.13k forks source link

[SR-13831] Warnings while building on Linux #3240

Open dhoepfl opened 3 years ago

dhoepfl commented 3 years ago
Previous ID SR-13831
Radar rdar://problem/71122020
Original Reporter @dhoepfl
Type Improvement
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: fb7ced6742bc6d687df5ea1589e7d36e

Issue Description:

When building swift on Linux, there are two warnings that I see a lot:

/home/myhome/llvm/swift-source/build/buildbot_linux/foundation-linux-x86_64/CoreFoundation.framework/Headers/ForSwiftFoundationOnly.h:610:12: warning: implicit declaration of function 'lstat' is invalid in C99 [-Wimplicit-function-declaration]
    return lstat(filename, buffer) == 0 ? 0 : errno;

and

/home/myhome/llvm/swift-source/swift-corelibs-foundation/Sources/Foundation/RunLoop.swift:11:8:
warning: 'CoreFoundation' inconsistently imported as implementation-only
import CoreFoundation
       ^
@_implementationOnly
/home/myhome/llvm/swift-source/swift-corelibs-foundation/Sources/Foundation/Bridging.swift:13:29
: note: imported as implementation-only here
@_implementationOnly import CoreFoundation
                            ^

In a full build, the first one appears 160 times, the second one 399 times.
Thats 19%/47% (66%) of all 843 warnings I see in a full swift build.

Both swift-corelibs-foundation/CoreFoundation/Base.subproj/CoreFoundation.h, and swift-corelibs-foundation/CoreFoundation/Base.subproj/SwiftRuntime/CoreFoundation.h currently import <sys/types.h> but lack <sys/stat.h> (and <unistd.h>).

I’m think CoreFoundation should be imported implementation-only since all other files in swift-corelibs-foundation/Sources/Foundation import it like that. Both files where introduced in the same commit fd7c1e9d.

typesanitizer commented 3 years ago

@swift-ci create

dhoepfl commented 3 years ago

Partially (lstat-part) fixed by pull request #2919.

Did not touch the import part since I’m not sure how it is intended to be.