You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we get more details (steps to reproduce)? Are you all using an allocator? I know there's a linker regression caused by the new-ish oom lang item, which I have reported in #51647. It could be that you are experiencing that bug and that this isn't related to the #[panic_implementation] stuff.
EDIT: I have been using #[panic_implementation] since it landed and have not run into any linker issue but I'm not using an allocator.
It pretty much happens on 'hello world'; you could strip even more out of the above, if it doesn't warn for you for some reason, I can minimize even further.
@steveklabnik thanks for the sample code. I see at least one bug there: rust_begin_unwind is not emitted when crate-type = bin -- I have reported this with minimal reproduction steps in #51671. I think --{start,end}-group is also missing in the linker invocation but that could be a different issue (or it may fix itself once #51671 is fixed).
So I tried it with the latest nightly [1] and the issue still exists for me. To reproduce, try the panic-without-no-mangle branch of https://github.com/phil-opp/blog_os with either bootimage build or env RUST_TARGET_PATH=$(pwd) xargo build --target x86_64-blog_os. Edit: The travis build for that branch also shows the same error.
Ah, thanks for reminding me to verify the fix. I tried removing #[no_mangle] from my code compiled with rustc 1.29.0-nightly (e06c87544 2018-07-06) and I'm hitting the same error as before.
Seems like no_mangle is still required in release mode without LTO:
error: linking with `rust-lld` failed: exit code: 1
|
= note: rust-lld: error: undefined symbol: rust_oom
>>> referenced by alloc.rs:224 (liballoc/alloc.rs:224)
>>> alloc-c69b28e77453f7a5.alloc.4j3hju2s-cgu.11.rcgu.o:(.text._ZN5alloc5alloc18handle_alloc_error17hcb467c6fec4cebfdE+0x0) in archive /home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/liballoc-c69b28e77453f7a5.rlib
rust-lld: error: undefined symbol: rust_begin_unwind
>>> referenced by panicking.rs:77 (libcore/panicking.rs:77)
>>> core-59aaa68b41c4baf4.core.82zizo12-cgu.9.rcgu.o:(core::panicking::panic_fmt::h380215f9f52a35ae) in archive /home/philipp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/thumbv7em-none-eabihf/lib/libcore-59aaa68b41c4baf4.rlib
It works fine in debug mode and in release mode with LTO. When I add no_mangle, it also works in release mode without LTO. I'm using rustc 1.30.0-nightly (33b923fd4 2018-08-18).
Activity
steveklabnik commentedon Jun 5, 2018
I'm seeing this as well.
Additionally, adding
no_manglegivesbut it still works. This implies to me that
no_mangleshouldn't be needed, as the function doesn't need to be public to work.crawford commentedon Jun 10, 2018
I'm seeing the exact same behavior. I'm using arm-none-eabi-ld (2.28.0.20170620) to link.
japaric commentedon Jun 20, 2018
Can we get more details (steps to reproduce)? Are you all using an allocator? I know there's a linker regression caused by the new-ish oom lang item, which I have reported in #51647. It could be that you are experiencing that bug and that this isn't related to the
#[panic_implementation]stuff.EDIT: I have been using #[panic_implementation] since it landed and have not run into any linker issue but I'm not using an allocator.
steveklabnik commentedon Jun 20, 2018
https://github.com/intermezzos/kernel is pretty small; download it, remove https://github.com/intermezzOS/kernel/blob/e6508a00ec0bc9ffa417d003d81ae63eceac2cf9/src/panic.rs#L5, and
bootimage buildIt pretty much happens on 'hello world'; you could strip even more out of the above, if it doesn't warn for you for some reason, I can minimize even further.
Not using an allocator or anything.
japaric commentedon Jun 21, 2018
@steveklabnik thanks for the sample code. I see at least one bug there:
rust_begin_unwindis not emitted when crate-type = bin -- I have reported this with minimal reproduction steps in #51671. I think--{start,end}-groupis also missing in the linker invocation but that could be a different issue (or it may fix itself once #51671 is fixed).translate / export weak lang items
Auto merge of #51687 - japaric:gh51671, r=alexcrichton
phil-opp commentedon Jul 9, 2018
So I tried it with the latest nightly [1] and the issue still exists for me. To reproduce, try the
panic-without-no-manglebranch of https://github.com/phil-opp/blog_os with eitherbootimage buildorenv RUST_TARGET_PATH=$(pwd) xargo build --target x86_64-blog_os. Edit: The travis build for that branch also shows the same error.I also still get the error for intermezzOS.
[1]: rustc 1.29.0-nightly (960f604 2018-07-08)
crawford commentedon Jul 10, 2018
Ah, thanks for reminding me to verify the fix. I tried removing
#[no_mangle]from my code compiled withrustc 1.29.0-nightly (e06c87544 2018-07-06)and I'm hitting the same error as before.japaric commentedon Jul 27, 2018
This might be related to #52795.
alexcrichton commentedon Aug 2, 2018
I believe this is fixed in #52993, where the answer is "no" you shouldn't need
#[no_mangle]Auto merge of #52993 - alexcrichton:fix-some-vis, r=michaelwoerister
phil-opp commentedon Aug 17, 2018
I can confirm that it now works without
no_mangleandpub. Thanks @alexcrichton!phil-opp commentedon Aug 20, 2018
Seems like
no_mangleis still required in release mode without LTO:It works fine in debug mode and in release mode with LTO. When I add no_mangle, it also works in release mode without LTO. I'm using
rustc 1.30.0-nightly (33b923fd4 2018-08-18).alexcrichton commentedon Aug 20, 2018
@phil-opp oh dear! Is it possible to get an example I could poke around with?
phil-opp commentedon Aug 21, 2018
I created a minimal embedded project here: https://github.com/phil-opp/rust-issue-51342-example
alexcrichton commentedon Aug 23, 2018
Oops, thanks for the report! That should be fixed in #53640
Auto merge of #53640 - alexcrichton:more-symbol-tweaks, r=michaelwoer…