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 attribute to specify symbol name, as an alternative to no_mangle #2007

Closed
ids1024 opened this issue May 25, 2017 · 3 comments
Closed

Add attribute to specify symbol name, as an alternative to no_mangle #2007

ids1024 opened this issue May 25, 2017 · 3 comments

Comments

@ids1024
Copy link

ids1024 commented May 25, 2017

I suggested this in rust-lang/rust#42202, to address an issue mentioned there (namely, symbol names that are not valid identifiers in Rust), but there are other uses for such a feature. Certainly it would be helpful if symbols need to be exposed to another language with some sort of mangling but also called from Rust with less ugly names. I also seem to vaguely recall wanting such a feature for some other reason, but I can't recall exactly why.

There are several possible syntaxes:

  • #[symbol="some_symbol_name"]
  • #[no_mangle="some_symbol_name"]
  • Something else

I can't think of any major disadvantages, other than the ones that are already present by allowing no_mangle. And of course the general disadvantage of adding a relatively obscure feature.

@ids1024 ids1024 closed this as completed May 25, 2017
@ids1024
Copy link
Author

ids1024 commented May 25, 2017

Oh wait, I think export_name does this.

@eddyb
Copy link
Member

eddyb commented May 25, 2017

Pretty sure it's link_name?

@ids1024
Copy link
Author

ids1024 commented May 25, 2017

link_name - the name of the symbol that this function or static should be imported as.
export_name - on statics and functions, this determines the name of the exported symbol.
https://doc.rust-lang.org/stable/reference/attributes.html

It looks to me like these do similar things, the fist when importing a function, the second when exporting a function. Is that wrong? The documentation is somewhat sparse here (these are, after all, fairly obscure and rarely needed features).

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