Skip to content

Linking an std program with the *-unknown-uefi targets fails with "undefined symbol: wcslen" #160827

Description

@nicholasbishop

With a simple main.rs like this:

fn main() {}

Build with cargo +nightly build --target x86_64-unknown-uefi. It fails like this:

error: linking with `rust-lld` failed: exit status: 1
  |
  = note:  "rust-lld" "-flavor" "link" "/NOLOGO" "/entry:efi_main" "/subsystem:efi_application" "/var/home/nbishop/tmp/uefi-std-test/target/x86_64-unknown-uefi/debug/build/uefi-std-test/e1b313fb8e551b59/out/rustcAdIZq5/symbols.o" "<6 object files omitted>" "<sysroot>/lib/rustlib/x86_64-unknown-uefi/lib/{libpanic_abort-*,libstd-*,libr_efi_alloc-*,libr_efi-*,libcfg_if-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "/NXCOMPAT" "/OUT:/var/home/nbishop/tmp/uefi-std-test/target/x86_64-unknown-uefi/debug/build/uefi-std-test/e1b313fb8e551b59/out/uefi_std_test.efi" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NODEFAULTLIB"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: undefined symbol: wcslen
          >>> referenced by /rustc/771916f9028e7fe56d2685f2c4f698de5d7d6a45/library/std/src/sys/process/uefi.rs:744
          >>>               libstd-95535557a15d2937.rlib(std-95535557a15d2937.std.61c682eb00e56aa5-cgu.0.rcgu.o):(<std::sys::process::uefi::uefi_command_internal::PipeProtocol>::output_string)
          >>> referenced by /rustc/771916f9028e7fe56d2685f2c4f698de5d7d6a45/library/std/src/process.rs:1140
          >>>               libstd-95535557a15d2937.rlib(std-95535557a15d2937.std.61c682eb00e56aa5-cgu.0.rcgu.o):(<std::process::Command>::output)
          >>> referenced by /rustc/771916f9028e7fe56d2685f2c4f698de5d7d6a45/library/std/src/env.rs:54
          >>>               libstd-95535557a15d2937.rlib(std-95535557a15d2937.std.61c682eb00e56aa5-cgu.0.rcgu.o):(std::env::current_dir)
          >>> referenced 8 more times

Similar errors occur for the i686 and aarch64 UEFI targets.

Note that this only fails if std is enabled; a no_std+no_main program still works fine.

$ rustc +nightly --version --verbose
rustc 1.99.0-nightly (771916f90 2026-08-08)
binary: rustc
commit-hash: 771916f9028e7fe56d2685f2c4f698de5d7d6a45
commit-date: 2026-08-08
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

I bisected this to #158734, which is the LLVM 23 uprev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-UEFIUEFIneeds-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions