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

inline-asm stack probe used but not defined on x86_64-unknown-uefi #81196

Closed
addrianyy opened this issue Jan 19, 2021 · 2 comments
Closed

inline-asm stack probe used but not defined on x86_64-unknown-uefi #81196

addrianyy opened this issue Jan 19, 2021 · 2 comments
Labels
C-bug Category: This is a bug. O-UEFI UEFI

Comments

@addrianyy
Copy link

addrianyy commented Jan 19, 2021

I tried this code:

#![no_std]
#![no_main]

#[panic_handler]
fn panic(_panic_info: &core::panic::PanicInfo) -> ! {
    loop {}
}

struct LargeObject {
    x: [u64; 4096 / 8],
}

#[no_mangle]
extern fn efi_main(image_handle: usize, system_table: usize) -> ! {
    let obj = LargeObject {
        x: [0u64; 4096 / 8],
    };

    loop {}
}

.cargo/config.toml

[build]
target = "x86_64-unknown-uefi"

[unstable]
build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"]

I expected to see this happen: successful build

Instead, this happened:

  = note: rust-lld: error: undefined symbol: inline-asm
          >>> referenced by /home/adrian/dev/bug_test/src/main.rs:14
          >>>               /home/adrian/dev/bug_test/target/x86_64-unknown-uefi/debug/deps/bug_test-a3717c03849f2f91.5fjbp9r5jsbut7ld.rcgu.o:(efi_main)
          >>> referenced by /home/adrian/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/dec2flt/algorithm.rs:16
          >>>               libcore-4d11da90c3f4442d.rlib(core-4d11da90c3f4442d.core.5b14wvwk-cgu.12.rcgu.o):(core::num::dec2flt::algorithm::power_of_ten::hb262726576c8070b)

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (d98d2f57d 2021-01-18)
binary: rustc
commit-hash: d98d2f57d9b98325ff075c343d2c7695b66dfa7d
commit-date: 2021-01-18
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

I believe that this problem was introduced in commit #77885.
The same problem exits if building compiler-builtins-mem is not enabled.

@addrianyy addrianyy added the C-bug Category: This is a bug. label Jan 19, 2021
@nagisa
Copy link
Member

nagisa commented Jan 19, 2021

Could work around in #80838, but I'm surprised LLVM doesn't just emit probing there?

cc @cuviper @erikdesjardins

@cuviper
Copy link
Member

cuviper commented Jan 19, 2021

We define x86_64-unknown-uefi using llvm target x86_64-unknown-windows, and X86TargetLowering::hasInlineStackProbe returns false for isOSWindows. Then X86TargetLowering::getStackProbeSymbolName returns the attribute as if it were a real symbol.

library/core/src/num/dec2flt/algorithm.rs:16

Off-topic, but that table::POWERS should probably be made indirect as a static.

@camelid camelid added the O-UEFI UEFI label Jan 20, 2021
@bors bors closed this as completed in 1b15ec6 Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-UEFI UEFI
Projects
None yet
Development

No branches or pull requests

4 participants