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

[SR-638] Glibc missing tgmath overlay #43255

Closed
swift-ci opened this issue Jan 28, 2016 · 2 comments
Closed

[SR-638] Glibc missing tgmath overlay #43255

swift-ci opened this issue Jan 28, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-638
Radar None
Original Reporter tchagnon (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Linux
Assignee None
Priority Medium

md5: a9b902e6da826f78482414c3846d4576

Issue Description:

I ran into this issue (or at least surprise) trying to compile some code that uses math.h functions on both OSX and Linux. Here's an example:

#if os(Linux)
  import Glibc
#else
  import Darwin
#endif

let x = Float(1.2345)
let y = sin(x)
print(y)

Compiles and runs fine on OSX, but fails with the following error on Linux:

MathTest.swift:8:13: error: cannot convert value of type 'Float' to expected argument type 'Double'

This is due to the fact that Darwin includes the additional tgmath.swift.gyb overlay that provide the overloaded sin(x: Float) -> Float swift function. Glibc only includes plain math.h functions:

double sin(double x);
float sinf(float x);
@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 1, 2016

Comment by Tim Chagnon (JIRA)

As an experiment, I tried just symlinking the Darwin tgmath to Glibc and fixing some things to make it compile and test. You can take a look here: tchagnon@742eff3

I ran into a couple issues that I had questions about or couldn't figure out:

  1. What's the best way for tgmath.swift.gyb to be shared between both Darwin and Glibc? Move it to a common location and symlink? Would it be better to have a common Math module? It would be a lot nicer if I could just import Math in the example above.

  2. @_silgen_name doesn't appear to work on Linux. I get linker errors or hidden symbol `_swift_Glibc_ilogb' isn't defined if I try to set up an extern function in Misc.c. Is this known? How do I work around this to avoid the ambiguous overloading in the case of ilogb(CDouble) -> CInt.

  3. Is swift-dev@ a better forum for these questions?

@gribozavr
Copy link
Collaborator

tgmath overlay is available in Glibc now.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Linux Platform: Linux standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants