title: Why doesn't llvm-config on Windows emit the correct parameters for clang++.exe?
body: <p>I'm no experienced LLVM user, but I'm trying to compile a Linux LLVM project on Windows. The project is GHDL.</p>
  
  <p>Because ready-to-use LLVM installers for Windows don't have <code>llvm-config</code> bundled, I needed to compile LLVM and clange from sources. The project requires LLVM 3.5.</p>
  
  <p>So first, I downloaded <code>llvm-3.5.2</code> and <code>clang-3.5.2</code> and used CMake to translate it into Visual Studio 2013 projects. Then I used VS2013 to compile it.</p>
  
  <p>The original makefile calls <code>llvm-config</code>. The resulting string is passed to <code>clang++</code>:</p>
  
  <pre><code>clang++ -c -I`/usr/lib/llvm-3.5/bin/llvm-config --includedir --cflags --cxxflags` -o llvm-cbindings.o src/ortho/llvm/llvm-cbindings.cpp
  </code></pre>
  
  <p>I'm using PowerShell to call <code>llvm-config</code> and store the result in a variable:</p>
  
  <pre><code>$LLVM_CONFIG_RESULT = &amp; $LLVM_CONFIG --cxxflags
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>-IC:\Tools\LLVM-3.5/include  /DWIN32 /D_WINDOWS /W3     /MP -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -wd4146 -wd4180 -wd4244 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4503 -wd4624 -wd4722 -wd4800 -w14062 -we4238 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
  </code></pre>
  
  <p>I notice several problems:</p>
  
  <ol>
  <li>Some paths have <code>/</code> instead of <code>\</code><br>
  <code>-IC:\Tools\LLVM-3.5/include</code></li>
  <li>Some switches and parameters are used with <code>-</code> others with <code>/</code><br>
  <code>... -IC:\Tools\LLVM-3.5/include  /DWIN32 /D_WINDOWS ...</code></li>
  <li>Some parameters are delimited by more then one space sign<br>
  <code>... /W3     /MP ...</code></li>
  <li>clang++.exe prints errors on unknown arguments:
  
  <blockquote>
    <p>clang++.exe: error: unknown argument: '-wd4146'<br>
    clang++.exe: error: unknown argument: '-wd4180'<br>
    clang++.exe: error: unknown argument: '-wd4244'<br>
    clang++.exe: error: unknown argument: '-wd4267'<br>
    clang++.exe: error: unknown argument: '-wd4291'<br>
    clang++.exe: error: unknown argument: '-wd4345'<br>
    clang++.exe: error: unknown argument: '-wd4351'<br>
    clang++.exe: error: unknown argument: '-wd4355'<br>
    clang++.exe: error: unknown argument: '-wd4503'<br>
    clang++.exe: error: unknown argument: '-wd4624'<br>
    clang++.exe: error: unknown argument: '-wd4722'<br>
    clang++.exe: error: unknown argument: '-wd4800'<br>
    clang++.exe: error: unknown argument: '-w14062'<br>
    clang++.exe: error: unknown argument: '-we4238'</p>
  </blockquote></li>
  </ol>
  
  <p>The result is now included into the clang++.exe call, which causes errors.</p>
  
  <pre><code>Command: 'C:\Tools\LLVM-3.5\bin\clang++.exe -c -c -v -IC:\Tools\LLVM-3.5/include  /DWIN32 /D_WINDOWS /W3     /MP -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -wd4146 -wd4180 -wd4244 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4503 -wd4624 -wd4722 -wd4800 -w14062 -we4238 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o llvm-cbindings.o ../../src\ortho\llvm\llvm-bindings.cpp -o llvm-cbindings.o ../../src\ortho\llvm\llvm-cbindings.cpp'  
  clang++.exe: error: unknown argument: '-wd4146'  
  clang++.exe: error: unknown argument: '-wd4180'  
  clang++.exe: error: unknown argument: '-wd4244'  
  clang++.exe: error: unknown argument: '-wd4267'  
  clang++.exe: error: unknown argument: '-wd4291'  
  clang++.exe: error: unknown argument: '-wd4345'  
  clang++.exe: error: unknown argument: '-wd4351'  
  clang++.exe: error: unknown argument: '-wd4355'  
  clang++.exe: error: unknown argument: '-wd4503'  
  clang++.exe: error: unknown argument: '-wd4624'  
  clang++.exe: error: unknown argument: '-wd4722'  
  clang++.exe: error: unknown argument: '-wd4800'  
  clang++.exe: error: unknown argument: '-w14062'  
  clang++.exe: error: unknown argument: '-we4238'  
  clang version 3.5.2 (tags/RELEASE_352/final)  
  Target: i686-pc-windows-msvc  
  Thread model: posix  
  clang++.exe: error: no such file or directory: '/DWIN32'  
  clang++.exe: error: no such file or directory: '/D_WINDOWS'  
  clang++.exe: error: no such file or directory: '/W3'  
  clang++.exe: error: no such file or directory: '/MP'  
  </code></pre>
  
  <p><strong>So here are my questions:</strong></p>
  
  <ul>
  <li>Why does <code>llvm-config</code> emit false results on Windows?</li>
  <li>How can I fix it?</li>
  <li>What are these <code>-wd***</code> switches for?</li>
  </ul>