tyoma / micro-profiler

Cross-platform low-footprint realtime C/C++ Profiler
https://visualstudiogallery.msdn.microsoft.com/133d5764-b32b-4ec9-8ee8-5546eca64584
MIT License
238 stars 27 forks source link

Cannot build using Visual Studio 2022 (64-bit) - LTSC 17.4 #85

Open LouisStrous opened 1 year ago

LouisStrous commented 1 year ago

I tried building micro-profiler myself in the hope that that would circumvent issue #83 (to which I contributed some logs yesterday), but Conan ran into errors. The first one was

  -- Conan: Version found Conan version 2.0.9
  -- Conan executing: C:/Program Files/Conan/conan/conan.exe install . -s arch=x86_64 -s build_type=Release -s compiler=Visual Studio -s compiler.version=17 -s compiler.runtime=MT -g=cmake_multi --build=missing -o=capstone:arm=False -o=capstone:evm=False -o=capstone:m680x=False -o=capstone:m68k=False -o=capstone:mips=False -o=capstone:ppc=False -o=capstone:sparc=False -o=capstone:sysz=False -o=capstone:tms320c64x=False -o=capstone:xcore=False
  ERROR: Error while initializing options. The usage of package names `capstone:arm` in options is deprecated, use a pattern like `capstone/*:arm` instead
  CMake Error at build.props/conan.cmake:540 (message):

I tried working around that one by changing capstone: to capstone/*: in patcher/src/CMakeLists.txt. Rerunning cmake gave a new error:

  -- Conan executing: C:/Program Files/Conan/conan/conan.exe install . -s arch=x86_64 -s build_type=Release -s compiler=Visual Studio -s compiler.version=17 -s compiler.runtime=MT -g=cmake_multi --build=missing -o=capstone/*:arm=False -o=capstone/*:evm=False -o=capstone/*:m680x=False -o=capstone/*:m68k=False -o=capstone/*:mips=False -o=capstone/*:ppc=False -o=capstone/*:sparc=False -o=capstone/*:sysz=False -o=capstone/*:tms320c64x=False -o=capstone/*:xcore=False
  ERROR: Invalid setting 'Visual Studio' is not a valid 'settings.compiler' value.
  Possible values are ['sun-cc', 'gcc', 'msvc', 'clang', 'apple-clang', 'intel-cc', 'qcc', 'mcst-lcc']
  Read "http://docs.conan.io/2/knowledge/faq.html#error-invalid-setting"
  CMake Error at build.props/conan.cmake:540 (message):

I tried working around that one by changing set(_VISUAL "Visual Studio") to set(_VISUAL "msvc") in build.props/conan.cmake. Rerunning cmake gave a new error:

  -- Conan executing: C:/Program Files/Conan/conan/conan.exe install . -s arch=x86_64 -s build_type=Release -s compiler=msvc -s compiler.version=17 -s compiler.runtime=MT -g=cmake_multi --build=missing -o=capstone/*:arm=False -o=capstone/*:evm=False -o=capstone/*:m680x=False -o=capstone/*:m68k=False -o=capstone/*:mips=False -o=capstone/*:ppc=False -o=capstone/*:sparc=False -o=capstone/*:sysz=False -o=capstone/*:tms320c64x=False -o=capstone/*:xcore=False
  ERROR: Error while processing 'profile.py' plugin, line 13
          _check_correct_cppstd(settings)
  while calling '_check_correct_cppstd', line 50
          _error(compiler, cppstd, mver, version)
  while calling '_error', line 19
          raise ConanException(f"The provided compiler.cppstd={cppstd} requires at least {compiler}"
          ConanException: The provided compiler.cppstd=14 requires at least msvc>=190 but version 17 provided
  CMake Error at build.props/conan.cmake:540 (message):

I don't know how to work around that problem. I think that the msvc version check is incorrect. The latest available Visual Studio version is 17.7, so I don't know what the "at least msvc >= 190" means. I expect that the "compiler.cppstd = 14" refers to C++14 support, which is available in the Visual Studio version that I use, which is 17.4.

Maybe this is a conan problem rather than a micro-profiler problem, but in any case it prevents me from making further progress in getting micro-profiler to build. And the first two problems look like they're micro-profiler problems.

I attach the CMake logs from the last cmake run.

CMakeOutput.log CMakeError.log

tyoma commented 1 year ago

Hi @LouisStrous!

I have not migrated cmake/conan to the latest versions yet - at conan they've changed the whole integration principle with cmake. Right now I am using Conan v1.59.0 and CMake v3.24.3 - those work fine. As for 'arm' I'd look at the ~/.conan/profiles/default (I have not employed local profiles yet).

Basically, what you see here conan-wise was added, bc I needed to integrate sqlite3 and capstone fast. More work is required as per infrastructure...

thanks!

LouisStrous commented 1 year ago

I have now installed conan v1.59.0 and CMake v3.24.3, re-cloned the micro-profiler code, and run "cmake ." in the top-level folder of the repository. This gets me much further than before but still runs into a fatal problem:

CMake Error at micro-profiler/CMakeLists.txt:3 (include):
  include could not find requested file:

    vssdk

I find the word "vssdk" mentioned in one location in the repository: on line 3 of [repo]/micro-profiler/CMakeLists.txt, which reads

include(vssdk)

There is indeed no file named "vssdk" anywhere in the repository.

"vssdk" seems to refer to the Visual Studio SDK, which I had already installed on my system, as part of the "Visual Studio extension development" toolset.

Do you know how I can resolve this problem?

CMakeError.log CMakeOutput.log

tyoma commented 1 year ago

I usually create '/_build' directory, 'cd' there and from it call: cmake .. does this work? I'll check calling cmake from the root dir - it should work from there as well.

btw, did you pull submodules: 'git submodule update --init' ?

LouisStrous commented 1 year ago

That gives me the same results, unfortunately. See the attached log files.

Regards, Louis Strous

Artem G. schreef op 2023-09-16 02:02:

I usually create '/_build' directory, 'cd' there and from it call: cmake .. does this work? I'll check calling cmake from the root dir - it should work from there as well.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you were mentioned.Message ID: @.***>

Links:

[1] https://github.com/tyoma/micro-profiler/issues/85#issuecomment-1722067916 [2] https://github.com/notifications/unsubscribe-auth/ABJRVQJLARNMO6PTLE6X3TTX2TUCXANCNFSM6AAAAAA4COXSYA The system is: Windows - 10.0.22621 - AMD64 Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. Compiler:
Build flags: Id flags:

The output was: 0 MSBuild version 17.4.3+7e646be43 for .NET Framework Build started 2023-09-22 11:46:33. Project "C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". Creating directory "Debug\CompilerIdC.tlog\". InitializeBuildStatus: Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc143.pdb" /external:W0 /Gd /TC /FC /errorReport:queue CMakeCCompilerId.c CMakeCCompilerId.c Link: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X64 Debug\CMakeCCompilerId.obj CompilerIdC.vcxproj -> C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdC\CompilerIdC.exe PostBuildEvent: for %%i in (cl.exe) do @echo CMAKE_C_COMPILER=%%~$PATH:i :VCEnd CMAKE_C_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe FinalizeBuildStatus: Deleting file "Debug\CompilerIdC.tlog\unsuccessfulbuild". Touching "Debug\CompilerIdC.tlog\CompilerIdC.lastbuildstate". Done Building Project "C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdC\CompilerIdC.vcxproj" (default targets).

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:00.86

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.exe"

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CompilerIdC.vcxproj"

The C compiler identification is MSVC, found in "C:/ik/src/micro-profiler/_build/CMakeFiles/3.24.3/CompilerIdC/CompilerIdC.exe"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. Compiler:
Build flags: Id flags:

The output was: 0 MSBuild version 17.4.3+7e646be43 for .NET Framework Build started 2023-09-22 11:46:35. Project "C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets). PrepareForBuild: Creating directory "Debug\". Creating directory "Debug\CompilerIdCXX.tlog\". InitializeBuildStatus: Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\" /Fd"Debug\vc143.pdb" /external:W0 /Gd /TP /FC /errorReport:queue CMakeCXXCompilerId.cpp CMakeCXXCompilerId.cpp Link: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdCXX.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdCXX.lib" /MACHINE:X64 Debug\CMakeCXXCompilerId.obj CompilerIdCXX.vcxproj -> C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdCXX\CompilerIdCXX.exe PostBuildEvent: for %%i in (cl.exe) do @echo CMAKE_CXX_COMPILER=%%~$PATH:i :VCEnd CMAKE_CXX_COMPILER=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe FinalizeBuildStatus: Deleting file "Debug\CompilerIdCXX.tlog\unsuccessfulbuild". Touching "Debug\CompilerIdCXX.tlog\CompilerIdCXX.lastbuildstate". Done Building Project "C:\ik\src\micro-profiler_build\CMakeFiles\3.24.3\CompilerIdCXX\CompilerIdCXX.vcxproj" (default targets).

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:00.80

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.exe"

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CompilerIdCXX.vcxproj"

The CXX compiler identification is MSVC, found in "C:/ik/src/micro-profiler/_build/CMakeFiles/3.24.3/CompilerIdCXX/CompilerIdCXX.exe"

Detecting C compiler ABI info compiled with the following output: Change Dir: C:/ik/src/micro-profiler/_build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_89024.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.4.3+7e646be43 for .NET Framework

Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31947 for x64

CMakeCCompilerABI.c

Copyright (C) Microsoft Corporation. All rights reserved.

cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_89024.dir\Debug\" /Fd"cmTC_89024.dir\Debug\vc143.pdb" /external:W3 /Gd /TC /errorReport:queue "C:\Program Files\CMake\share\cmake-3.24\Modules\CMakeCCompilerABI.c"

cmTC_89024.vcxproj -> C:\ik\src\micro-profiler_build\CMakeFiles\CMakeTmp\Debug\cmTC_89024.exe

Detecting CXX compiler ABI info compiled with the following output: Change Dir: C:/ik/src/micro-profiler/_build/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_c834e.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.4.3+7e646be43 for .NET Framework

Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31947 for x64

CMakeCXXCompilerABI.cpp

Copyright (C) Microsoft Corporation. All rights reserved.

cl /c /Zi /W3 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_c834e.dir\Debug\" /Fd"cmTC_c834e.dir\Debug\vc143.pdb" /external:W3 /Gd /TP /errorReport:queue "C:\Program Files\CMake\share\cmake-3.24\Modules\CMakeCXXCompilerABI.cpp"

cmTC_c834e.vcxproj -> C:\ik\src\micro-profiler_build\CMakeFiles\CMakeTmp\Debug\cmTC_c834e.exe

Checking whether the ASM_MASM compiler is MSVC using "-?" matched "Microsoft": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

    ML64 [ /options ] filelist [ /link linkoptions ]

/Bl Use alternate linker /Sf Generate first pass listing /c Assemble without linking /Sl Set line width /Cp Preserve case of user identifiers /Sn Suppress symbol-table listing /Cx Preserve case in publics, externs /Sp Set page length /D[=text] Define text macro /Ss Set subtitle /EP Output preprocessed listing to stdout /St Set title /F Set stack size (bytes) /Sx List false conditionals /Fe Name executable /Ta Assemble non-.ASM file /Fl[file] Generate listing /w Same as /W0 /WX /Fm[file] Generate map /WX Treat warnings as errors /Fo Name object file /W Set warning level /Fr[file] Generate limited browser info /X Ignore INCLUDE environment path /FR[file] Generate full browser info /Zd Add line number debug info /I Add include path /Zf Make all symbols public /link /Zi Add symbolic debug info /nologo Suppress copyright message /Zp[n] Set structure alignment /Sa Maximize source listing /Zs Perform syntax check only /ZH:MD5 Use MD5 for checksum in debug info /ZH:SHA_256 Use SHA256 for checksum in debug info (default) /Gy[-] separate functions for linker /errorReport:

Checking whether the ASM_MASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is Clang using "--version" did not match "(clang version)": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is AppleClang using "--version" did not match "(Apple LLVM version)": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is ARMClang using "--version" did not match "armclang": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is HP using "-V" did not match "HP C": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : -V MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is Intel using "--version" did not match "(ICC)": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is IntelLLVM using "--version" did not match "(Intel[^ ]+oneAPI)": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : --version MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is SunPro using "-V" did not match "Sun C": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : -V MASM : fatal error A1017:missing source filename Checking whether the ASM_MASM compiler is XL using "-qversion" did not match "XL C": Microsoft (R) Macro Assembler (x64) Version 14.34.31947.0 Copyright (C) Microsoft Corporation. All rights reserved.

MASM : warning A4018:invalid command-line option : -qversion MASM : fatal error A1017:missing source filename

LouisStrous commented 3 months ago

I got the code to compile as follows with Visual Studio 2022 LTSC 17.8.11 on Windows 11, using your tips:

  1. Install conan version 1.59.0.
  2. Install cmake version 3.24.3.
  3. Git clone the repository. via git clone --recurse-submodules https://github.com/tyoma/micro-profiler.git. It is at commit v2.0.651.0-154-g1fb1b5ed in branch "master". The local copy of the repository ends up in subdirectory "micro-profiler" of the current working directory.
  4. Create subdirectory "micro-profiler\_build", go into that directory, then run cmake ...
  5. Then run cmake --build .. This produces "micro-profiler_x64.dll" and various other things in "micro-profiler\_build\_bin".

I managed (with some hackery) to create a VSIX file and install it into Visual Studio but that didn't lead to any successful profiling run.

I then tried to use the micro-profiler as follows without integration into Visual Studio, using a combination of the various options that you describe, but that didn't work, either:

  1. Add the /GH and /Gh flags to the compilation of the application I wish to profile.
  2. Add the "micro-profiler\_build\_bin\micro-profiler_x64.lib" to the linking of the application I wish to profile.
  3. Build the application.
  4. Define environment variable MICROPROFILERFRONTEND with value "sockets|127.0.0.1:6100".
  5. Add the absolute path of the "micro-profiler\_build\_bin" folder to the PATH environment variable.
  6. Copy "micro-profiler\_build\_bin\micro-profiler_x64.dll" next to my application.
  7. Open a new CMD shell (so it gets the new environment variables) and start my application.

The build succeeded but when I ran my application I did not see anything to show that the micro-profiler was active. Any ideas what I'm doing wrong?