Skip to content

LLVM 21 seemingly assumes that strlen is present even if libc is not linked #149094

@alexrp

Description

@alexrp

I haven't created an isolated repro for this yet, but here are the symptoms:

test-standalone
└─ standalone_test_cases
   └─ standalone_test_cases.windows_resources
      └─ compile exe zig_resource_test Debug x86_64-windows-gnu 1 errors
error: ld.lld: undefined symbol: strlen
    note: referenced by resinator
    note:               /home/alexrp/.cache/zig/o/5a55db84c093a6181e460adf5c02418a/resinator_zcu.o:(zig.LibCInstallation.findNative)
    note: referenced by resinator
    note:               /home/alexrp/.cache/zig/o/5a55db84c093a6181e460adf5c02418a/resinator_zcu.o:(zig.LibCInstallation.findNative)
error: the following command failed with 1 compilation errors:
/home/alexrp/Source/ziglang/zig-llvm21/zig-out/bin/zig build-exe -rcflags /c65001 /I .zig-cache/o/aef5fcc6a94a711acf1fd5aefc9a8b35 -- /home/alexrp/Source/ziglang/zig-llvm21/test/standalone/windows_resources/res/zig.rc -ODebug -target x86_64-windows-gnu -mcpu baseline -Mroot=/home/alexrp/Source/ziglang/zig-llvm21/test/standalone/windows_resources/main.zig --cache-dir .zig-cache --global-cache-dir /home/alexrp/.cache/zig --name zig_resource_test -L /opt/llvm-21/lib -I /opt/llvm-21/include --zig-lib-dir lib/ --listen=-
test-standalone
└─ standalone_test_cases
   └─ standalone_test_cases.zerolength_check
      └─ run test
         └─ compile test ReleaseSmall wasm32-wasi 1 errors
error: wasm-ld: .zig-cache/o/f63cce3ea1b5c099048787fe888c88f2/test_zcu.o: undefined symbol: strlen
error: the following command failed with 1 compilation errors:
/home/alexrp/Source/ziglang/zig-llvm21/zig-out/bin/zig test -OReleaseSmall -target wasm32-wasi -mcpu baseline+bulk_memory -Mroot=/home/alexrp/Source/ziglang/zig-llvm21/test/standalone/zerolength_check/src/main.zig --cache-dir .zig-cache --global-cache-dir /home/alexrp/.cache/zig --name test -L /opt/llvm-21/lib -I /opt/llvm-21/include --zig-lib-dir lib/ --listen=-

It seems like LLVM is now assuming that strlen is present just based on the target triple? Note that we are not linking libc in these test cases.

cc @arsenm this seems like it could potentially be related to your recent libcall work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvmUmbrella label for LLVM issuesquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions