Issue 956 in include-what-you-use: Any instruction how to build it on windows?

27 views
Skip to first unread message

notifi...@include-what-you-use.org

unread,
Oct 3, 2021, 9:08:10 AM10/3/21
to include-wh...@googlegroups.com
New issue 956 by xahon: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

I tried to blindly build it as a cmake project and it says it wants llvm package. I tried one from conan https://conan.io/center/search/llvm-core but it looks like it wants something else. Should I install llvm from official installer for windows or should I clone it and build myself? Definition `-DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-6.0`, what path should I pass in order to build it on windows?


notifi...@include-what-you-use.org

unread,
Oct 3, 2021, 9:17:03 AM10/3/21
to include-wh...@googlegroups.com
Comment #0 on issue 956 by kimgr: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

I think last I built on Windows, I built all of llvm+clang first and then used the build directory as CMAKE_PREFIX_PATH when I configured IWYU.


notifi...@include-what-you-use.org

unread,
Oct 3, 2021, 9:17:47 AM10/3/21
to include-wh...@googlegroups.com
Comment #2 on issue 956 by kimgr: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

It should work with MSVC, if it doesn't, bug reports and patches are welcome.


notifi...@include-what-you-use.org

unread,
Oct 6, 2021, 6:43:43 PM10/6/21
to include-wh...@googlegroups.com
Comment #3 on issue 956 by jonesmz: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

I happened to also be looking into how to do this.

Here's a *SUPER* janky script that I whipped together to get clang building on windows without needing to install external dependencies.
```bash
mkdir D:\builds\clang\
mkdir D:\builds\build-clang\
cd D:\builds\clang\

git clone --depth 1 --branch v1.2.11 https://github.com/madler/zlib.git
git clone --depth 1 --branch llvmorg-12.0.1 --config core.autocrlf=false https://github.com/llvm/llvm-project.git
git clone --depth 1 --branch 0.14 https://github.com/include-what-you-use/include-what-you-use.git

echo<<<EOF > D:\builds\clang\CMakeLists.txt
cmake_minimum_required(VERSION 3.12.0)
project(BuildClang)

add_subdirectory(zlib)

set(LLVM_ENABLE_PROJECTS "")
list(APPEND LLVM_ENABLE_PROJECTS clang)
list(APPEND LLVM_ENABLE_PROJECTS libcxx)
list(APPEND LLVM_ENABLE_PROJECTS libcxxabi)
list(APPEND LLVM_ENABLE_PROJECTS lldb)
list(APPEND LLVM_ENABLE_PROJECTS lld)
list(APPEND LLVM_ENABLE_PROJECTS polly)

set(LLVM_ENABLE_ZLIB ON)

set(LLVM_TARGETS_TO_BUILD "")
list(APPEND LLVM_TARGETS_TO_BUILD ARM)
list(APPEND LLVM_TARGETS_TO_BUILD AArch64)
list(APPEND LLVM_TARGETS_TO_BUILD X86)
list(APPEND LLVM_TARGETS_TO_BUILD BPF)
list(APPEND LLVM_TARGETS_TO_BUILD WebAssembly)

add_library(ZLIB::ZLIB ALIAS zlibstatic)
set(ZLIB_FOUND TRUE CACHE BOOL "")
get_target_property(INTERFACE_INCLUDE_DIRECTORIES zlibstatic ZLIB_INCLUDE_DIRS)
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
##
# The last thing that the FindPackage script does is set ZLIB_LIBRARY
# But CMake doesn't make it easy to figure out the destination path
# for the library at configuration time.
# E.G. this'll throw an error.
##
#get_target_property(ZLIB_LIBRARY zlibstatic LOCATION_${build_type})

##
# Alternatively, a replacement for FindZLIB.cmake could be dropped into a folder
# on the CMAKE_MODULE_PATH.
#
# With contents matching the above
##
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

add_subdirectory(llvm-project/llvm)

# iwyu's cmake script is all sorts of broken
#add_subdirectory(include-what-you-use)
EOF

cmake.exe -Thost=x64 -DCMAKE_BUILD_TYPE=Release -S D:\builds\clang -B D:\builds\build-clang\

cmake.exe --build D:\builds\build-clang\ --parallel
```bash


notifi...@include-what-you-use.org

unread,
Oct 6, 2021, 6:43:53 PM10/6/21
to include-wh...@googlegroups.com

notifi...@include-what-you-use.org

unread,
Oct 6, 2021, 6:44:13 PM10/6/21
to include-wh...@googlegroups.com
Comment #4 on issue 956 by jonesmz: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

If you have any luck getting include what you use to build during the clang build, please let me know!


notifi...@include-what-you-use.org

unread,
Oct 7, 2021, 2:01:04 AM10/7/21
to include-wh...@googlegroups.com
Comment #5 on issue 956 by kimgr: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

@jonesmz

> # iwyu's cmake script is all sorts of broken
> #add_subdirectory(include-what-you-use)

How so? I've worked so hard to make it all sorts of working 🙂


notifi...@include-what-you-use.org

unread,
Oct 7, 2021, 2:01:40 AM10/7/21
to include-wh...@googlegroups.com

notifi...@include-what-you-use.org

unread,
Oct 7, 2021, 2:56:15 PM10/7/21
to include-wh...@googlegroups.com
Comment #5 on issue 956 by kimgr: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

I think the README is mostly valid for Windows as well: https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md#how-to-build. The CMake details are just different.

* Clone and build Clang as per https://clang.llvm.org/get_started.html.
* Clone `include-what-you-use` to a separate tree
* Configure IWYU with CMake with `-DCMAKE_PREFIX_PATH=D:\clang\build\tree`

If there are any problems along the way there, please ask, and we can see if we can figure them out.


notifi...@include-what-you-use.org

unread,
Oct 7, 2021, 6:50:13 PM10/7/21
to include-wh...@googlegroups.com
Comment #7 on issue 956 by jonesmz: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

How can we build include-what-you-use as part of the same cmake tree that includes zlib and clang?


notifi...@include-what-you-use.org

unread,
Oct 8, 2021, 1:04:42 AM10/8/21
to include-wh...@googlegroups.com
Comment #7 on issue 956 by kimgr: Any instruction how to build it on windows?
https://github.com/include-what-you-use/include-what-you-use/issues/956

The procedure used to be to clone include-what-you-use inside clang/tools and add_subdirectory in its CMakeLists.txt. But I'm not sure of the exact motions since llvm/clang moved to git and its cmake system was modernized with LLVM_ENABLE_PROJECTS, etc.


Reply all
Reply to author
Forward
0 new messages