Issue 1264 in include-what-you-use: Integrating iwyu 0.20 in CMake build system fails on an assertion

23 views
Skip to first unread message

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

unread,
Jun 22, 2023, 9:30:47 PM6/22/23
to include-wh...@googlegroups.com
New issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

It configures successfully, the the build fails on:

```
Error running 'include-what-you-use': /builddir/build/BUILD/include-what-you-use-0.20/iwyu.cc:3735: Assertion failed: sema.getCurScope() != nullptr
```

Details in https://bugzilla.redhat.com/show_bug.cgi?id=2215937.


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

unread,
Jun 24, 2023, 5:18:25 AM6/24/23
to include-wh...@googlegroups.com
Comment #1 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Curious. That assertion guards an expected invariant in the Clang state, so it could be that it changed at some point. Do you have a way of knowing which Clang version IWYU was built against? Is it latest stable (16) or with Fedora-specific patches?

I'm building Clang mainline locally to test on my Ubuntu system now.

Also, the Fedora bug report says this happens for all projects, and Transmission was chosen at random... Can you try building IWYU from source on the Fedora 38 system, and running its test suite? Same result?


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

unread,
Jun 24, 2023, 7:59:06 AM6/24/23
to include-wh...@googlegroups.com
Comment #2 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

It's just the iwyu package provided in the Fedora repository.

Running `include-what-you-use --version` gives the following info:

```
include-what-you-use 0.20 based on clang version 16.0.5 (Fedora 16.0.5-1.fc38)
```

And looking at the [sources](https://src.fedoraproject.org/rpms/llvm/tree/ba5f101283f102da636c7006619244d15fac76aa) of the llvm 16.0.5 package, it looks like the local patches are affecting gtest and markdown docs.

Anything else you need to know?


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

unread,
Jun 24, 2023, 7:59:41 AM6/24/23
to include-wh...@googlegroups.com
And looking at the [sources](https://src.fedoraproject.org/rpms/llvm/tree/ba5f101283f102da636c7006619244d15fac76aa) of the llvm 16.0.5 package, it looks like the local patches are affecting gtest and markdown docs only. I am not familiar with the Fedora packaging process though, so I may miss something.

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

unread,
Jun 24, 2023, 8:03:13 AM6/24/23
to include-wh...@googlegroups.com
Comment #3 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

No issues on Ubuntu with LLVM built from source... :thinking:. I can give 16.0.5 a shot too, but I suspect it's something unique to the Fedora package (either IWYU or Clang).

Any chance you can build IWYU from source? If you have lib packages of Clang available, it doesn't take long.


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

unread,
Jun 25, 2023, 3:36:24 AM6/25/23
to include-wh...@googlegroups.com
Comment #4 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> Do you have a way of knowing which Clang version IWYU was built against?

Built against llvm-16.0.0-2.fc38.
Current version: llvm-16.0.5-1.fc38.

> Is it latest stable (16) or with Fedora-specific patches?

We don't use any downstream patches for include-what-you-use.

> No issues on Ubuntu with LLVM built from source

Can you try building with the following flags: `-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS`.

Fedora's build flags:

```
export CFLAGS='-O2 -flto=thin -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
export CXXFLAGS='-O2 -flto=thin -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
export LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -flto=thin -fno-openmp-implicit-rpath -Wl,--build-id=sha1 '
```


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

unread,
Jun 25, 2023, 3:38:54 AM6/25/23
to include-wh...@googlegroups.com
Comment #4 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> Do you have a way of knowing which Clang version IWYU was built against?

Built against llvm-16.0.0-2.fc38.
Current version: llvm-16.0.5-1.fc38.

> Is it latest stable (16) or with Fedora-specific patches?

We don't use any downstream patches for include-what-you-use.

> No issues on Ubuntu with LLVM built from source

Can you try building with the following flags: `-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS`?

Fedora's build flags:

```bash

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

unread,
Jun 25, 2023, 4:05:10 AM6/25/23
to include-wh...@googlegroups.com
Comment #5 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Tried to replicate Fedora's build for iwyu (minus the local patches), but I am failing to get iwyu output in the Transmission build. What am I doing wrong?

1. Fresh install Fedora 38 Server with the "C Development Tools and Libraries" group selected.
2. Update all packages: `sudo dnf upgrade --refresh`
3. Install required packages: `sudo dnf install cmake git libcurl-devel openssl-devel llvm-devel clang-devel`
4. Clone iwyu: `git clone https://github.com/include-what-you-use/include-what-you-use.git`
5. Checkout `clang_16` branch: `cd include-what-you-use/ && git checkout clang_16`
6. Configure iwyu CMake: `cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_PREFIX_PATH=/usr/lib64` (Note that I replaced `IWYU_LLVM_ROOT_PATH` with `CMAKE_PREFIX_PATH`)
7. Build iwyu: `cmake --build build/`
8. Install iwyu: `sudo cmake --install build/`
9. Clone Transmission: `cd && git clone --recurse-submodules https://github.com/transmission/transmission.git Transmission && cd Transmission/`
10. Configure Transmission CMake: `cmake -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use -DCMAKE_C_INCLUDE_WHAT_YOU_USE=include-what-you-use -DCMAKE_BUILD_TYPE=RelWithDebInfo`
11. Build Transmission with verbose commands: `cmake --build build/ -- VERBOSE=1`

I can see CMake trying to run iwyu, but there are no iwyu output:

```bash
# Snippet of Transmission build output

cd /home/f38-test/Transmission/build/libtransmission && /usr/bin/cmake -E __run_co_compile --iwyu="include-what-you-use;--driver-mode=g++" -- /usr/lib64/ccache/c++ -DFMT_EXCEPTIONS=0 -DFMT_HEADER_ONLY=1 -DHAVE_COPY_FILE_RANGE -DHAVE_FALLOCATE64 -DHAVE_FLOCK -DHAVE_GETMNTENT -DHAVE_GETTEXT -DHAVE_LIBINTL_H -DHAVE_MKDTEMP -DHAVE_NGETTEXT -DHAVE_POSIX_FADVISE -DHAVE_POSIX_FALLOCATE -DHAVE_PREAD -DHAVE_PWRITE -DHAVE_SENDFILE64 -DHAVE_SO_REUSEPORT=1 -DHAVE_STATVFS -DHAVE_SYS_STATVFS_H -DMINIUPNP_STATICLIB -DNATPMP_STATICLIB -DPACKAGE_DATA_DIR=\"/usr/local/share\" -DPOSIX -DSMALL_DISABLE_EXCEPTIONS=1 -DSYSTEM_MINIUPNP -DWIDE_INTEGER_DISABLE_FLOAT_INTEROP -DWIDE_INTEGER_DISABLE_IOSTREAM -DWITH_INOTIFY -DWITH_UTP -D__TRANSMISSION__ -I/home/f38-test/Transmission/libtransmission/.. -I/home/f38-test/Transmission/build/libtransmission/.. -I/home/f38-test/Transmission/third-party/libutp/include -I/home/f38-test/Transmission/third-party/libb64/include -I/home/f38-test/Transmission/third-party/json
sl -I/home/f38-test/Transmission/third-party/wildmat -isystem /home/f38-test/Transmission/build/third-party/libdeflate.bld/pfx/include -isystem /home/f38-test/Transmission/cmake/../third-party/fast_float/include -isystem /home/f38-test/Transmission/build/third-party/libpsl.bld/pfx/include -isystem /home/f38-test/Transmission/build/third-party/libnatpmp.bld/pfx/include -isystem /home/f38-test/Transmission/build/third-party/miniupnpc.bld/pfx/include -isystem /home/f38-test/Transmission/build/third-party/dht.bld/pfx/include -isystem /home/f38-test/Transmission/cmake/../third-party/utfcpp/source -isystem /home/f38-test/Transmission/cmake/../third-party/wide-integer -isystem /home/f38-test/Transmission/cmake/../third-party/fmt/include -isystem /home/f38-test/Transmission/cmake/../third-party/small/include -isystem /home/f38-test/Transmission/build/third-party/libevent.bld/pfx/include -O2 -g -DNDEBUG -std=gnu++17 -W -Wall -Wextra -Wcast-align -Wduplicated-cond -Wextra-semi -Wfloat-equal -
Winit-self -Wint-in-bool-context -Wlogical-op -Wmissing-format-attribute -Wnull-dereference -Wpointer-arith -Wredundant-decls -Wredundant-move -Wrestrict -Wself-move -Wshadow -Wsign-compare -Wsuggest-override -Wuninitialized -Wunreachable-code -Wunused -Wunused-const-variable -Wunused-parameter -Wunused-result -Wwrite-strings -MD -MT libtransmission/CMakeFiles/transmission.dir/tr-udp.cc.o -MF CMakeFiles/transmission.dir/tr-udp.cc.o.d -o CMakeFiles/transmission.dir/tr-udp.cc.o -c /home/f38-test/Transmission/libtransmission/tr-udp.cc
```


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

unread,
Jun 25, 2023, 4:07:08 AM6/25/23
to include-wh...@googlegroups.com
```bash
$ which include-what-you-use
/usr/local/bin/include-what-you-use
$ include-what-you-use --version
include-what-you-use 0.20 (git:7301b1f) based on clang version 16.0.5 (Fedora 16.0.5-1.fc38)
```


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

unread,
Jun 25, 2023, 9:21:04 AM6/25/23
to include-wh...@googlegroups.com
Comment #6 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@tearfur Nice. Instead of running CMake through step 9 and onwards, can you run IWYU's own test suite? Something like:
```
/run_iwyu_tests.py -- build/bin/include-what-you-use
```
When in the IWYU source dir.


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

unread,
Jun 25, 2023, 9:22:24 AM6/25/23
to include-wh...@googlegroups.com
Comment #7 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@xvitaly Are those build flags for IWYU or LLVM/Clang, or both?


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

unread,
Jun 25, 2023, 12:05:50 PM6/25/23
to include-wh...@googlegroups.com
Comment #8 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> Nice. Instead of running CMake through step 9 and onwards, can you run IWYU's own test suite? Something like:

[iwyu_tests.txt](https://github.com/include-what-you-use/include-what-you-use/files/11860186/iwyu_tests.txt)



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

unread,
Jun 25, 2023, 12:16:38 PM6/25/23
to include-wh...@googlegroups.com
Comment #9 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> > Nice. Instead of running CMake through step 9 and onwards, can you run IWYU's own test suite? Something like:
>
> [iwyu_tests.txt](https://github.com/include-what-you-use/include-what-you-use/files/11860186/iwyu_tests.txt)

The failed tests are fixed after applying the following patch to the root `CMakeLists.txt`:

```bash
sed -e s@lib/@lib\${LLVM_LIBDIR_SUFFIX}/@g -i CMakeLists.txt
```


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

unread,
Jun 25, 2023, 12:20:36 PM6/25/23
to include-wh...@googlegroups.com
Comment #9 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> > Nice. Instead of running CMake through step 9 and onwards, can you run IWYU's own test suite? Something like:
>
> [iwyu_tests.txt](https://github.com/include-what-you-use/include-what-you-use/files/11860186/iwyu_tests.txt)

The failed tests are fixed after applying the following patch to the root `CMakeLists.txt` ([Ref](https://src.fedoraproject.org/rpms/iwyu/blob/8e98d187a58e201796f9d9af0d8e5ecf142f8d9e/f/iwyu.spec#_46)):

```bash
sed -e s@lib/@lib\${LLVM_LIBDIR_SUFFIX}/@g -i CMakeLists.txt
```

Still no iwyu output in Transmission build though.


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

unread,
Jun 25, 2023, 12:27:11 PM6/25/23
to include-wh...@googlegroups.com
Comment #10 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Is it possible that this is a problem triggered by something special in Transmission? I got the sense that you couldn't run IWYU for _any_ inputs on Fedora.


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

unread,
Jun 25, 2023, 12:28:16 PM6/25/23
to include-wh...@googlegroups.com
Comment #11 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Well to be fair, the other project I tried was x265, and I assumed it happens for all projects because they are so different.


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

unread,
Jun 25, 2023, 12:30:48 PM6/25/23
to include-wh...@googlegroups.com
Comment #11 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Well to be fair, the other project I tried was x265, and I assumed it happens for all projects because they are so different.

I admit I was probably jumping to conclusions a bit too quick there.


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

unread,
Jun 25, 2023, 12:52:31 PM6/25/23
to include-wh...@googlegroups.com
Comment #12 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Anyway I just tested a minimal hello word project, and the assertion still failed.

For this test, other than replacing Transmission with the hello world project, the steps are identical with the original Fedora bug report.

[hello_word.zip](https://github.com/include-what-you-use/include-what-you-use/files/11860293/hello_word.zip)


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

unread,
Jun 25, 2023, 12:53:15 PM6/25/23
to include-wh...@googlegroups.com
Comment #12 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Anyway I just tested a minimal hello word project, and the assertion still failed.

For this test, other than replacing Transmission with the hello world project, the steps are identical with the original Fedora bug report.

[hello_world.zip](https://github.com/include-what-you-use/include-what-you-use/files/11860293/hello_word.zip)


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

unread,
Jun 25, 2023, 12:54:28 PM6/25/23
to include-wh...@googlegroups.com
Comment #12 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Anyway I just tested a minimal hello world project, and the assertion still failed.

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

unread,
Jun 25, 2023, 1:08:03 PM6/25/23
to include-wh...@googlegroups.com
Comment #13 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Ah, nice, thanks. I just cloned Transmission and followed your steps to run it through CMake -- it seems to work just fine on my Ubuntu system with IWYU master built with mainline LLVM (killed it after ~50% with lots of IWYU output).

So there must be something funky going on with the Clang libraries on Fedora. I just finished a build of llvm-16 in the background with the FORTIFY flags enabled, I'll try and build an `include-what-you-use` against that and see if anything falls out.




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

unread,
Jun 25, 2023, 1:18:49 PM6/25/23
to include-wh...@googlegroups.com
Comment #14 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Still seems to work as expected (turns out it was IWYU master HEAD + LLVM/Clang main HEAD + FORTIFY flags).

I tried to make sense of the Fedora config files used in the invocation there, I wonder if they enable some runtime hardening that breaks us somehow. Haven't found anything yet.


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

unread,
Jun 25, 2023, 1:51:31 PM6/25/23
to include-wh...@googlegroups.com
Comment #15 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

I looked into the Clang side of things, and as far as I can tell:

* The `CurScope` is owned by Sema but updated by `Parser`
* In `Parser::Initialize` a new scope is created for the translation unit
* it only seems to be reset to `nullptr` in `Parser`'s destructor
* when IWYU's `HandleTranslationUnit` is called, both the `Parser` and `Sema` instances in clang's `ParseAST.cpp` are definitely alive

So I don't think it's a use-after-free or anything like that.


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

unread,
Jun 25, 2023, 1:52:02 PM6/25/23
to include-wh...@googlegroups.com
Comment #16 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Hmm. There are some special paths if precompiled headers are enabled... Could it be something like that?


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

unread,
Jun 26, 2023, 12:19:39 AM6/26/23
to include-wh...@googlegroups.com
Comment #18 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@kimgr Any idea why I was not getting any iwyu output in my local build? If I get that sorted, then I can help confirm if the problem was with Fedora's iwyu build or the Fedora clang libraries.


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

unread,
Jun 26, 2023, 12:21:23 AM6/26/23
to include-wh...@googlegroups.com
Comment #18 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@kimgr Any idea why I was not getting any iwyu output when using my local iwyu build? If I get that sorted, then I can help confirm if the problem was with Fedora's iwyu build or the Fedora clang libraries.


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

unread,
Jun 26, 2023, 4:50:05 AM6/26/23
to include-wh...@googlegroups.com
Comment #19 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@tearfur I don't have any working theory there :). It might be easier to troubleshoot without CMake in the middle, so you could try generating a compilation database and using `iwyu_tool.py -v` to get an actual `include-what-you-use` command that works for a source file. Once you have the full command, it's easier to debug. There are instructions for creating and running with a compilation database here: https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md#using-with-a-compilation-database.


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

unread,
Jun 26, 2023, 8:02:06 AM6/26/23
to include-wh...@googlegroups.com
Comment #20 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@kimgr Can't get that to work either. 😢

```
[f38-test@f38-test build]$ CC="clang" CXX="clang++" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
-- The C compiler identification is Clang 16.0.5
-- The CXX compiler identification is Clang 16.0.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/f38-test/hello_word/build
[f38-test@f38-test build]$ iwyu_tool.py -v -p compile_commands.json
# /usr/local/bin/include-what-you-use -o CMakeFiles/hello_word.dir/main.cpp.o -c /home/f38-test/hello_word/main.cpp
In file included from /home/f38-test/hello_word/main.cpp:1:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/iostream:41:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/ostream:40:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/ios:40:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/iosfwd:42:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/bits/postypes.h:40:
In file included from /usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/cwchar:44:
/usr/include/wchar.h:35:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
^~~~~~~~~~
```


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

unread,
Jun 26, 2023, 8:38:16 AM6/26/23
to include-wh...@googlegroups.com
Comment #21 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@tearfur IWYU via Clang needs the compiler builtin headers in dirname(executable)/../lib/clang/<version>/include, so in your case they should probably go in `/usr/local/lib/clang/17/include` -- could also be `/16/`, depending on how you configured your `include-what-you-use` build.

The IWYU build tries to copy the relevant headers into the build tree, but does not yet install them to the install tree (because they're really a Clang dependency, not an IWYU dependency).

There's some more background on this in https://github.com/include-what-you-use/include-what-you-use/blob/master/README.md#how-to-install.


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

unread,
Jun 26, 2023, 9:37:11 AM6/26/23
to include-wh...@googlegroups.com
Comment #22 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@xvitaly @tearfur I wonder if there could be some configuration differences between the LLVM/Clang packages and the IWYU package such that e.g. LLVM is built with `NDEBUG` defined, and IWYU not; some symbols affect the layout/size of objects, and cause confusion around member offsets, which could lead to corruption like this.

Is it possible/easy to expand the full CFLAGS/CXXFLAGS for a source file in Clang package's Sema library vs. one in IWYU package to see if there are any potentially incompatible combinations?


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

unread,
Jun 26, 2023, 9:54:43 AM6/26/23
to include-wh...@googlegroups.com
Comment #23 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@kimgr I see Fedora packages are all compiled with `-frecord-gcc-switches`, so [this stackoverflow answer](https://stackoverflow.com/a/12112479/11390656) should be perfect.


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

unread,
Jun 26, 2023, 10:49:28 AM6/26/23
to include-wh...@googlegroups.com
Comment #24 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> @xvitaly @tearfur I wonder if there could be some configuration differences between the LLVM/Clang packages and the IWYU package such that e.g. LLVM is built with NDEBUG defined, and IWYU not; some symbols affect the layout/size of objects, and cause confusion around member offsets, which could lead to corruption like this.

Maybe the problem is `-fno-omit-frame-pointer`. LLVM [opts out of this change](https://src.fedoraproject.org/rpms/llvm/blob/rawhide/f/llvm.spec#_7) and include-what-you-use doesn't.

I can try rebuilding iwyu with `%undefine _include_frame_pointers` in SPEC.


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

unread,
Jun 26, 2023, 11:05:35 AM6/26/23
to include-wh...@googlegroups.com
Comment #25 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@tearfur Can you try [this build](https://koji.fedoraproject.org/koji/taskinfo?taskID=102615197)? Compiled without frame pointers.

Installation method:

```
sudo dnf remove iwyu
sudo dnf install https://kojipkgs.fedoraproject.org/work/tasks/5272/102615272/iwyu-0.20-1.fc38.x86_64.rpm
```

All tests passed:
```
174/177 Test #94: cxx.test_no_char_traits ........................... Passed 0.82 sec
175/177 Test #177: iwyu_tool_test .................................... Passed 0.65 sec
176/177 Test #120: cxx.test_quoted_includes_first .................... Passed 0.91 sec
177/177 Test #114: cxx.test_precomputed_tpl_args ..................... Passed 0.95 sec
100% tests passed, 0 tests failed out of 177
```


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

unread,
Jun 26, 2023, 12:37:34 PM6/26/23
to include-wh...@googlegroups.com
Comment #27 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

@xvitaly Out of curiosity, did the IWYU test suite pass with the baseline config with framepointers enabled?


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

unread,
Jun 26, 2023, 1:52:20 PM6/26/23
to include-wh...@googlegroups.com
Comment #28 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> @xvitaly Out of curiosity, did the IWYU test suite pass with the baseline config with framepointers enabled?

[Yes](https://kojipkgs.fedoraproject.org//packages/iwyu/0.20/1.fc38/data/logs/x86_64/build.log).


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

unread,
Jun 26, 2023, 2:10:22 PM6/26/23
to include-wh...@googlegroups.com
Comment #29 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> It worked

Should be fixed now: https://bodhi.fedoraproject.org/updates/FEDORA-2023-a92562d0ea


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

unread,
Jun 26, 2023, 2:10:33 PM6/26/23
to include-wh...@googlegroups.com
Comment #29 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> It worked

Thanks for testing. Should be fixed now: https://bodhi.fedoraproject.org/updates/FEDORA-2023-a92562d0ea


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

unread,
Jun 26, 2023, 3:18:02 PM6/26/23
to include-wh...@googlegroups.com
Comment #30 on issue 1264 by kimgr: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

I can't really build the story for why this symptom would show only on non-test code, but :shrug:. Seems like a good thing to keep configs in sync. Not much we can do in upstream IWYU anyway, right?


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

unread,
Jun 26, 2023, 3:44:39 PM6/26/23
to include-wh...@googlegroups.com
Comment #31 on issue 1264 by xvitaly: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

> Not much we can do in upstream IWYU anyway, right?

I think this issue can be closed.


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

unread,
Jun 26, 2023, 7:09:27 PM6/26/23
to include-wh...@googlegroups.com
Comment #32 on issue 1264 by tearfur: Integrating iwyu 0.20 in CMake build system fails on an assertion
https://github.com/include-what-you-use/include-what-you-use/issues/1264

Thank you both for being helpful. 🎉


Reply all
Reply to author
Forward
0 new messages