Issue 1094 in include-what-you-use: IWYU picks up multiple Clang/LLVM installs

2 views
Skip to first unread message

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

unread,
Aug 9, 2022, 11:34:31 AMAug 9
to include-wh...@googlegroups.com
New issue 1094 by rchildre3: IWYU picks up multiple Clang/LLVM installs
https://github.com/include-what-you-use/include-what-you-use/issues/1094

Distro: `Ubuntu 20.04.4 LTS`

Installed Packages:
`apt search 'clang|llvm' | grep installed`
```
clang-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
clang-10-doc/focal,focal,now 1:10.0.0-4ubuntu1 all [installed]
clang-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
clang-format-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
clang-format-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
clang-tidy-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
clang-tidy-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
clang-tools-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
clang-tools-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
clangd-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
clangd-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
libclang-10-dev/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
libclang-12-dev/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
libclang-common-10-dev/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
libclang-common-12-dev/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
libclang-cpp10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
libclang-cpp10-dev/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
libclang-cpp12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
libclang1-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
libclang1-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed]
libllvm10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
libllvm12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
libomp-12-dev/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
libomp5-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
llvm-10/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
llvm-10-dev/focal,now 1:10.0.0-4ubuntu1 amd64 [installed]
llvm-10-runtime/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
llvm-10-tools/focal,now 1:10.0.0-4ubuntu1 amd64 [installed,automatic]
llvm-12/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
llvm-12-dev/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
llvm-12-doc/focal-updates,focal-updates,focal-security,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 all [installed]
llvm-12-linker-tools/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
llvm-12-runtime/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
llvm-12-tools/focal-updates,focal-security,now 1:12.0.0-3ubuntu1~20.04.5 amd64 [installed,automatic]
```
On IWYU branch `clang_12` (commit 78577f2)
with patch:
```diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 923b4d9..95322a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,6 +19,12 @@ if (NOT IWYU_IN_TREE)
find_package(LLVM CONFIG REQUIRED)
find_package(Clang CONFIG REQUIRED)

+ message(STATUS "LLVM_DIR: ${LLVM_DIR}")
+ message(STATUS "LLVM_DEFINITIONS: ${LLVM_DEFINITIONS}")
+ message(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
+ message(STATUS "LLVM_LIBRARY_DIR: ${LLVM_LIBRARY_DIR}")
+ message(STATUS "CLANG_INCLUDE_DIRS: ${CLANG_INCLUDE_DIRS}")
+
list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
include(AddLLVM)
```

Output of `cmake ../`:

```
..
-- LLVM_DIR: /usr/lib/llvm-12/cmake
-- LLVM_DEFINITIONS: -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- LLVM_INCLUDE_DIRS: /usr/lib/llvm-12/include
-- LLVM_LIBRARY_DIR: /usr/lib/llvm-12/lib
-- CLANG_INCLUDE_DIRS: /usr/lib/llvm-10/include
..
```
Note `CLANG_INCLUDE_DIRS`

I end up with both `llvm-12/include` and `llvm-10/include` in the compile step


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

unread,
Aug 9, 2022, 1:10:13 PMAug 9
to include-wh...@googlegroups.com
Comment #1 on issue 1094 by kimgr: IWYU picks up multiple Clang/LLVM installs
https://github.com/include-what-you-use/include-what-you-use/issues/1094

> Output of cmake ../:

That's not a supported cmake command, see https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md#how-to-build-standalone.


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

unread,
Aug 9, 2022, 2:19:20 PMAug 9
to include-wh...@googlegroups.com
Comment #2 on issue 1094 by rchildre3: IWYU picks up multiple Clang/LLVM installs
https://github.com/include-what-you-use/include-what-you-use/issues/1094

Noted, but seems like the version specific branches of IWYU should append the corresponding `/usr/lib/llvm-${VER}` to the `CMAKE_PREFIX_PATH` by default, would you agree?


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

unread,
Aug 9, 2022, 2:32:45 PMAug 9
to include-wh...@googlegroups.com
Comment #3 on issue 1094 by kimgr: IWYU picks up multiple Clang/LLVM installs
https://github.com/include-what-you-use/include-what-you-use/issues/1094

I'm not sure. It seems I would have to add that patch manually for every release branch. Or can you think of a nice way to make it self-discover?


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

unread,
Aug 9, 2022, 2:34:26 PMAug 9
to include-wh...@googlegroups.com
Comment #4 on issue 1094 by kimgr: IWYU picks up multiple Clang/LLVM installs
https://github.com/include-what-you-use/include-what-you-use/issues/1094

That said, I already do something similar for CI, e.g. https://github.com/include-what-you-use/include-what-you-use/commit/abd5d2bd6320867d3605227a7f798a4e08fef896, but I'd like to keep those kinds of changes to a minimum.


Reply all
Reply to author
Forward
0 new messages