Skip to content

[lld-link] bug, maybe. clang_rt.builtins-x86_64.lib will not auto link wen use function "__builtin_cpu_supports" #144630

@Eternalni

Description

@Eternalni

platform : winodws x86_64

my code:
if (__builtin_cpu_supports("avx"))
std::cin >> s3.a;
else
std::cin >> s3.b;

build error message:
C:\Windows\system32\cmd.exe /C "cd . && D:\a2\cmake\compilers\win\x64\LLVM\bin\clang++.exe --target=x86_64-pc-windows-msvc -nostartfiles -nostdlib -mcx16 -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -fuse-ld=lld -Xlinker /subsystem:console -fuse-ld=lld-link CMakeFiles/a2.dir/main.cpp.obj -o a2.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:a2.lib -Xlinker /pdb:a2.pdb -Xlinker /version:0.0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: undefined symbol: __cpu_model

note: LLVM\bin\ is not in system environment path

add "target_link_libraries("${EXECUTABLE_TARGET}" PRIVATE clang_rt.builtins-x86_64)" in CMakeLists.txt, then build success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions