Skip to content

Move libm bindings into separate crate #40798

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

Open
anatol opened this issue Mar 24, 2017 · 2 comments
Open

Move libm bindings into separate crate #40798

anatol opened this issue Mar 24, 2017 · 2 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@anatol
Copy link
Contributor

anatol commented Mar 24, 2017

It is a followup for #39473

There is Rust cleanup activity that aims to move complex, platform-specific dependencies outside of std. For examples libc bindings were moved to its own crate and std links to it.

It worth checking if similar thing can be done for libm dependency. Decoupling libm library from std has advantages:

  • clear interface between the libraries
  • external libm will have its own release cycle independent of the Rust one. If there is a bug in libm crate then it can be released separately without waiting for a new Rust release.
  • external libm has more freedom over its implementation. Initially libm is going to be just a wrapper over system shared library. But it is be possible to create a version that statically links to openlibm and avoid dynamic linking. It would be great to see a libm version implemented fully in Rust, similar to what math.rs tries to achieve. And users could switch between libm implementation depending on their requirements.

Another question - do math functions like hyperbolic cosine need to be part of std at all? Would it make more sense to remove libm dependency from std completely and let users plug math crate manually instead?

@steveklabnik steveklabnik added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 24, 2017
@nagisa
Copy link
Member

nagisa commented Mar 24, 2017

Another question - do math functions like hyperbolic cosine need to be part of std at all? Would it make more sense to remove libm dependency from std completely and let users plug math crate manually instead?

This question is irrelevant, because LLVM can and will lower trivial-er operations to library calls anyway. You’d have to remove pretty much every single associated method on floats to make it viable to remove the dependency on libm.

@steveklabnik
Copy link
Member

Triage: @japaric has created https://github.com/japaric/libm. Would it be useful in fixing this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants