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.
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'm a bit confused by whether these imports need to be there at all, as I've been seeing changes in what the trunk compiler I build natively on Android expects here in the last month.
To compare to other platforms, I commented out the imports of CoreFoundation and the three linux C libraries in this file- Bionic, Musl, and Glibc- and tried building the latter two on Fedora 40, where both compiled fine without these imports (Musl was built with the latest July 2 SDK snapshot, Glibc starting from the latest trunk snapshot toolchain back to 5.9.2). This file uses the
inet_pton()
C function, which clearly comes from those C libraries.The issue is that a trunk source snapshot of the compiler from June and July built natively on Android worked the same, ie these two imports were unnecessary, but an August trunk snapshot now requires
import Android
.I don't know if something changed in the compiler's ClangImporter or LLVM in the last month, but the Android module map is identical from the July trunk snapshot to August.
Anyone know what is going on here, if not with my Android issue, at least why these imports seem unneeded for Glibc/Musl?
@ian-twilightcoder, @compnerd, @etcwilde, @al45tair, perhaps one of you knows what's going on with these overlay imports.
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.
The glibc modulemap/header thing that we have today isn't properly modularizing glibc. Instead of using that mega header, each of the top-level C headers should end up in its own top-level module so if that header is seen through a transitive include, that's the module definition that will get used. I don't know what changed specifically, but what we have was technically undefined, so we're still in the wrong with glibc. It just means that something pulled in something from CoreFoundation that pulled in the necessary header before something else pulled in the bit of glibc/bionic that pulled in that same header, which ends up with CoreFoundation saying that it owns the canonical definition of that thing rather than the libc. We ran into this in corelibs-foundation as well: swiftlang/swift-corelibs-foundation#5005
The musl modulemap should be better behaved though as I seem to remember Alastair putting quite a lot of work to modularize it correctly. @ian-twilightcoder can probably give you more details though on how to proceed.
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 tried a little experiment to see if these libc imports are needed at all, deleting every
import Musl
andimport Glibc
in theswift-nio
repo and then trying to build with each libc on linux with the July 2 trunk snapshot toolchain, as that's the latest Musl SDK available.The good news is that caused a bunch of errors, so I then put back each import one by one until I was left with this cleaned-up patch, ie it still built fine with these imports deleted, even running and passing all the same tests for the
Glibc
build:The bad news is that I don't know why some of these are not needed. The imports in
NIOPosix/VsockAddress.swift
aren't needed because one of theGlibc
imports in that module is@_exported
, so that appears to cover all files in that module. I presume the same forNIOFileSystem/Internal/SystemFileHandle.swift
andNIOFileSystem/FileSystem.swift
, which both explicitlyimport NIOPosix
. The other three are a mystery.Pinging @ian-twilightcoder, perhaps you know what's going on here.
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.
Hmm, maybe this is related to the current leaks in the module system, such as for member declarations that is currently being fixed, so given Ian hasn't responded, I will just change this so the compiler won't error, and we can merge and then revisit it later, once we know the Swift module leaks have been fixed.
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'm guessing this is related to the clang re-export leak that Allan wrote up on the forum.