-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
How can I stop rustc including system specific information such as absolute file paths of the source it's compiled from in the binaries it generates? #40374
Comments
/checkout/src/libcore/slice.rs
This such of debug info?/checkout/src/libcore/slice.rs
This such of debug info from compiled rlib or bin?
/checkout/src/libcore/slice.rs
This such of debug info from compiled rlib or bin?
I tried: -Cdebuginfo=0 -Zno-landing-pads -C opt-level=3 -C panic=abort -C lto It still exists panic message in binary:
What should I do? |
I see, they are hardcoded in libstd. https://doc.rust-lang.org/nightly/src/std/macros.rs.html#39-60 #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable]
macro_rules! panic {
() => ({
panic!("explicit panic")
});
($msg:expr) => ({
$crate::rt::begin_panic($msg, {
// static requires less code at runtime, more constant data
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
&_FILE_LINE
})
});
($fmt:expr, $($arg:tt)+) => ({
$crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), {
// The leading _'s are to avoid dead code warnings if this is
// used inside a dead function. Just `#[allow(dead_code)]` is
// insufficient, since the user may have
// `#[forbid(dead_code)]` and which cannot be overridden.
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
&_FILE_LINE
})
});
} https://doc.rust-lang.org/nightly/src/core/macros.rs.html#15-31 #[macro_export]
#[allow_internal_unstable]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! panic {
() => (
panic!("explicit panic")
);
($msg:expr) => ({
static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!());
$crate::panicking::panic(&_MSG_FILE_LINE)
});
($fmt:expr, $($arg:tt)*) => ({
// The leading _'s are to avoid dead code warnings if this is
// used inside a dead function. Just `#[allow(dead_code)]` is
// insufficient, since the user may have
// `#[forbid(dead_code)]` and which cannot be overridden.
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
});
} I know how to fix it for now. |
No, It's doesn't work. I had to find another way out.
|
Almost I am given up. The strange local source file path string where are they come from? https://www.reddit.com/r/rust/comments/5ygehg/when_i_opened_a_rustc_compiled_binary_that/ |
It is unclear what your question is. These paths point to where things were compiled, which in the case of libstd, is not on your computer, but on our build machines. |
How to do not let rustc writing that local source file path string in the final compiled binary program? I am sorry about the unclear question. |
I believe you can run |
@steveklabnik I tried. it didn't work. cd /tmp
git clone https://github.com/kfairmasterz/wtf
cd wtf
cargo build --release
strip ./target/release/wtf
objdump -s -j .rodata ./target/release/wtf |
These paths are coming through calls to |
@alexcrichton I tried mask the macro {libcore,libstd}/panic! inside After I will upload a sample repo. |
https://github.com/kfairmasterz/hello_https/tree/master Now, (or I wondering where are they come from. |
👍 |
Unfortunately, Nobody one tries tell me there is better way how to do.
|
Now I see How to solve it now. These path definely is from panic messages. Now, I could focus to wipe out these messages. |
As finally trace out, I believe there is the source code about how inject the local source file location now. https://github.com/rust-lang/rust/blob/master/src/librustc_trans/mir/block.rs#L284-L287 Specifically. |
Oh I see hints for define a option/flag; |
Solved. Thanks from https://internals.rust-lang.org/t/disabling-panic-handling/1834 |
Great, let's close then. |
/checkout/src/libcore/option.rs
/home/kfairmasterz/.cargo/registry/src/github.com-1ecc6299db9ec823/typeable-0.1.2/src/lib.rs
/home/kfairmasterz/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.7/src/ssl/bio.rs
The text was updated successfully, but these errors were encountered: