Skip to content

Running iwyu on Bitcoin Core #15442

@maflcko

Description

@maflcko

There seems to be a lot of time wasted on discussing what headers to include and what headers not to include, so it would be nice to just have a tool that does that for us. iwyu is probably the closest to what I am looking for, but it is not straightforward to set up (see instructions below for Ubuntu). Let me know if the workflow could be simplified, so that is actually easily usable (maybe also on different distros).

iwyu makes a lot of changes, so it's best to run it manually and selectively on individual source files, rather than in some automated place like a travis script.

To install on Ubuntu/Debian: apt install iwyu.

Steps to install:

sudo apt install libclang-dev
cd ~/src
git clone github:include-what-you-use/include-what-you-use.git iwyu
cd iwyu
git checkout clang_3.8
mkdir build && cd build
cmake -DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-3.8 ..
make
sudo cp -aiv ~/src/iwyu/build/include-what-you-use /usr/lib/llvm-3.8/bin/

Steps to run:

cd ~/src/bitcoin/src
make
rm -v interface/libbitcoin_util_a-chain.o # run iwyu on interface/chain.cpp
make -k CXX="iwyu -std=c++17" 2>&1 | tee /tmp/iwyu
~/src/iwyu/fix_includes.py < /tmp/iwyu

Taken from #11878 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions