Skip to content

Include What You Use #1427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: develop
Choose a base branch
from
Draft

Include What You Use #1427

wants to merge 27 commits into from

Conversation

chapman39
Copy link
Collaborator

@chapman39 chapman39 commented Jul 25, 2025

Updating serac and system includes based on whether we're using them in the file directly using include-what-you-use.

This PR:

  • adds (or removes) standard library includes that's directly used (or not used) in each file
  • adds (or removes) serac includes that's directly used (or not used) in each file'
  • tries to group include headers by class header (if cpp), system, tpl, and project includes

also,

  • removes usage of using namespace serac::profiling; to better track profiling function usage (e.g. concat, SERAC_MARK_SCOPE, etc)

TODO

  • run iwyu again and double check things in functional and functional tests
  • going thru non-test serac_physics

my setup for iwyu

# build iwyu outside serac proj
git clone [email protected]:include-what-you-use/include-what-you-use.git
git checkout clang_14
cd include-what-you-use
mkdir build && cd build
module load clang/14.0.6
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/tce/packages/clang/clang-14.0.6 ..
srun -N1 make -j

# add build to path
# PATH=/usr/workspace/meemee/iwyu/include-what-you-use/build/bin/:$PATH
# PATH=/usr/workspace/meemee/iwyu/include-what-you-use/:$PATH

# build serac with clang 14
module load python
./config-build.py -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use
srun -N1 make -j 2> /tmp/iwyu.out
fix_includes.py -b < ../iwyu.out

after this, i one-by-one remove the comments and check if the header they added is worth adding or not. there is a --nocomments option, but it's useful to see why iwyu added the header.

workaround petsc circular includes

  • Petsc internally has a circular include error, so I commented out this error in the iwyu source. I emailed the petsc team so they could be aware of this.
  • Cycles are actually ignored in iwyu develop, but since we needed the clang_14 branch this workaround was needed.
Error running 'include-what-you-use': Cycle in include-mapping:
  <petscmacros.h> ->
  <petsc/private/petscadvancedmacros.h> ->
  <petsc/private/petscadvancedmacros.h>

@chapman39 chapman39 self-assigned this Jul 25, 2025
@chapman39 chapman39 added WIP Work in progress CS Computer science and software engineering labels Jul 25, 2025
#include "serac/serac_config.hpp"

#include <mpi.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <mpi.h>
#include "mpi.h"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i do the same for googletest headers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CS Computer science and software engineering WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants