llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang-cl emits bogus error LNK2019: unresolved external symbol _wmemchr

Open StephanTLavavej opened this issue 8 years ago • 4 comments

Bugzilla Link 37911
Resolution DUPLICATE
Resolved on Jul 17, 2019 12:51
Version 7.0
OS Windows NT
CC @dwblaikie,@mwinterb,@nico

Extended Description

This was reported to MSVC: https://developercommunity.visualstudio.com/content/problem/234075/unresolved-symbols-in-iosfwd-with-has-constexpr-ch-1.html

It appears to be a Clang bug.

C:\Temp\CLANG_REPRO>clang-cl -m32 -v clang version 6.0.0 (tags/RELEASE_600/final) Target: i386-pc-windows-msvc Thread model: posix InstalledDir: S:\msvc\src\vctools\NonShip\ClangLLVM\bin

C:\Temp\CLANG_REPRO>type pch.h #pragma once #include

C:\Temp\CLANG_REPRO>type pch.cpp // empty file

C:\Temp\CLANG_REPRO>type test.cpp int main() { (void) std::wstring().find(L' ', 0); }

C:\Temp\CLANG_REPRO>clang-cl -m32 /EHsc /nologo /W4 -Ycpch.h -FI pch.h pch.cpp -c -std:c++latest -MDd

C:\Temp\CLANG_REPRO>clang-cl -m32 /EHsc /nologo /W4 -Yupch.h -FI pch.h test.cpp pch.obj -std:c++latest -MDd test-c47dea.obj : error LNK2019: unresolved external symbol _wmemchr referenced in function "public: static wchar_t const * __cdecl std::_WChar_traits<wchar_t>::find(wchar_t const *,unsigned int,wchar_t const &)" (?find@?$_WChar_traits@_W@std@@SAPB_WPB_WIAB_W@Z) test.exe : fatal error LNK1120: 1 unresolved externals clang-cl.exe: error: linker command failed with exit code 1120 (use -v to see invocation)

StephanTLavavej avatar Jun 23 '18 00:06 StephanTLavavej

mentioned in issue llvm/llvm-bugzilla-archive#41226

nico avatar Nov 27 '21 01:11 nico

Duping into newer bug with more information.

*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#41226 ***

nico avatar Jul 17 '19 19:07 nico

Please see also bug 41226 for an even simpler example.

KarstenH avatar Mar 25 '19 22:03 KarstenH

This is likely because wmemchr is implemented as an inline function in wchar.h so there's nothing to actually link against. A fix similar to the handling for __builtin_wmemcmp introduced here https://reviews.llvm.org/rL323362 is probably needed.

mwinterb avatar Jul 06 '18 19:07 mwinterb