-
Notifications
You must be signed in to change notification settings - Fork 13.3k
funcs::posix::fcntl::open from libc magically becomes a public symbol #26640
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Seems to be because on UNIX, If instead of #![feature(no_std, core)]
#![no_std]
extern crate core;
pub fn burger() {}
extern {
pub fn fries();
}
pub extern fn drink() {} the resulting assembly has a public symbol for I suppose the real bug here is that if a library crate depends on a second library crate with a I can think of the following workarounds (slash alternatives, if it's determined this is the right behavior for even for mangled
|
I can't seem to reproduce today (assembly output here: https://gist.github.com/Mark-Simulacrum/be225370d9b7e52fd946cd4eccedb9da), so I'm going to close. I don't see any reference to open on both macOS and on Ubuntu. I'm going to close -- if this is wrong, let us know and we'll reopen. Ideally let us know with exact instructions to reproduce. |
I forget the state of this in 2015 exactly, but it looks like this particular bug got fixed for To put this in a "what I tried, what I expected, what happened" format: I want to be able to compile a C-ABI-compatible library that exports C functions for use by C (or languages that can FFI to C), and implement it in Rust, without the fact that it's written in Rust leaking out. In 2015, I think the only thing that leaked (either static or dynamic) was the mangled symbol for libc::open. Currently everything leaks in static libraries, but it looks fine for dynamic libraries built with Here's my reproducer: meal.rs (simulating the libc crate, in the above context) #![no_std]
pub fn burger() {}
extern {
pub fn fries();
}
pub extern fn drink() {} diner.rs (library written in Rust, using libmeal as a stand-in for liblibc) #![feature(lang_items)]
#![no_std]
extern crate meal;
#[lang="panic_fmt"]
extern fn panic_fmt(_msg: &core::fmt::Arguments, _file: &'static str, _line: u32) -> ! {
loop { }
}
#[lang="eh_personality"]
extern fn eh_personality() {
loop { }
}
#[no_mangle]
pub extern fn libdiner_actually_public_function() -> i32 {
17
}
That is, I'm compiling libdiner into a C-ABI-compatible static library and shared library, and expect my only public function to be For what it's worth, building a regular Given the fact that |
I believe the libcore/libstd being exposed is #33221, so I'll leave this closed -- does that seem correct? |
Yup, thanks for finding that. |
Minimal test case:
Compile with:
The text was updated successfully, but these errors were encountered: