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

Make symbol linkage weak in certain cases #11

Closed
8 tasks
mrhota opened this issue Jan 9, 2017 · 4 comments
Closed
8 tasks

Make symbol linkage weak in certain cases #11

mrhota opened this issue Jan 9, 2017 · 4 comments

Comments

@mrhota
Copy link
Collaborator

mrhota commented Jan 9, 2017

Musl makes the linkage of some symbols weak (using weak_alias(foo, bar)). Currently, the list of symbols which don't have weak linkage attributes looks like this:

  • clock_gettime
  • madvise
  • __vm_wait
  • mmap
  • mmap64
  • mremap
  • munmap
  • stpcpy

Weak linkage is a feature of ELF binaries, so it's not supported in Windows or Mac OS X. It should be as simple as an attribute like so on the above functions:

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]

And an attribute like so to enable the linkage feature:

#![cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), feature(linkage))]

See the Rust reference and rlibc repository for more.

@anp
Copy link
Owner

anp commented Jan 15, 2017

I had some issues with weak linkage for these symbols before (as well as malloc, free, etc) when compiling on a much older nightly. If you're able to make this work, I'd certainly be happy. Although we'd want some way to test the weak linkage on Travis now that libc-test has been submodule'd.

I'm not really sure it matters how link args are handled on Windows or Mac -- (m|r)usl only supports Linux, and even if cross compiling is useful we wouldn't want the symbols to stop being weak when cross compiling. I guess this also gets at a broader question of platform compatibility, but since Linux is the only environment I'm aware of with a stable syscall ABI, I don't see it being very useful to compile rusl for other platforms. Your thoughts?

@mrhota
Copy link
Collaborator Author

mrhota commented Jan 15, 2017

I think the linkage feature is broken in rustc. I annotated all the symbols, just like in rlibc, but nothing came out with weak linkage. I think there's an issue in the rust repo indicating that linkage is broken, but I can't find it now

@anp
Copy link
Owner

anp commented Jan 20, 2017

Looks like the progress here is being tracked in rust-lang/rust#29603, although that doesn't reference any issues which explicitly list it as broken.

@mrhota
Copy link
Collaborator Author

mrhota commented Feb 9, 2017

Closed by #15

@mrhota mrhota closed this as completed Feb 9, 2017
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

No branches or pull requests

2 participants