-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Symbol mangling happens despite #[no_mangle] or #[link_name] #35052
Comments
The |
Having no knowledge of rustc's source code, it seems to me that that is the purpose of |
Ah the #[export_name = "\x01foo"]
pub extern fn foo() {
} That is, explicit symbol names which start with the 1 byte get no extra mangling at the LLVM layer, and that 1 byte is stripped. |
For reference, in C, using the
Arguably it would be more consistent for Rust to do the same with |
Really I think we just need to properly document the |
Yuck... it's confusing enough that mangling adds characters you didn't write, without added magic that removes characters you did write. I would much prefer either changing |
Normally the ABI decoration is desired though. If some code links to an extern C function named |
I omitted this initially in an attempt to keep the thread focused. I'm developing an Emacs module. Modules are a new Emacs 25 feature and basically provide an FFI to the C world. Emacs requires each module to have a symbol I have a working C module (working as in it can be successfully loaded by Emacs) in which the symbol is defined as
(The When I build the Rust code with this definition: #[no_mangle]
pub static plugin_is_GPL_compatible: c_int = 0; and inspect the generated
(The grep is necessary since there are almost 5800 symbols with I notice 2 things:
I'm not sure what to make of this to be honest, since Emacs still refuses to load it. But this is a While it would be great to know the answers to those questions, it also seems to me that this specific bug can be closed. |
Perhaps you could try using the new
It shouldn't. |
@retep998 I just tried changing # ...
[lib]
crate-type = ["dylib"]
# ... to # ...
[lib]
crate-type = ["cdylib"]
# ... But those 2 produce identical results for me when using |
I think I finally figured out what happened. Emacs wants the dynamic lib to have a |
I see symbols being mangled despite using
#[no_mangle]
or#[link_name = "foo"]
. Specifically, the symbols are being prepended by_
, i.e.foo
gets mangled to_foo
rather than being accessible asfoo
.I tried this code:
and
Meta
OS:
OS X 10.10
rustc --version --verbose
: I tried bothrustc 1.10.0 (cfcb716cf 2016-07-03) binary: rustc commit-hash: cfcb716cf0961a7e3a4eceac828d94805cf8140b commit-date: 2016-07-03 host: x86_64-apple-darwin release: 1.10.0
and
rustc 1.12.0-nightly (9316ae515 2016-07-24) binary: rustc commit-hash: 9316ae515e2f8f3f497fb4f1559910c1eef2433d commit-date: 2016-07-24 host: x86_64-apple-darwin release: 1.12.0-nightly
The text was updated successfully, but these errors were encountered: