can't build/run after adding lib to Fibonacci example, even reverting the complete llvm tree does not help

my build environment:

Win7 x64
VStudio 2017 Community Edition 15.8.4 (latest)
CMake 3.12.1 (x86)
git 2.19.0 (latest, x64)
Python 2.7.2 (x86)
x64 Native Tools Command Prompt for VS 2017

directory structure:

test
   llvm <-- git clone https://github.com/llvm-mirror/llvm, git checkout
release_70
     tools
       clang <-- git clone GitHub - llvm-mirror/clang: Mirror kept for legacy. Moved to https://github.com/llvm/llvm-project, git
checkout release_70
   llvm_build

build steps:

cd llvm_build
cmake -Thost=x64 -G "Visual Studio 15 2017 Win64"
-DLLVM_TARGETS_TO_BUILD=host -DLLVM_BUILD_EXAMPLES=1
-DCLANG_BUILD_EXAMPLES=1 -DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_DOCS=OFF ..\llvm
cmake --build . --config Debug

after building i open llvm-build\LLVM.sln in VS2017 ... loading 273 projects

question1: if left click on the solution root and select "build
solution" (to check if everyhing is built) two files
DummyClangFuzzer.cpp and ClangFuzzer.cpp getting compiled - is that
indendet?

then i want to add some tests to the Fibonacci example and added
IRReader to llvm\examples\Fibonacci\CMakeLists.txt

set(LLVM_LINK_COMPONENTS
  Core
  ExecutionEngine
  Interpreter
  MC
  MCJIT
  Support
  nativecodegen
  IRReader # <-- new
  )

and then build the Fibonacci example

but the build will fail with this log - even git revert on the llvm root does not get me back to an buildable state,
i tried to build the Fibonacci project and the solution

the projects ZERO_CHECK and Fibonacci giving these errors

Severity   Code   Description   Project   File   Line Suppression State
Error   MSB6006   "cmd.exe" exited with code -1073741819.
ZERO_CHECKÂ Â Â C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets
209
Severity   Code   Description   Project   File   Line Suppression State
Error   MSB6006   "cmd.exe" exited with code 1.   Fibonacci
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets 209

"DIA SDK not found" msg seems to be related to

but why do i (maybe) need to set the VSINSTALLDIR when inside of the IDE?

any ideas?

this is the log that is create

... many... generate.stamp is up-to-date.
1>CMake does not need to re-run because
D:/projects/fun/jit_tests/clang_from_src/llvm-build/runtimes/CMakeFiles/generate.stamp

is up-to-date.
1>CMake does not need to re-run because
D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/CMakeFiles/generate.stamp

is up-to-date.
1>CMake does not need to re-run because
D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/BrainF/CMakeFiles/generate.stamp

is up-to-date.
1>CMake is re-running because
D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/Fibonacci/CMakeFiles/generate.stamp

is out-of-date.
1>Â the file
'D:/projects/fun/jit_tests/clang_from_src/llvm/examples/Fibonacci/CMakeLists.txt'
1>Â is newer than
'D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/Fibonacci/CMakeFiles/generate.stamp.depend'
1>Â result='-1'
1>CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):
1>Â The OLD behavior for policy CMP0051 will be removed from a future
version
1>Â of CMake.
1>
1>Â The cmake-policies(7) manual explains that the OLD behaviors of all
1>Â policies are deprecated and that a policy should be set to OLD only
under
1> specific short-term circumstances. Projects should be ported to the NEW
1>Â behavior and not rely on setting a policy to OLD.
1>
1>-- Selecting Windows SDK version 10.0.17134.0 to target Windows 6.1.7601.
1>-- Could NOT find Backtrace (missing: Backtrace_LIBRARY
Backtrace_INCLUDE_DIR)
1>-- Native target architecture is X86
1>CMake Error at cmake/config-ix.cmake:466 (message):
1> DIA SDK not found. If you have both VS 2012 and 2013 installed, you may
1>Â need to uninstall the former and re-install the latter afterwards.
1>Call Stack (most recent call first):
1>Â CMakeLists.txt:600 (include)
1>
1>-- Configuring incomplete, errors occurred!
1>See also
"D:/projects/fun/jit_tests/clang_from_src/llvm-build/CMakeFiles/CMakeOutput.log".
1>See also
"D:/projects/fun/jit_tests/clang_from_src/llvm-build/CMakeFiles/CMakeError.log".
1>CMake Configure step failed. Build files cannot be regenerated
correctly. Attempting to stop IDE build.
1>C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5):

error MSB6006: "cmd.exe" exited with code -1073741819.
1>Done building project "ZERO_CHECK.vcxproj" -- FAILED.
2>------ Build started: Project: llvm_vcsrevision_h, Configuration:
Debug x64 ------
3>------ Build started: Project: intrinsics_gen, Configuration: Debug
x64 ------
4>------ Build started: Project: InstCombineTableGen, Configuration:
Debug x64 ------
5>------ Build started: Project: AttributeCompatFuncTableGen,
Configuration: Debug x64 ------
6>------ Build started: Project: X86CommonTableGen, Configuration: Debug
x64 ------
7>------ Build started: Project: Fibonacci, Configuration: Debug x64 ------
7>Building Custom Rule
D:/projects/fun/jit_tests/clang_from_src/llvm/examples/Fibonacci/CMakeLists.txt
7>CMake is re-running because
D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/Fibonacci/CMakeFiles/generate.stamp

is out-of-date.
7>Â the file
'D:/projects/fun/jit_tests/clang_from_src/llvm/examples/Fibonacci/CMakeLists.txt'
7>Â is newer than
'D:/projects/fun/jit_tests/clang_from_src/llvm-build/examples/Fibonacci/CMakeFiles/generate.stamp.depend'
7>Â result='-1'
7>CMake Deprecation Warning at CMakeLists.txt:14 (cmake_policy):
7>Â The OLD behavior for policy CMP0051 will be removed from a future
version
7>Â of CMake.
7>
7>Â The cmake-policies(7) manual explains that the OLD behaviors of all
7>Â policies are deprecated and that a policy should be set to OLD only
under
7> specific short-term circumstances. Projects should be ported to the NEW
7>Â behavior and not rely on setting a policy to OLD.
7>
7>-- Selecting Windows SDK version 10.0.17134.0 to target Windows 6.1.7601.
7>-- Could NOT find Backtrace (missing: Backtrace_LIBRARY
Backtrace_INCLUDE_DIR)
7>-- Native target architecture is X86
7>CMake Error at cmake/config-ix.cmake:466 (message):
7> DIA SDK not found. If you have both VS 2012 and 2013 installed, you may
7>Â need to uninstall the former and re-install the latter afterwards.
7>Call Stack (most recent call first):
7>Â CMakeLists.txt:600 (include)
7>
7>-- Configuring incomplete, errors occurred!
7>See also
"D:/projects/fun/jit_tests/clang_from_src/llvm-build/CMakeFiles/CMakeOutput.log".
7>See also
"D:/projects/fun/jit_tests/clang_from_src/llvm-build/CMakeFiles/CMakeError.log".
7>C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5):

error MSB6006: "cmd.exe" exited with code 1.
7>Done building project "Fibonacci.vcxproj" -- FAILED.
========== Build: 5 succeeded, 2 failed, 35 up-to-date, 0 skipped ==========

I might try compiling your source from the VS's Developer Command Prompt:

cmake --build . --target Fibonacci

Does this work?

Otherwise, there might be some workarounds. E.g. Unload the
"ZERO_CHECK" project from the IDE so it does not reconfigure (or just
run cmake from outside the IDE before building). Or start the IDE from
the Developer Command Prompt so the right environment variables are
set.

Michael

first: thank you for helping out

>I might try compiling your source from the VS's Developer Command Prompt:
>cmake --build . --target Fibonacci
>Does this work?

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
cd llvm-build
cmake --build . --config Debug --target Fibonacci

building Fibonacci example works BUT X86CommonTableGen get rebuild again?

Das Projekt "D:\projects\fun\jit_tests\clang_from_src\llvm-build\lib\Target\X86\InstPrinter\LLVMX86AsmPrinter.vcxproj" (37) erstellt "D:\projects\fun\jit_tests\clang_from_src\llvm-build\lib\Target\X86\X86CommonTableGen.vcxproj" (38) auf Knoten "1" (Standardziele).
InitializeBuildStatus:
"x64\Debug\X86CommonTableGen\X86Commo.1917F16D.tlog\unsuccessfulbuild" wird erstellt, da "AlwaysCreate" angegeben wurde.
CustomBuild:
Building X86GenAsmMatcher.inc...
Building X86GenAsmWriter.inc...
Building X86GenAsmWriter1.inc...
Building X86GenCallingConv.inc...
Building X86GenDAGISel.inc...
Building X86GenDisassemblerTables.inc...
Building X86GenEVEX2VEXTables.inc...
Building X86GenFastISel.inc...
Building X86GenGlobalISel.inc...
...
which costs me much time (>30min) on my slow system - and i don't understand why "AlwaysCreate" is used here - i only added one lib dependencie to an example and reverted it? now the totaly unrelated big one is build again
it could be that faster systems do not suffer that much from this behavior but it still does not feel right

enough RAM, no swapping, just my 2 core CPU is not fast enough

result: Fibonacci was built without errors

after building i reopened llvm-build\LLVM.sln in VS2017 ... loading 273 projects
and tested what happend on selecting "build solution" - to check what else happened to build now
serveral cpp getting compiled, libs/exes getting linked - i think that is related to the X86CommonTableGen rebuild
another >30min waiting to "finish building" the solution inside of the IDE

nearly enough RAM, started swapping on building lli.cpp :(, but get back to under 5GB Ram usage after some seconds, my 2 core CPU is still not fast enough

>Otherwise, there might be some workarounds. E.g. Unload the
>"ZERO_CHECK" project from the IDE so it does not reconfigure (or just
>run cmake from outside the IDE before building).
>Or start the IDE from
>the Developer Command Prompt so the right environment variables are
>set.

will check that later - it just costs me way too much time to get to this point (Fibonacci from outside, finish build of solution inside IDE), currently nearly 2 hours :frowning:

beside "i don't really know what im doing" and the short swapping problem the workflow/build optimization of the CMake scripts feels strange, not very optimal
is that a windows/VStudio generator only effect (and no one is using that, or everyone got more cores/RAM?) or how does this usually work? other CMake based projects do not behave like this on my system

as a side note: i also got VS2010 and VS2015 installed on my build system

first: thank you for helping out

>I might try compiling your source from the VS's Developer Command Prompt:
>cmake --build . --target Fibonacci
>Does this work?

call "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
cd llvm-build
cmake --build . --config Debug --target Fibonacci

building Fibonacci example works BUT X86CommonTableGen get rebuild again?

Das Projekt
"D:\projects\fun\jit_tests\clang_from_src\llvm-build\lib\Target\X86\InstPrinter\LLVMX86AsmPrinter.vcxproj"
(37) erstellt
"D:\projects\fun\jit_tests\clang_from_src\llvm-build\lib\Target\X86\X86CommonTableGen.vcxproj"
(38) auf Knoten "1" (Standardziele).
InitializeBuildStatus:
"x64\Debug\X86CommonTableGen\X86Commo.1917F16D.tlog\unsuccessfulbuild"
wird erstellt, da "AlwaysCreate" angegeben wurde.
CustomBuild:
   Building X86GenAsmMatcher.inc...
   Building X86GenAsmWriter.inc...
   Building X86GenAsmWriter1.inc...
   Building X86GenCallingConv.inc...
   Building X86GenDAGISel.inc...
   Building X86GenDisassemblerTables.inc...
   Building X86GenEVEX2VEXTables.inc...
   Building X86GenFastISel.inc...
   Building X86GenGlobalISel.inc...
   ...
which costs me much time (>30min) on my slow system - and i don't
understand why "AlwaysCreate" is used here - i only added one lib
dependencie to an example and reverted it? now the totaly unrelated big
one is build again
it could be that faster systems do not suffer that much from this
behavior but it still does not feel right

enough RAM, no swapping, just my 2 core CPU is not fast enough

No idea either why it re-reruns, but it should not be that much of an
issue and not re-run when you rebuild without changes to CMakeLists.
The debug version of tablegen is quite slow. You can either set
LLVM_TABLEGEN/CLANG_TABLEGEN to separately compiled release version of
them or use LLVM_OPTIMIZED_TABLEGEN which does that for you.

result: Fibonacci was built without errors

after building i reopened llvm-build\LLVM.sln in VS2017 ... loading 273
projects
and tested what happend on selecting "build solution" - to check what
else happened to build now
serveral cpp getting compiled, libs/exes getting linked - i think that
is related to the X86CommonTableGen rebuild
another >30min waiting to "finish building" the solution inside of the IDE

nearly enough RAM, started swapping on building lli.cpp :(, but get back
to under 5GB Ram usage after some seconds, my 2 core CPU is still not
fast enough

You may want to restrict the number of parallel project builds:
Options->Projects and Solutions->Build and Run->maximum number of
parallel build jobs

Michael

No idea either why it re-reruns, but it should not be that much of an
issue and not re-run when you rebuild without changes to CMakeLists.

i' will your other suggestions (with starting VStudio from commandline with VCVars set) if that helps

The debug version of tablegen is quite slow. You can either set
LLVM_TABLEGEN/CLANG_TABLEGEN to separately compiled release version of
them or use LLVM_OPTIMIZED_TABLEGEN which does that for you.

i'll give that a try

You may want to restrict the number of parallel project builds:
Options->Projects and Solutions->Build and Run->maximum number of
parallel build jobs

hope the build time will not raise again by a large margine using just 1 of my cores

thx