apple / swift-numerics

Advanced mathematical types and functions for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error: 'Float16' is only available in macOS 9999 or newer

xanderdunn opened this issue · comments

I have a machine learning project using Swift for Tensorflow that I develop on both macOS 10.15.6 and Ubuntu 18.04.

I added swift-numerics to my Package.swift:

let package = Package(
    name: "TestApp",
    platforms: [
       .macOS(.v10_15)
    ],
    dependencies: [
        .package(name: "swift-numerics",
                 url: "https://github.com/apple/swift-numerics",
                 .upToNextMajor(from: "0.0.7"))
]
    targets: [
        .target(
            name: "TestApp",
            dependencies: [.product(name: "Numerics", package: "swift-numerics")])
]

And I wrote some test code:

import Numerics

func test() {
    let testFloat: Float = 1075.58
    let testDouble: Double = 1075.58
    pow(testDouble, 2)
}

This compiles without any issue on Ubuntu, but I get these compilation errors on Mac:

.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:172:5: error: 'Float16' is only available in macOS 9999 or newer
    Float16(.logGamma(Float(x)))
    ^
.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:172:5: note: add 'if #available' version check
    Float16(.logGamma(Float(x)))
    ^
.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:171:22: note: add @available attribute to enclosing static method
  public static func logGamma(_ x: Float16) -> Float16 {
                     ^
.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:172:5: error: 'init(_:)' is only available in macOS 9999 or newer
    Float16(.logGamma(Float(x)))
    ^
.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:172:5: note: add 'if #available' version check
    Float16(.logGamma(Float(x)))
    ^
.build/checkouts/swift-numerics/Sources/RealModule/Float16+Real.swift:171:22: note: add @available attribute to enclosing static method
  public static func logGamma(_ x: Float16) -> Float16 {
                     ^
[13/528] Compiling ssl_cipher.cc

Note that I am compiling with the Swift for Tensorflow v0.10 toolchain on both machines:

$ uname
Darwin
$ swift --version
Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
Target: x86_64-apple-darwin19.6.0
$ uname
Linux
$ swift --version
Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08)
Target: x86_64-unknown-linux-gnu

I am relatively new to Swift and am likely making a simple mistake. Any pointers would be appreciated.

Xcode 12 beta here and I've a similar problem , with swift-numerics 0.0.7 at launch time I get this error on my Mac app.

Is it possible that "macOS 9999" is just another way to say "not supported" ?
https://developer.apple.com/forums/thread/653041

dyld: Symbol not found: _$ss7Float16VMn
  Referenced from: xxx
  Expected in: /usr/lib/swift/libswiftCore.dylib

for my specific problem tag 0.0.6 is working fine.

It sounds like you're using an older Swift dev toolchain (in particular, 6a5d84ec08 is from June 15, I think); you shouldn't have these issues with the Xcode-provided toolchain (or a recent dev toolchain).

Xcode 12 beta here and I've a similar problem , with swift-numerics 0.0.7 at launch time I get this error on my Mac app.

Is it possible that "macOS 9999" is just another way to say "not supported" ?
https://developer.apple.com/forums/thread/653041

dyld: Symbol not found: _$ss7Float16VMn
  Referenced from: xxx
  Expected in: /usr/lib/swift/libswiftCore.dylib

for my specific problem tag 0.0.6 is working fine.

This seems like it may be a different issue, but I can't reproduce it. I don't suppose you have a public project that exhibits the problem that I could take a look at?

Which beta are you using, and which compiler toolchain?

It sounds like you're using an older Swift dev toolchain (in particular, 6a5d84ec08 is from June 15, I think); you shouldn't have these issues with the Xcode-provided toolchain (or a recent dev toolchain).

Using a newer version did indeed bypass that issue. Using Swift for Tensorflow v0.11 (latest release):

$ which swift
/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.11.xctoolchain/usr/bin//swift
$ swift --version
Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)
Target: x86_64-apple-darwin19.6.0

I do hit some new errors when compiling on macOS 10.15.6:

$ swift build
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:1:1: error: failed to build module 'AppKit' from its module interface; the compiler that produced it, 'Apple Swift version 5.2 (swiftlang-1103.8.25.8 clang-1103.0.30.20)', may have used features that aren't supported by this compiler, 'Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)'
// swift-interface-format-version: 1.0
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/swift/AppKit.swiftmodule/x86_64.swiftinterface:7:8: error: no such module '_SwiftAppKitOverlayShims'
import _SwiftAppKitOverlayShims
       ^
/Users/xander/dev/swift-numerics/Sources/_TestSupport/RealTestSupport.swift:12:8: error: failed to build module 'XCTest' from its module interface; the compiler that produced it, 'Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)', may have used features that aren't supported by this compiler, 'Swift version 5.3-dev (LLVM db8896f3f345af2, Swift 61684f62a6132c0)'
import XCTest
       ^

I believe this is simply because it is linking against my Xcode.app's older mac SDK rather than my Xcode-beta.app's SDK. I don't know how to set the SDK swift build is linking against.

However, it did successfully build with no issues using Swift for Tensorflow 0.11 on Ubuntu 18.04.

Ah, sudo xcode-select -switch /Applications/Xcode-beta.app did it for me. Build working on macOS 10.15.6 with Swift for Tensorflow 0.11.

Xcode 12 beta here and I've a similar problem , with swift-numerics 0.0.7 at launch time I get this error on my Mac app.
Is it possible that "macOS 9999" is just another way to say "not supported" ?
https://developer.apple.com/forums/thread/653041

dyld: Symbol not found: _$ss7Float16VMn
  Referenced from: xxx
  Expected in: /usr/lib/swift/libswiftCore.dylib

for my specific problem tag 0.0.6 is working fine.

This seems like it may be a different issue, but I can't reproduce it. I don't suppose you have a public project that exhibits the problem that I could take a look at?

Which beta are you using, and which compiler toolchain?

(sorry for the late answer)
no I don't have a public repo exhibiting the problem

➜  swift --version
Apple Swift version 5.3 (swiftlang-1200.0.28.1 clang-1200.0.30.1)
Target: x86_64-apple-darwin19.6.0
➜  xcode-select --version
xcode-select version 2373.
➜ ```