Open helje5 opened 4 years ago
This can be reproduced with two simple packages:
mkdir LibBase LibDep
cd LibBase && swift package init --type library && git init && cd ..
cd LibDep && swift package init --type library && cd ..
LibBase.swift:
#if os(Windows)
import WinSDK
#elseif os(Linux)
import struct Glibc.timespec
public typealias timespec = Glibc.timespec
public extension timespec {
static func demo() -> timespec { return timespec() }
}
#else // Darwin
import struct Darwin.timespec
public typealias timespec = Darwin.timespec
public extension timespec {
static func demo() -> timespec { return timespec() }
}
#endif // Darwin
libdep Package.swift:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "LibDep",
dependencies: [ .package(url: "../LibBase", .branch("master")) ],
targets: [ .target(name: "LibDep", dependencies: [ "LibBase" ]) ]
)
LibDep.swift:
import LibBase
func doIt() {
let x = timespec.demo()
print("X:", x)
}
Compile:
brew install spmdestinations/tap/spm-dest-5.3-x86_64-ubuntu16.04
swift build --destination \
/usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/destination.json
Zini18:LibDep helge$ swift build --destination /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/destination.json
/Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/Sources/LibDep/LibDep.swift:4:20: error: type 'timespec' has no member 'demo'
let x = timespec.demo()
~~~~~~~~ ^~~~
Doing the compilation on the host (or in Docker) works just fine.
Call one looks good (--emit-module
mode?):
/usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/swift.xctoolchain/usr/bin/swiftc \
-module-name LibDep -incremental -emit-dependencies -emit-module \
-emit-module-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.swiftmodule \
-output-file-map /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/output-file-map.json \
-parse-as-library \
-c /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/Sources/LibDep/LibDep.swift \
-I /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug \
-target x86_64-unknown-linux -swift-version 5 -enable-batch-mode \
-index-store-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/index/store \
-use-ld=lld \
-tools-directory /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/swift.xctoolchain/usr/bin \
-sdk /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/x86_64-ubuntu16.04.sdk \
-Onone -enable-testing -g -j12 -DSWIFT_PACKAGE -DDEBUG \
-module-cache-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/ModuleCache \
-parseable-output -color-diagnostics
Seems to have the right switches on.
Call two fails:
/usr/local/Cellar/spm-dest-5.3-x86_64-ubuntu16.04/2020-07-31/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/swift.xctoolchain/usr/bin/swift \
-frontend -c \
-primary-file /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/Sources/LibDep/LibDep.swift \
-emit-module-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep~partial.swiftmodule \
-emit-module-doc-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep~partial.swiftdoc \
-emit-module-source-info-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep~partial.swiftsourceinfo \
-emit-dependencies-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep.d \
-emit-reference-dependencies-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep.swiftdeps \
-target x86_64-unknown-linux \
-disable-objc-interop \
-sdk /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/x86_64-ubuntu16.04.sdk \
-I /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug \
-color-diagnostics -enable-testing -g \
-module-cache-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/ModuleCache \
-swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG \
-enable-anonymous-context-mangled-names \
-parse-as-library \
-module-name LibDep \
-o /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/LibDep.build/LibDep.swift.o \
-index-store-path /Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/.build/x86_64-unknown-linux/debug/index/store \
-index-system-modules
/Users/helge/Dropbox/dev/Tests/RepoXIssue/LibDep/Sources/LibDep/LibDep.swift:4:20: error: type 'timespec' has no member 'demo'
let x = timespec.demo()
~~~~~~~~ ^~~~
Though it does pretty much correct as well? 🤔
Ready to use tarball to demo the issue: https://helgehess.eu/patches/RepoXIssue-2020-08-04-1.tgz
It's not related to the ifdef's, same error w/ this LibBase.swift:
import Glibc
public typealias timespec = Glibc.timespec
public extension timespec {
static func demo() -> timespec { return timespec() }
}
Hm, it is restricted to such libc types though, e.g. an extension to Formatter
DOES work.
Adding
-resource-dir /usr/local/lib/swift/dst/x86_64-unknown-linux/swift-5.3-ubuntu16.04.xtoolchain/x86_64-ubuntu16.04.sdk/usr/lib/swift \
gives
<unknown>:0: error: missing required module 'SwiftShims'
Looks like the Ubuntu SDK is missing the shims.
Macro (and NIO) itself works fine, but
stat
andtimespec
extensions inxsys
andfs
do not make it through toconnect
in MacroExpress.This is declared just fine in
Macro/fs/Utils/StatStruct.swift
.