Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Musl (#429) #430

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add support for Musl (#429) #430

wants to merge 1 commit into from

Conversation

arasan01
Copy link

@arasan01 arasan01 commented Sep 25, 2024

Summary

Change import to allow a choice between Glibc and Musl.

related Issue: #429
replacing musl pow: https://git.musl-libc.org/cgit/musl/tree/include/math.h

Check

$ xcrun --toolchain org.swift.600202409171a swift --version
Apple Swift version 6.0.2-dev (LLVM 43d73cb0cc589f7, Swift aaa632cea622394)
Target: arm64-apple-macosx14.0

$ xcrun --toolchain org.swift.600202409171a swift build --swift-sdk x86_64-swift-linux-musl -c release
Building for production...
[3/3] Compiling Yams Constructor.swift
Build complete! (7.32s)

$ xcrun --toolchain org.swift.600202409171a swift build -c release
Building for production...
[9/9] Compiling Yams Constructor.swift
Build complete! (16.99s)

Change import to allow a choice between Glibc and Musl
musl pow ref: https://git.musl-libc.org/cgit/musl/tree/include/math.h
#elseif canImport(Musl)
import CoreFoundation
import Musl
private let cpow: (_: Double, _: Double) -> Double = Musl.pow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weren't native Swift math functions added to the STL in 2019?
https://github.com/swiftlang/swift/pull/23140/files

Do we still need to import any C libraries here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the background to the introduction of this, it now seems like it would be okay to use STL math functions. In that case, we would need to check that there are no problems with all toolchains. If we are only going to support Musl, I think it would have less of an impact if you just explicitly loaded cpow.

introduce commit: 682d498

commit message:

We must disambiguate `Double.pow(_: Double, _: Double) -> Double` and
`__C.pow(_: Double, _: Double) -> Double` as the Swift for TensorFlow
branch adds the former into the standard library.  The explicit module
dispatch ensures that we make the overload resolution unambiguous
allowing building Yams.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants