Viladoman / StructLayout

Visual Studio Extension for C++ struct memory layout visualization
MIT License
480 stars 22 forks source link

Visual Studio 17.4 Support #32

Closed BobbyAnguelov closed 1 year ago

BobbyAnguelov commented 1 year ago

Hi, so the latest VS update has unfortunately broken this plugin due to them inserting a minimum required clang version in yvals_core.h

`#if __clang_major__ < 14 _EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 14.0.0 or newer.");

endif // ^^^ old Clang ^^^`

I use libclang internally and had to upgrade that due to this as well :(

Viladoman commented 1 year ago

Wow! Thanks for letting me know. I will get latest Clang 15 stable ( looks like 15.0.5 ), fix any api changes they might have done and update the binaries as soon as I can.

BobbyAnguelov commented 1 year ago

I tried to recompile ClangLayout myself using the latest clang but ended up hitting a bunch of linker errors that became a pain to fix since I'm not super familiar with LLVM and it felt like I was chasing my tail a bit.

I'm very curious why MS decided to put that compiler version minimum limit in place...

Viladoman commented 1 year ago

There were 2 new .lib dependencies that needed to be added. I submitted the change to the repository, but I want to run some more tests over the weekend before pushing the new version to the marketplace. Please feel free to get latest and try it out at your end if you need it sooner. Thanks again for letting me know about this.

BobbyAnguelov commented 1 year ago

I tried to rebuild it but it still won't compile. I'm using VS 17.4.1...

I need to switch the language spec to C++ 17 else I get a bunch of compilation errors (I'm assuming this is cause I built LLVM with the latest compilers and it set the language spec then). Basically a bunch of template errors regarding optional.

There is a new error (C4146) triggered in MathExtra.h since they negate an unsigned int

inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) { assert(Align != 0 && (Align & (Align - 1)) == 0 && "Align must be a power of 2"); return (Value + Align - 1) & -Align;

And finally, I still have linker errors:

1>LLVMCodeGen.lib(CodeGen.obj) : error LNK2001: unresolved external symbol "void __cdecl llvm::initializeObjCARCContractLegacyPassPass(class llvm::PassRegistry &)" (?initializeObjCARCContractLegacyPassPass@llvm@@YAXAEAVPassRegistry@1@@Z) 1>LLVMObject.lib(OffloadBinary.obj) : error LNK2001: unresolved external symbol "class std::unique_ptr<class llvm::Module,struct std::default_delete<class llvm::Module> > __cdecl llvm::getLazyIRModule(class std::unique_ptr<class llvm::MemoryBuffer,struct std::default_delete<class llvm::MemoryBuffer> >,class llvm::SMDiagnostic &,class llvm::LLVMContext &,bool)" (?getLazyIRModule@llvm@@YA?AV?$unique_ptr@VModule@llvm@@U?$default_delete@VModule@llvm@@@std@@@std@@V?$unique_ptr@VMemoryBuffer@llvm@@U?$default_delete@VMemoryBuffer@llvm@@@std@@@3@AEAVSMDiagnostic@1@AEAVLLVMContext@1@_N@Z)

I'm guessing you are on an older version of VS 2022?

Any chance you can upload the compiled version of the plugin (with a beta or RC flag) to the releases?

Viladoman commented 1 year ago

yes, the alignToPowerOf2 error was introduced in the clang codebase and I had to fix it before building.

I submitted a new version 0.6.1. Sadly I did not have much time over the weekend to go through different projects setups and validate everything is ok. But it should be the same just with updated clang libraries.

If I can't find anything I will push it soon to the marketplace. Please let me know if everything works fine at your end.

BobbyAnguelov commented 1 year ago

So far it's working great! Thanks!