IWYU successfully run on Windows

1,241 views
Skip to first unread message

Philip Craig

unread,
May 12, 2011, 1:33:47 PM5/12/11
to include-wh...@googlegroups.com
Built by using cmake to generate .sln and .vcproj for Clang (visual studio 2008)
 
Then adding an IWYU .vcproj for the IWYU files, and adding the llvm and clang headers and libs to the project
 
When running IWYU, I have to use the cygwin C++ headers (as Clang can't parse the windows non-standard C++ headers)
 
Just an FYI for anyone interested.

Kim Gräsman

unread,
May 12, 2011, 4:07:16 PM5/12/11
to include-wh...@googlegroups.com
Excellent! I've been wanting to get both clang and iwyu to run on
Windows, but I've been stuck on clang's inability to parse Microsoft's
SCL headers. Could you give some more info on how you hooked it up
with cygwin?

Thanks,
- Kim

Craig Silverstein

unread,
May 12, 2011, 5:49:49 PM5/12/11
to include-wh...@googlegroups.com

I'm not sure I understand it (I don't program windows), but this
sounds like it could be very useful! If you can write it up in more
detail, I'll be glad to add it to the project-page wiki.

craig

Philip Craig

unread,
May 14, 2011, 5:42:35 PM5/14/11
to include-wh...@googlegroups.com
Steps were not too hard:

1) Build LLVM and Clang as it says to on the Clang Windows Development howto page. You'll need cmake. Once done, you'll have a Visual Studio solution with about 113 libraries for llvm and clang.

2) Make a new IWYU .vcproj as part of that solution. Add the IWYU source to the IWYU .vcproj. Add the llvm and clang libraries mentioned in the original IWYU makefile to the list of link libraries, changing the suffix from the linux .a to the Windows .lib.

3) Remove/replace linux-isms in the IWYU code that are non portable. Find a getopt replacement for Windows. Replace fnmatch with some other windows code (I used boost filesystem, but you don't have to).

4) Build, fix errors, repeat

5) When running IWYU, you have to put standard c++ headers from cygwin on the include path, as Clang can't handle the non standard c++ constructs in the microsoft standard c++ headers.

6) Enjoy your Windows version of IWYU!

Craig Silverstein

unread,
May 15, 2011, 5:58:05 PM5/15/11
to include-wh...@googlegroups.com
} Steps were not too hard:

Thanks! I updated the wiki.

craig

Paul Holden

unread,
May 17, 2011, 2:47:37 AM5/17/11
to include-wh...@googlegroups.com
FWIW, my steps are very similar, but I use the attached patch (applied
to the Clang source tree) to take care of step 2). It's a bit less
fiddly than manually setting up all of the libraries by hand.

For 5), I took a slightly different approach and used MinGW headers in
place of Cygwin. I developed a set of headers (also attached) to
provide compatibility between mingw (latest version from
http://sourceforge.net/projects/mingw/files/) with libc++ (svn HEAD
from http://llvm.org/svn/llvm-project/libcxx/trunk). I compile by
using the options in opts.rsp which you can pass to Clang/IWYU with
"@opts.rsp".

Paul

add_iwyu_as_tool.patch
clang_mingw_libcxx_compatibility.zip
opts.rsp

Kim Gräsman

unread,
May 25, 2011, 4:17:56 PM5/25/11
to include-wh...@googlegroups.com
Philip and Paul,

Thanks for your detailed descriptions!

I've had a busy week, so I haven't had time to try this, but I will
make another attempt at setting this up when there's time...

Cheers,
- Kim

Reply all
Reply to author
Forward
0 new messages