Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems building on windows #508

Closed
edwardbr opened this issue Nov 4, 2022 · 4 comments
Closed

Problems building on windows #508

edwardbr opened this issue Nov 4, 2022 · 4 comments

Comments

@edwardbr
Copy link

edwardbr commented Nov 4, 2022

Hi I am building on Visual Studio Community 2019 amd64. Against llvm 14.05, I am getting a lot of missing symbols and warnings. To save you grief I have just included the errors. I would love to get this working on my windows rig (our linux platform is in pipeline). Can you give me pointers as to where I have gone off the rails?
I have tried branch v_0.8 and main to no avail.

The only change I have done is in the main CMakeLists file:
#find_program(LLVM_CONFIG_PATH "${INSIGHTS_LLVM_CONFIG}")
set(LLVM_CONFIG_PATH "C:\LLVM14.05\bin\llvm-config")

Windows sdk 10.0.19041.0
Compiler version : 19.29.30146.0

[build] CoroutinesCodeGenerator.obj : error LNK2019: unresolved external symbol "void __cdecl AddToVarNamePrefixMap(class clang::VarDecl const *,class std::basic_string_view<char,struct std::char_traits >)" (?AddToVarNamePrefixMap@@YAXPEBVVarDecl@clang@@v?$basic_string_view@DU?$char_traits@D@std@@@std@@@z) referenced in function "public: void __cdecl clang::insights::CoroutinesCodeGenerator::InsertCoroutine(class clang::FunctionDecl const &,class clang::CoroutineBodyStmt const *)" (?InsertCoroutine@CoroutinesCodeGenerator@insights@clang@@QEAAXAEBVFunctionDecl@3@PEBVCoroutineBodyStmt@3@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] Hint on symbols that are defined and could potentially match:
[build] "void __cdecl clang::insights::AddToVarNamePrefixMap(class clang::VarDecl const *,class std::basic_string_view<char,struct std::char_traits >)" (?AddToVarNamePrefixMap@insights@clang@@YAXPEBVVarDecl@2@V?$basic_string_view@DU?$char_traits@D@std@@@std@@@z)
[build] CoroutinesCodeGenerator.obj : error LNK2019: unresolved external symbol "void __cdecl ClearVarNamePrefix(void)" (?ClearVarNamePrefix@@yaxxz) referenced in function "public: virtual __cdecl clang::insights::CoroutinesCodeGenerator::~CoroutinesCodeGenerator(void)" (??1CoroutinesCodeGenerator@insights@clang@@UEAA@XZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] Hint on symbols that are defined and could potentially match:
[build] "void __cdecl clang::insights::ClearVarNamePrefix(void)" (?ClearVarNamePrefix@insights@clang@@yaxxz)
[build] clangFrontend.lib(CompilerInstance.obj) : error LNK2019: unresolved external symbol __imp__time64 referenced in function "void __cdecl pruneModuleCache(class clang::HeaderSearchOptions const &)" (?pruneModuleCache@@YAXAEBVHeaderSearchOptions@clang@@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangLex.lib(PPMacroExpansion.obj) : error LNK2001: unresolved external symbol __imp__time64 [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangDriver.lib(MSVC.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function sscanf [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangDriver.lib(MSVC.obj) : error LNK2019: unresolved external symbol __imp_strncpy referenced in function "bool __cdecl getSystemRegistryString(char const *,char const *,class std::basic_string<char,struct std::char_traits,class std::allocator > &,class std::basic_string<char,struct std::char_traits,class std::allocator > *)" (?getSystemRegistryString@@YA_NPEBD0AEAV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@PEAV12@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMProfileData.lib(InstrProf.obj) : error LNK2001: unresolved external symbol __imp_strncpy [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangSerialization.lib(ASTWriter.obj) : error LNK2019: unresolved external symbol __imp_strdup referenced in function "private: void __cdecl clang::ASTWriter::WriteHeaderSearch(class clang::HeaderSearch const &)" (?WriteHeaderSearch@ASTWriter@clang@@AEAAXAEBVHeaderSearch@2@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp_strdup [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangLex.lib(PPMacroExpansion.obj) : error LNK2019: unresolved external symbol __imp_asctime referenced in function "private: void __cdecl clang::Preprocessor::ExpandBuiltinMacro(class clang::Token &)" (?ExpandBuiltinMacro@Preprocessor@clang@@AEAAXAEAVToken@2@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] clangLex.lib(PPMacroExpansion.obj) : error LNK2019: unresolved external symbol __imp__localtime64 referenced in function "void __cdecl ComputeDATE_TIME(class clang::SourceLocation &,class clang::SourceLocation &,class clang::Preprocessor &)" (?ComputeDATE_TIME@@YAXAEAVSourceLocation@clang@@0AEAVPreprocessor@2@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(APInt.obj) : error LNK2019: unresolved external symbol __imp_round referenced in function "public: class llvm::APInt __cdecl llvm::APInt::sqrt(void)const " (?sqrt@APInt@llvm@@qeba?AV12@XZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(raw_ostream.obj) : error LNK2019: unresolved external symbol __imp_lseek referenced in function "public: __cdecl llvm::raw_fd_ostream::raw_fd_ostream(int,bool,bool,enum llvm::raw_ostream::OStreamKind)" (??0raw_fd_ostream@llvm@@qeaa@H_N0W4OStreamKind@raw_ostream@1@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(lseek.obi) : error LNK2001: unresolved external symbol __imp_lseek [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(raw_ostream.obj) : error LNK2019: unresolved external symbol __imp_read referenced in function "public: __int64 __cdecl llvm::raw_fd_stream::read(char *,unsigned __int64)" (?read@raw_fd_stream@llvm@@QEAA_JPEAD_K@Z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Path.obj) : error LNK2001: unresolved external symbol __imp_read [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp_read [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(raw_ostream.obj) : error LNK2019: unresolved external symbol __imp_write referenced in function "private: virtual void __cdecl llvm::raw_fd_ostream::write_impl(char const *,unsigned __int64)" (?write_impl@raw_fd_ostream@llvm@@EEAAXPEBD_K@Z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Path.obj) : error LNK2001: unresolved external symbol __imp_write [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(ErrorHandling.obj) : error LNK2001: unresolved external symbol __imp_write [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp_write [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Path.obj) : error LNK2019: unresolved external symbol __imp_close referenced in function "class std::error_code __cdecl llvm::sys::fs::copy_file(class llvm::Twine const &,class llvm::Twine const &)" (?copy_file@fs@sys@llvm@@ya?AVerror_code@std@@AEBVTwine@3@0@Z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Process.obj) : error LNK2001: unresolved external symbol __imp_close [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp_close [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Process.obj) : error LNK2019: unresolved external symbol __imp_srand referenced in function "public: static unsigned int __cdecl llvm::sys::Process::GetRandomNumber(void)" (?GetRandomNumber@Process@sys@llvm@@SaiXZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Process.obj) : error LNK2019: unresolved external symbol __imp_rand referenced in function "public: static unsigned int __cdecl llvm::sys::Process::GetRandomNumber(void)" (?GetRandomNumber@Process@sys@llvm@@SaiXZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Process.obj) : error LNK2019: unresolved external symbol __imp__heapwalk referenced in function "public: static unsigned __int64 __cdecl llvm::sys::Process::GetMallocUsage(void)" (?GetMallocUsage@Process@sys@llvm@@SA_KXZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(JSON.obj) : error LNK2019: unresolved external symbol __imp_modf referenced in function "public: class llvm::Optional<__int64> __cdecl llvm::json::Value::getAsInteger(void)const " (?getAsInteger@Value@json@llvm@@qeba?AV?$Optional@_J@3@XZ) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(NativeFormatting.obj) : error LNK2019: unresolved external symbol __imp__fpclass referenced in function "void __cdecl llvm::write_double(class llvm::raw_ostream &,double,enum llvm::FloatStyle,class llvm::Optional)" (?write_double@llvm@@YAXAEAVraw_ostream@1@NW4FloatStyle@1@V?$Optional@_K@1@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] LLVMSupport.lib(Chrono.obj) : error LNK2019: unresolved external symbol __imp__localtime64_s referenced in function "class llvm::raw_ostream & __cdecl llvm::operator<<(class llvm::raw_ostream &,class std::chrono::time_point<struct std::chrono::system_clock,class std::chrono::duration<__int64,struct std::ratio<1,1000000000> > >)" (??6llvm@@YAAEAVraw_ostream@0@AEAV10@V?$time_point@Usystem_clock@chrono@std@@v?$duration@_JU?$ratio@$00$0DLJKMKAA@@std@@@23@@chrono@std@@@z) [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] OLDNAMES.lib(strdup.obi) : error LNK2001: unresolved external symbol __imp__strdup [C:\Dev\Projects\cppinsights\build\insights.vcxproj]
[build] C:\Dev\Projects\cppinsights\build\insights.exe : fatal error LNK1120: 20 unresolved externals [C:\Dev\Projects\cppinsights\build\insights.vcxproj]

@andreasfertig
Copy link
Owner

Hello @edwardbr,

I'm sorry that building C++ Insights causes you trouble.

I abandoned the Windows build in the CI pipeline a while ago due to a compiler error. However, you're hitting something else. First, but that's not the reason for the compiler errors, you should be able to set LLVM_CONFIG_PATH via cmake with the -DLLVM_CONFIG_PATH=PATH_TO_YOUR_LLVM option.

The missing symbol errors you get seem strange to me. Some of them are functions from C++ Insights. Others are from LLVM/Clang. It looks like some mangling issue/confusion. Can you maybe attach the output from cmake?

Andreas

@edwardbr
Copy link
Author

edwardbr commented Nov 4, 2022

Hi I am doing a kosher build as far as I can see build of llvm 14.05 as the binary distribution does not include llvm-config. Building llvm is VERY slow!
I had to upload the logs as they were too long in the comment box

I am using this kit in vscode:
{
"name": "Visual Studio Community 2019 Release - amd64",
"visualStudio": "6640c3ad",
"visualStudioArchitecture": "x64",
"preferredGenerator": {
"name": "Visual Studio 16 2019",
"platform": "x64",
"toolset": "host=x64"
}
},
configure and build log .txt

@andreasfertig
Copy link
Owner

Hello @edwardbr,

thanks for posting the build log. These are the lines that I think are the root cause:

clangTooling.lib(ArgumentsAdjusters.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in CodeGenerator.obj [C:\Dev\Projects\cppinsights\build\insights.vcxproj]

It looks to me that the runtime library settings do not match. Please note that I'm not an MSVC expert. I use that compiler mainly via GitHub Actions. What I learned is that these settings have to match. You can try to enable static linking for C++ Insights. That forces C++ Insights to apply /MT to the compiler options.

Another option is the use the pre-built binaries I try to use for MSVC builds cppinsights-compiler-binaries. I haven't used them officially now, but I struggle with the same issue as you, building LLVM is slow and Clang does not ship with the libraries we need for C++ Insights and other libClang tools.

Andreas

@andreasfertig
Copy link
Owner

Hello @edwardbr,

I assume you managed to compile C++ Insights on Windows in the meantime. I'm closing the issue, but feel free to open it if there are still problems.

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants