Bug 2215937

Summary: Using iwyu with CMake fails on an assertion
Product: [Fedora] Fedora Reporter: lagoho7
Component: iwyuAssignee: Vitaly Zaitsev <vitaly>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 38CC: vitaly
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: iwyu-0.20-2.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-28 01:15:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description lagoho7 2023-06-19 12:48:37 UTC
Integrating iwyu into a CMake build system using CMAKE_C_INCLUDE_WHAT_YOU_USE and CMAKE_CXX_INCLUDE_WHAT_YOU_USE fails on an assertion. It appears what you are building and what toolchain you are using are irrelevant.

The same steps work on Fedora 37.

Reproducible: Always

Steps to Reproduce:
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 iwyu git libcurl-devel openssl-devel
4. Clone a CMake project (I chose Transmission arbitrarily): git clone --recurse-submodules https://github.com/transmission/transmission.git Transmission
5. cd into the project: cd Transmission/
6. Configure 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
7. Start the build: cmake --build build
Actual Results:  
Build fails with the following error:

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

Expected Results:  
The build completes successfully with iwyu output. Tested on Fedora 37 to verify that my steps are correct.

Comment 1 Fedora Update System 2023-06-26 18:09:33 UTC
FEDORA-2023-a92562d0ea has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-a92562d0ea

Comment 2 Fedora Update System 2023-06-27 10:55:43 UTC
FEDORA-2023-a92562d0ea has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-a92562d0ea`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-a92562d0ea

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2023-06-28 01:15:50 UTC
FEDORA-2023-a92562d0ea has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.