Skip to content

Issues linking __rust_probestack when cross compiling for UEFI on 0.1.23 #333

Closed
@ALSchwalm

Description

@ALSchwalm

Cross compiling a simple example crate (containing a function with sufficiently large stack allocation) with compiler_builtins v0.1.23 produces the following error:

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "rust-lld" "-flavor" "link" "/NOLOGO" "/NXCOMPAT" "/nodefaultlib" "/entry:efi_main" "/subsystem:efi_application" "/LIBPATH:/home/adam/test/uefi-example/target/sysroot/lib/rustlib/x86_64-unknown-uefi/lib" "/home/adam/test/uefi-example/target/x86_64-unknown-uefi/debug/deps/uefi_example-33d6ce04242a6b68.1j5mfhubop672qu0.rcgu.o" "/OUT:/home/adam/test/uefi-example/target/x86_64-unknown-uefi/debug/deps/uefi_example-33d6ce04242a6b68.efi" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:/home/adam/test/uefi-example/target/x86_64-unknown-uefi/debug/deps" "/LIBPATH:/home/adam/test/uefi-example/target/debug/deps" "/LIBPATH:/home/adam/test/uefi-example/target/sysroot/lib/rustlib/x86_64-unknown-uefi/lib" "/home/adam/test/uefi-example/target/sysroot/lib/rustlib/x86_64-unknown-uefi/lib/libcore-9d5e0b6ad79711be.rlib" "/home/adam/test/uefi-example/target/x86_64-unknown-uefi/debug/deps/libcompiler_builtins-e6a828d72c47e9cb.rlib"
  = note: rust-lld: error: undefined symbol: __rust_probestack
          >>> referenced by /home/adam/test/uefi-example/target/x86_64-unknown-uefi/debug/deps/uefi_example-33d6ce04242a6b68.1j5mfhubop672qu0.rcgu.o:(efi_main)

Produced using this crate with cargo +nightly xbuild --target x86_64-unknown-uefi on the current nightly.

Reverting to 0.1.21 resolves the issue (0.1.22 produces the expected issue with invalid assembly). Looking at the object files it seems the the symbol is present and defined but maybe not in a way the linker expects? I tried a bit to fix this but I don't know enough about COFF/UEFI linkage. I can only speculate it is not sufficient to just use .globl ___rust_probestack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions