Skip to content
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

[ci] run include-what-you-use in CI #6284

Open
jameslamb opened this issue Jan 22, 2024 · 7 comments
Open

[ci] run include-what-you-use in CI #6284

jameslamb opened this issue Jan 22, 2024 · 7 comments

Comments

@jameslamb
Copy link
Collaborator

Summary

In early 2024, the R package was almost archived on CRAN because of a compiler warning from clang-18 resulting from an unnecessary #include <string>.

ref: #6264

This project should test running include-what-you-use (https://github.com/include-what-you-use/include-what-you-use) in CI to catch such things earlier.

Motivation

Removing unused includes in C/C++ code could have the following benefits:

  • smaller binary size
  • reduced risk of runtime failures caused by irrelevant ABI breakages
  • reducing build / linking times
  • reduced effort required to update to new C++ standards

Description

Consider adding that to the cpp_tests CI jobs, and maybe to the R-package CMake CI jobs.

Try reverting the change from #6265 and test if include-what-you-use would have caught it.

References

See the documentation at https://github.com/include-what-you-use/include-what-you-use?tab=readme-ov-file#using-with-cmake.

@jameslamb
Copy link
Collaborator Author

I tried this on my mac tonight.

Installed with Homebrew.

brew install include-what-you-use

Then ran the following (compiler = Apple clang version 13.0.0 (clang-1300.0.27.3)).

cmake \
    -B build \
    -S . \
    -DCMAKE_C_INCLUDE_WHAT_YOU_USE=include-what-you-use \
    -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use

cmake \
    --build build \
    --target _lightgbm \
    2>&1 \
| tee ./logs.txt \
| cat

That generated a lot of recommendations.

logs.txt (click me)
[  2%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/c_api.h should add these lines:
struct ArrowArray;
struct ArrowSchema;

/Users/jlamb/repos/LightGBM/include/LightGBM/c_api.h should remove these lines:
- #include <LightGBM/arrow.h>  // lines 16-16
- #include <cstring>  // lines 22-22

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/c_api.h:
#include <LightGBM/export.h>  // for LIGHTGBM_C_EXPORT
#include <cstdint>            // for int64_t, int32_t, uint8_t
#include <cstdio>             // for size_t, snprintf
struct ArrowArray;
struct ArrowSchema;
---

/Users/jlamb/repos/LightGBM/src/c_api.cpp should add these lines:
#include <__exception/exception.h>                         // for exception
#include <__mutex/unique_lock.h>                           // for unique_lock
#include <algorithm>                                       // for max, min
#include <cmath>                                           // for fabs, isnan
#include <cstring>                                         // for memcpy
#include <iterator>                                        // for advance
#include <unordered_map>                                   // for unordered_map
#include <utility>                                         // for pair, make...
#include "LightGBM/arrow.tpp"                              // for ArrowChunk...
#include "LightGBM/bin.h"                                  // for BinMapper
#include "LightGBM/meta.h"                                 // for kZeroThres...
#include "omp.h"                                           // for omp_get_th...

/Users/jlamb/repos/LightGBM/src/c_api.cpp should remove these lines:
- #include <LightGBM/prediction_early_stop.h>  // lines 15-15
- #include <LightGBM/utils/threading.h>  // lines 21-21
- #include <mutex>  // lines 27-27
- #include <stdexcept>  // lines 28-28

The full include-list for /Users/jlamb/repos/LightGBM/src/c_api.cpp:
#include <LightGBM/c_api.h>
#include <LightGBM/arrow.h>                                // for ArrowTable
#include <LightGBM/boosting.h>                             // for Boosting
#include <LightGBM/config.h>                               // for Config
#include <LightGBM/dataset.h>                              // for Dataset
#include <LightGBM/dataset_loader.h>                       // for DatasetLoader
#include <LightGBM/metric.h>                               // for Metric
#include <LightGBM/network.h>                              // for Network
#include <LightGBM/objective_function.h>                   // for ObjectiveF...
#include <LightGBM/utils/byte_buffer.h>                    // for ByteBuffer
#include <LightGBM/utils/common.h>                         // for Vector2Ptr
#include <LightGBM/utils/log.h>                            // for Log, CHECK_LT
#include <LightGBM/utils/openmp_wrapper.h>                 // for OMP_SET_NU...
#include <LightGBM/utils/random.h>                         // for Random
#include <__exception/exception.h>                         // for exception
#include <__mutex/unique_lock.h>                           // for unique_lock
#include <LightGBM/utils/yamc/alternate_shared_mutex.hpp>  // for shared_mutex
#include <LightGBM/utils/yamc/yamc_shared_lock.hpp>        // for shared_lock
#include <algorithm>                                       // for max, min
#include <cmath>                                           // for fabs, isnan
#include <cstdio>                                          // for size_t
#include <cstring>                                         // for memcpy
#include <functional>                                      // for function
#include <iterator>                                        // for advance
#include <memory>                                          // for unique_ptr
#include <string>                                          // for basic_string
#include <unordered_map>                                   // for unordered_map
#include <utility>                                         // for pair, make...
#include <vector>                                          // for vector
#include "LightGBM/arrow.tpp"                              // for ArrowChunk...
#include "LightGBM/bin.h"                                  // for BinMapper
#include "LightGBM/meta.h"                                 // for kZeroThres...
#include "application/predictor.hpp"                       // for Predictor
#include "omp.h"                                           // for omp_get_th...
---

[  2%] Built target lightgbm_capi_objs
[  5%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/boosting.h should add these lines:
#include <stddef.h>           // for size_t
#include <stdint.h>           // for int64_t
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/boosting.h should remove these lines:
- #include <LightGBM/config.h>  // lines 8-8
- #include <map>  // lines 12-12

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/boosting.h:
#include <LightGBM/meta.h>    // for score_t
#include <stddef.h>           // for size_t
#include <stdint.h>           // for int64_t
#include <string>             // for string
#include <unordered_map>      // for unordered_map
#include <vector>             // for vector
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { class Dataset; }  // lines 19-19
namespace LightGBM { class Metric; }  // lines 21-21
namespace LightGBM { class ObjectiveFunction; }  // lines 20-20
namespace LightGBM { struct Config; }
namespace LightGBM { struct PredictionEarlyStopInstance; }  // lines 22-22
---

/Users/jlamb/repos/LightGBM/src/boosting/boosting.cpp should add these lines:
#include <chrono>                        // for duration, operator*, operator-
#include <memory>                        // for unique_ptr
#include <ratio>                         // for ratio, milli
#include "LightGBM/utils/log.h"          // for Log
#include "LightGBM/utils/text_reader.h"  // for TextReader

/Users/jlamb/repos/LightGBM/src/boosting/boosting.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/boosting.cpp:
#include <LightGBM/boosting.h>
#include <chrono>                        // for duration, operator*, operator-
#include <memory>                        // for unique_ptr
#include <ratio>                         // for ratio, milli
#include "LightGBM/utils/log.h"          // for Log
#include "LightGBM/utils/text_reader.h"  // for TextReader
#include "dart.hpp"                      // for DART
#include "gbdt.h"                        // for GBDT
#include "rf.hpp"                        // for RF
---

[  8%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/boosting/gbdt.h should add these lines:
#include <__fwd/sstream.h>                  // for stringstream
#include <stdint.h>                         // for int64_t, int8_t
#include <sstream>                          // for operator<<, basic_ostream
#include <type_traits>                      // for __libcpp_remove_reference_t
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for score_t, data_size_t, kAl...
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/tree_learner.h"          // for TreeLearner
#include "LightGBM/utils/common.h"          // for Split, AlignmentAllocator
#include "LightGBM/utils/log.h"             // for CHECK, Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/random.h"          // for Random
namespace LightGBM { class Metric; }
namespace LightGBM { struct PredictionEarlyStopInstance; }

/Users/jlamb/repos/LightGBM/src/boosting/gbdt.h should remove these lines:
- #include <LightGBM/cuda/vector_cudahost.h>  // lines 11-11
- #include <LightGBM/prediction_early_stop.h>  // lines 10-10
- #include <LightGBM/utils/threading.h>  // lines 13-13
- #include <fstream>  // lines 19-19
- #include <map>  // lines 20-20
- #include <mutex>  // lines 22-22
- #include "cuda/cuda_score_updater.hpp"  // lines 27-27

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/gbdt.h:
#include <LightGBM/boosting.h>              // for GBDTBase
#include <LightGBM/objective_function.h>    // for ObjectiveFunction
#include <LightGBM/sample_strategy.h>       // for SampleStrategy
#include <LightGBM/utils/json11.h>          // for Json
#include <__fwd/sstream.h>                  // for stringstream
#include <stdint.h>                         // for int64_t, int8_t
#include <algorithm>                        // for min, max
#include <cstdio>                           // for size_t
#include <memory>                           // for unique_ptr, allocator
#include <sstream>                          // for operator<<, basic_ostream
#include <string>                           // for basic_string, char_traits
#include <type_traits>                      // for __libcpp_remove_reference_t
#include <unordered_map>                    // for unordered_map, __hash_map...
#include <utility>                          // for move, swap, pair
#include <vector>                           // for vector
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for score_t, data_size_t, kAl...
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/tree_learner.h"          // for TreeLearner
#include "LightGBM/utils/common.h"          // for Split, AlignmentAllocator
#include "LightGBM/utils/log.h"             // for CHECK, Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/random.h"          // for Random
#include "score_updater.hpp"                // for ScoreUpdater
namespace LightGBM { class Metric; }
namespace LightGBM { struct PredictionEarlyStopInstance; }
---

/Users/jlamb/repos/LightGBM/src/boosting/gbdt.cpp should add these lines:
#include <__fwd/fstream.h>                  // for ifstream
#include <cmath>                            // for fabs
#include <cstring>                          // for memset
#include <fstream>                          // for operator<<, basic_ostream
#include <functional>                       // for function
#include <ratio>                            // for milli
#include "LightGBM/cuda/vector_cudahost.h"  // for LGBM_config_, Use_Learner
#include "LightGBM/utils/json11.h"          // for Json
#include "omp.h"                            // for omp_get_thread_num

/Users/jlamb/repos/LightGBM/src/boosting/gbdt.cpp should remove these lines:
- #include <LightGBM/prediction_early_stop.h>  // lines 10-10
- #include <ctime>  // lines 16-16

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/gbdt.cpp:
#include "gbdt.h"
#include <LightGBM/metric.h>                // for Metric
#include <LightGBM/network.h>               // for Network
#include <LightGBM/objective_function.h>    // for ObjectiveFunction
#include <LightGBM/sample_strategy.h>       // for SampleStrategy
#include <LightGBM/utils/common.h>          // for AlignmentAllocator, Funct...
#include <LightGBM/utils/openmp_wrapper.h>  // for OMP_NUM_THREADS
#include <__fwd/fstream.h>                  // for ifstream
#include <chrono>                           // for duration, operator*, oper...
#include <cmath>                            // for fabs
#include <cstring>                          // for memset
#include <fstream>                          // for operator<<, basic_ostream
#include <functional>                       // for function
#include <queue>                            // for queue
#include <ratio>                            // for milli
#include <sstream>                          // for basic_stringstream
#include "LightGBM/cuda/vector_cudahost.h"  // for LGBM_config_, Use_Learner
#include "LightGBM/utils/json11.h"          // for Json
#include "omp.h"                            // for omp_get_thread_num
---

[ 11%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_model_text.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/boosting/gbdt_model_text.cpp should add these lines:
#include <__fwd/fstream.h>                  // for ifstream, ofstream
#include <__fwd/sstream.h>                  // for stringstream
#include <stdint.h>                         // for int8_t
#include <algorithm>                        // for min, max, stable_sort
#include <cstring>                          // for size_t, strlen
#include <fstream>                          // for basic_ofstream, basic_ifs...
#include <iomanip>                          // for operator<<, setprecision
#include <iterator>                         // for istreambuf_iterator
#include <limits>                           // for numeric_limits
#include <memory>                           // for unique_ptr, operator!=
#include <unordered_map>                    // for unordered_map
#include <utility>                          // for pair
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/log.h"             // for Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX

/Users/jlamb/repos/LightGBM/src/boosting/gbdt_model_text.cpp should remove these lines:
- #include <LightGBM/metric.h>  // lines 6-6

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/gbdt_model_text.cpp:
#include <LightGBM/config.h>                // for Config, ParseObjectiveAlias
#include <LightGBM/objective_function.h>    // for ObjectiveFunction
#include <LightGBM/utils/array_args.h>      // for ArrayArgs
#include <LightGBM/utils/common.h>          // for Join, Atoi, C_stringstream
#include <__fwd/fstream.h>                  // for ifstream, ofstream
#include <__fwd/sstream.h>                  // for stringstream
#include <stdint.h>                         // for int8_t
#include <algorithm>                        // for min, max, stable_sort
#include <cstring>                          // for size_t, strlen
#include <fstream>                          // for basic_ofstream, basic_ifs...
#include <iomanip>                          // for operator<<, setprecision
#include <iterator>                         // for istreambuf_iterator
#include <limits>                           // for numeric_limits
#include <memory>                           // for unique_ptr, operator!=
#include <sstream>                          // for operator<<, basic_ostream
#include <string>                           // for char_traits, basic_string
#include <unordered_map>                    // for unordered_map
#include <utility>                          // for pair
#include <vector>                           // for vector
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/log.h"             // for Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "gbdt.h"                           // for GBDT
---

[ 13%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_prediction.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/boosting/gbdt_prediction.cpp should add these lines:
#include <cstring>                           // for memset
#include <memory>                            // for unique_ptr
#include <unordered_map>                     // for unordered_map
#include <vector>                            // for vector
#include "LightGBM/tree.h"                   // for Tree

/Users/jlamb/repos/LightGBM/src/boosting/gbdt_prediction.cpp should remove these lines:
- #include <LightGBM/utils/openmp_wrapper.h>  // lines 7-7

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/gbdt_prediction.cpp:
#include <LightGBM/objective_function.h>     // for ObjectiveFunction
#include <LightGBM/prediction_early_stop.h>  // for PredictionEarlyStopInstance
#include <cstring>                           // for memset
#include <memory>                            // for unique_ptr
#include <unordered_map>                     // for unordered_map
#include <vector>                            // for vector
#include "LightGBM/tree.h"                   // for Tree
#include "gbdt.h"                            // for GBDT
---

[ 16%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/prediction_early_stop.cpp.o
Warning: include-what-you-use reported diagnostics:

(/Users/jlamb/repos/LightGBM/include/LightGBM/prediction_early_stop.h has correct #includes/fwd-decls)

/Users/jlamb/repos/LightGBM/src/boosting/prediction_early_stop.cpp should add these lines:
#include <stddef.h>              // for size_t

/Users/jlamb/repos/LightGBM/src/boosting/prediction_early_stop.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/prediction_early_stop.cpp:
#include <LightGBM/prediction_early_stop.h>
#include <LightGBM/utils/log.h>  // for Log
#include <stddef.h>              // for size_t
#include <algorithm>             // for partial_sort
#include <cmath>                 // for fabs
#include <limits>                // for numeric_limits
#include <vector>                // for vector
---

[ 19%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/sample_strategy.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/sample_strategy.h should add these lines:
#include "LightGBM/meta.h"             // for data_size_t, kAlignedSize, sco...
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { class TreeLearner; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/sample_strategy.h should remove these lines:
- #include <LightGBM/config.h>  // lines 13-13
- #include <LightGBM/objective_function.h>  // lines 16-16
- #include <LightGBM/tree_learner.h>  // lines 15-15
- #include <LightGBM/cuda/cuda_utils.hu>  // lines 9-9

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/sample_strategy.h:
#include <LightGBM/dataset.h>          // for Dataset
#include <LightGBM/utils/common.h>     // for AlignmentAllocator
#include <LightGBM/utils/random.h>     // for Random
#include <LightGBM/utils/threading.h>  // for ParallelPartitionRunner
#include <memory>                      // for unique_ptr
#include <vector>                      // for vector
#include "LightGBM/meta.h"             // for data_size_t, kAlignedSize, sco...
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { class TreeLearner; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/boosting/sample_strategy.cpp should add these lines:
#include <string>             // for basic_string, operator==, string
#include "LightGBM/config.h"  // for Config
namespace LightGBM { class Dataset; }
namespace LightGBM { class ObjectiveFunction; }

/Users/jlamb/repos/LightGBM/src/boosting/sample_strategy.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/boosting/sample_strategy.cpp:
#include <LightGBM/sample_strategy.h>
#include <string>             // for basic_string, operator==, string
#include "LightGBM/config.h"  // for Config
#include "bagging.hpp"        // for BaggingSampleStrategy
#include "goss.hpp"           // for GOSSStrategy
namespace LightGBM { class Dataset; }
namespace LightGBM { class ObjectiveFunction; }
---

[ 22%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/bin.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/bin.h should add these lines:
#include <__fwd/sstream.h>                  // for stringstream
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for uint32_t, int32_t, int64_t
#include <cmath>                            // for isnan
#include <iomanip>                          // for operator<<, setprecision
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
namespace LightGBM { struct BinaryWriter; }

/Users/jlamb/repos/LightGBM/include/LightGBM/bin.h should remove these lines:
- #include <LightGBM/utils/file_io.h>  // lines 10-10
- #include <functional>  // lines 14-14

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/bin.h:
#include <LightGBM/meta.h>                  // for data_size_t, score_t, com...
#include <LightGBM/utils/common.h>          // for Join
#include <__fwd/sstream.h>                  // for stringstream
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for uint32_t, int32_t, int64_t
#include <cmath>                            // for isnan
#include <iomanip>                          // for operator<<, setprecision
#include <limits>                           // for numeric_limits
#include <sstream>                          // for basic_ostream, operator<<
#include <string>                           // for char_traits, allocator
#include <unordered_map>                    // for unordered_map
#include <vector>                           // for vector
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
namespace LightGBM { struct BinaryWriter; }
---

/Users/jlamb/repos/LightGBM/src/io/bin.cpp should add these lines:
#include "LightGBM/meta.h"                 // for kZeroThreshold, data_size_t
#include "LightGBM/utils/binary_writer.h"  // for BinaryWriter
#include "LightGBM/utils/log.h"            // for CHECK_LE, Log, CHECK_GT

/Users/jlamb/repos/LightGBM/src/io/bin.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/bin.cpp:
#include <LightGBM/bin.h>
#include <LightGBM/utils/array_args.h>     // for ArrayArgs
#include <LightGBM/utils/common.h>         // for AlignmentAllocator, CheckD...
#include <LightGBM/utils/file_io.h>        // for VirtualFileWriter
#include <algorithm>                       // for max, min, stable_sort
#include <cmath>                           // for fabs, isnan, lround
#include <cstdint>                         // for uint8_t, uint32_t, uint16_t
#include <cstring>                         // for memcpy, size_t
#include "LightGBM/meta.h"                 // for kZeroThreshold, data_size_t
#include "LightGBM/utils/binary_writer.h"  // for BinaryWriter
#include "LightGBM/utils/log.h"            // for CHECK_LE, Log, CHECK_GT
#include "dense_bin.hpp"                   // for DenseBin
#include "multi_val_dense_bin.hpp"         // for MultiValDenseBin
#include "multi_val_sparse_bin.hpp"        // for MultiValSparseBin
#include "sparse_bin.hpp"                  // for SparseBin, SparseBinIterator
---

[ 25%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/config.h should add these lines:
#include <stddef.h>                 // for size_t
#include <stdint.h>                 // for int32_t, int8_t
#include <__hash_table>             // for operator==
#include <utility>                  // for pair

/Users/jlamb/repos/LightGBM/include/LightGBM/config.h should remove these lines:
- #include <LightGBM/meta.h>  // lines 20-20
- #include <memory>  // lines 26-26

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/config.h:
#include <LightGBM/export.h>        // for LIGHTGBM_EXPORT
#include <LightGBM/utils/common.h>  // for AtofAndCheck, AtoiAndCheck, tolower
#include <LightGBM/utils/log.h>     // for Log
#include <stddef.h>                 // for size_t
#include <stdint.h>                 // for int32_t, int8_t
#include <__hash_table>             // for operator==
#include <algorithm>                // for transform
#include <string>                   // for basic_string, operator==, string
#include <unordered_map>            // for unordered_map, __hash_map_iterator
#include <unordered_set>            // for unordered_set
#include <utility>                  // for pair
#include <vector>                   // for vector
---

/Users/jlamb/repos/LightGBM/src/io/config.cpp should add these lines:
#include <__fwd/sstream.h>                  // for stringstream
#include <cmath>                            // for fabs, pow
#include <memory>                           // for allocator
#include <sstream>                          // for operator<<, basic_ostream
#include "LightGBM/meta.h"                  // for kEpsilon, kZeroThreshold

/Users/jlamb/repos/LightGBM/src/io/config.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/config.cpp:
#include <LightGBM/config.h>
#include <LightGBM/cuda/vector_cudahost.h>  // for LGBM_Device, LGBM_config_
#include <LightGBM/utils/common.h>          // for tolower, Join, Split, Trim
#include <LightGBM/utils/log.h>             // for Log, LogLevel
#include <LightGBM/utils/random.h>          // for Random
#include <__fwd/sstream.h>                  // for stringstream
#include <cmath>                            // for fabs, pow
#include <limits>                           // for numeric_limits
#include <memory>                           // for allocator
#include <sstream>                          // for operator<<, basic_ostream
#include "LightGBM/meta.h"                  // for kEpsilon, kZeroThreshold
---

[ 27%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config_auto.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/io/config_auto.cpp should add these lines:
#include <__fwd/sstream.h>          // for stringstream
#include <stdint.h>                 // for int8_t, int32_t
#include <sstream>                  // for operator<<, basic_ostream, basic_...
#include <string>                   // for basic_string, char_traits, hash
#include <unordered_map>            // for unordered_map
#include <unordered_set>            // for unordered_set
#include <vector>                   // for vector
#include "LightGBM/utils/common.h"  // for Join, StringToArray, ArrayCast
#include "LightGBM/utils/log.h"     // for CHECK_GT, CHECK_GE, CHECK_LE, CHE...

/Users/jlamb/repos/LightGBM/src/io/config_auto.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/config_auto.cpp:
#include <LightGBM/config.h>        // for Config
#include <__fwd/sstream.h>          // for stringstream
#include <stdint.h>                 // for int8_t, int32_t
#include <sstream>                  // for operator<<, basic_ostream, basic_...
#include <string>                   // for basic_string, char_traits, hash
#include <unordered_map>            // for unordered_map
#include <unordered_set>            // for unordered_set
#include <vector>                   // for vector
#include "LightGBM/utils/common.h"  // for Join, StringToArray, ArrayCast
#include "LightGBM/utils/log.h"     // for CHECK_GT, CHECK_GE, CHECK_LE, CHE...
---

[ 30%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/dataset.h should add these lines:
#include <__mutex/lock_guard.h>             // for lock_guard
#include <__mutex/mutex.h>                  // for mutex
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for int32_t, uint32_t, int8_t
#include <algorithm>                        // for replace
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, BinIte...
#include "LightGBM/export.h"                // for LIGHTGBM_EXPORT
#include "LightGBM/utils/common.h"          // for CheckAllowedJSON
#include "LightGBM/utils/log.h"             // for Log
namespace LightGBM { class ArrowChunkedArray; }
namespace LightGBM { struct BinaryWriter; }
namespace LightGBM { struct ByteBuffer; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/dataset.h should remove these lines:
- #include <LightGBM/arrow.h>  // lines 8-8
- #include <LightGBM/config.h>  // lines 9-9
- #include <LightGBM/utils/byte_buffer.h>  // lines 13-13
- #include <LightGBM/utils/random.h>  // lines 15-15
- #include <LightGBM/utils/text_reader.h>  // lines 16-16
- #include <LightGBM/cuda/cuda_column_data.hpp>  // lines 27-27
- #include <LightGBM/cuda/cuda_metadata.hpp>  // lines 28-28
- #include <mutex>  // lines 22-22

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/dataset.h:
#include <LightGBM/feature_group.h>         // for FeatureGroup
#include <LightGBM/meta.h>                  // for data_size_t, label_t, sco...
#include <LightGBM/train_share_states.h>    // for TrainingShareStates
#include <LightGBM/utils/openmp_wrapper.h>  // for OMP_NUM_THREADS
#include <__mutex/lock_guard.h>             // for lock_guard
#include <__mutex/mutex.h>                  // for mutex
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for int32_t, uint32_t, int8_t
#include <algorithm>                        // for replace
#include <functional>                       // for function
#include <map>                              // for map
#include <memory>                           // for unique_ptr
#include <string>                           // for basic_string, string
#include <unordered_set>                    // for unordered_set
#include <utility>                          // for pair
#include <vector>                           // for vector
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, BinIte...
#include "LightGBM/export.h"                // for LIGHTGBM_EXPORT
#include "LightGBM/utils/common.h"          // for CheckAllowedJSON
#include "LightGBM/utils/log.h"             // for Log
namespace LightGBM { class ArrowChunkedArray; }
namespace LightGBM { class DatasetLoader; }  // lines 33-33
namespace LightGBM { struct BinaryWriter; }
namespace LightGBM { struct ByteBuffer; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/io/dataset.cpp should add these lines:
#include <cstring>                          // for size_t, memset, strlen, NULL
#include <ratio>                            // for ratio, milli
#include "LightGBM/config.h"                // for Config
#include "LightGBM/meta.h"                  // for data_size_t, score_t, NO_...
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/binary_writer.h"   // for BinaryWriter
#include "LightGBM/utils/byte_buffer.h"     // for ByteBuffer
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/random.h"          // for Random
namespace LightGBM { class ArrowChunkedArray; }

/Users/jlamb/repos/LightGBM/src/io/dataset.cpp should remove these lines:
- #include <limits>  // lines 16-16
- #include <sstream>  // lines 17-17
- #include <unordered_map>  // lines 18-18

The full include-list for /Users/jlamb/repos/LightGBM/src/io/dataset.cpp:
#include <LightGBM/dataset.h>
#include <LightGBM/cuda/vector_cudahost.h>  // for LGBM_Device, LGBM_config_
#include <LightGBM/feature_group.h>         // for FeatureGroup
#include <LightGBM/utils/array_args.h>      // for ArrayArgs
#include <LightGBM/utils/openmp_wrapper.h>  // for OMP_NUM_THREADS, OMP_INIT_EX
#include <LightGBM/utils/threading.h>       // for Threading
#include <chrono>                           // for duration, operator*, oper...
#include <cstdio>                           // for fprintf, size_t, fclose
#include <cstring>                          // for size_t, memset, strlen, NULL
#include <ratio>                            // for ratio, milli
#include "LightGBM/config.h"                // for Config
#include "LightGBM/meta.h"                  // for data_size_t, score_t, NO_...
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/binary_writer.h"   // for BinaryWriter
#include "LightGBM/utils/byte_buffer.h"     // for ByteBuffer
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/random.h"          // for Random
namespace LightGBM { class ArrowChunkedArray; }
---

[ 33%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset_loader.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/dataset_loader.h should add these lines:
#include <stddef.h>                 // for size_t
#include <stdint.h>                 // for int32_t, int64_t
#include "LightGBM/export.h"        // for LIGHTGBM_EXPORT
#include "LightGBM/meta.h"          // for data_size_t, PredictFunction
#include "LightGBM/utils/random.h"  // for Random
namespace LightGBM { class BinMapper; }
namespace LightGBM { class Dataset; }
namespace LightGBM { class Metadata; }
namespace LightGBM { class Parser; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/dataset_loader.h should remove these lines:
- #include <LightGBM/dataset.h>  // lines 8-8

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/dataset_loader.h:
#include <stddef.h>                 // for size_t
#include <stdint.h>                 // for int32_t, int64_t
#include <memory>                   // for unique_ptr
#include <string>                   // for string, basic_string
#include <unordered_set>            // for unordered_set
#include <vector>                   // for vector
#include "LightGBM/export.h"        // for LIGHTGBM_EXPORT
#include "LightGBM/meta.h"          // for data_size_t, PredictFunction
#include "LightGBM/utils/random.h"  // for Random
namespace LightGBM { class BinMapper; }
namespace LightGBM { class Dataset; }
namespace LightGBM { class Metadata; }
namespace LightGBM { class Parser; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/io/dataset_loader.cpp should add these lines:
#include <__fwd/fstream.h>                  // for ifstream
#include <__fwd/sstream.h>                  // for stringstream
#include <algorithm>                        // for min_element, min, equal, max
#include <cmath>                            // for fabs, isnan
#include <cstring>                          // for size_t, strlen
#include <functional>                       // for function
#include <ratio>                            // for ratio, milli
#include <sstream>                          // for basic_stringstream
#include <unordered_map>                    // for unordered_map
#include <utility>                          // for pair, move
#include "LightGBM/bin.h"                   // for BinMapper, BinType
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset, Parser, Metadata
#include "LightGBM/feature_group.h"         // for FeatureGroup
#include "LightGBM/utils/common.h"          // for Split, AtoiAndCheck, Star...
#include "LightGBM/utils/file_io.h"         // for VirtualFileReader, Virtua...
#include "LightGBM/utils/text_reader.h"     // for TextReader
#include "LightGBM/utils/threading.h"       // for Threading
#include "omp.h"                            // for omp_get_thread_num

/Users/jlamb/repos/LightGBM/src/io/dataset_loader.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/dataset_loader.cpp:
#include <LightGBM/dataset_loader.h>
#include <LightGBM/network.h>               // for Network
#include <LightGBM/utils/array_args.h>      // for ArrayArgs
#include <LightGBM/utils/json11.h>          // for Json
#include <LightGBM/utils/log.h>             // for Log, CHECK, CHECK_EQ, CHE...
#include <LightGBM/utils/openmp_wrapper.h>  // for OMP_NUM_THREADS, OMP_INIT_EX
#include <__fwd/fstream.h>                  // for ifstream
#include <__fwd/sstream.h>                  // for stringstream
#include <algorithm>                        // for min_element, min, equal, max
#include <chrono>                           // for duration, operator*, oper...
#include <cmath>                            // for fabs, isnan
#include <cstring>                          // for size_t, strlen
#include <fstream>                          // for basic_ostream, operator<<
#include <functional>                       // for function
#include <ratio>                            // for ratio, milli
#include <sstream>                          // for basic_stringstream
#include <unordered_map>                    // for unordered_map
#include <utility>                          // for pair, move
#include "LightGBM/bin.h"                   // for BinMapper, BinType
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset, Parser, Metadata
#include "LightGBM/feature_group.h"         // for FeatureGroup
#include "LightGBM/utils/common.h"          // for Split, AtoiAndCheck, Star...
#include "LightGBM/utils/file_io.h"         // for VirtualFileReader, Virtua...
#include "LightGBM/utils/text_reader.h"     // for TextReader
#include "LightGBM/utils/threading.h"       // for Threading
#include "omp.h"                            // for omp_get_thread_num
---

[ 36%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/file_io.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/file_io.h should add these lines:

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/file_io.h should remove these lines:
- #include <cstdlib>  // lines 12-12
- #include <cstring>  // lines 13-13
- #include <iostream>  // lines 14-14
- #include <vector>  // lines 16-16

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/utils/file_io.h:
#include <LightGBM/utils/binary_writer.h>  // for BinaryWriter
#include <cstdio>                          // for size_t
#include <memory>                          // for unique_ptr
#include <string>                          // for string
---

/Users/jlamb/repos/LightGBM/src/io/file_io.cpp should add these lines:

/Users/jlamb/repos/LightGBM/src/io/file_io.cpp should remove these lines:
- #include <LightGBM/utils/log.h>  // lines 8-8
- #include <algorithm>  // lines 10-10
- #include <sstream>  // lines 11-11
- #include <unordered_map>  // lines 12-12

The full include-list for /Users/jlamb/repos/LightGBM/src/io/file_io.cpp:
#include <LightGBM/utils/file_io.h>
---

[ 38%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/json11.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/json11.h should add these lines:
#include <cstddef>           // for nullptr_t, size_t
#include <type_traits>       // for is_constructible, enable_if

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/json11.h should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/utils/json11.h:
#include <cstddef>           // for nullptr_t, size_t
#include <initializer_list>  // for initializer_list
#include <map>               // for map
#include <memory>            // for shared_ptr
#include <string>            // for basic_string, string
#include <type_traits>       // for is_constructible, enable_if
#include <utility>           // for declval, pair
#include <vector>            // for vector
namespace json11_internal_lightgbm { class JsonValue; }  // lines 67-67
---

/Users/jlamb/repos/LightGBM/src/io/json11.cpp should add these lines:
#include <stdint.h>              // for uint8_t, int64_t

/Users/jlamb/repos/LightGBM/src/io/json11.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/json11.cpp:
#include <LightGBM/utils/json11.h>
#include <LightGBM/utils/log.h>  // for CHECK_NE
#include <stdint.h>              // for uint8_t, int64_t
#include <cmath>                 // for isfinite
#include <cstdio>                // for size_t, snprintf
#include <cstdlib>               // for atoi, strtod, strtol
#include <limits>                // for numeric_limits
---

[ 41%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/metadata.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/io/metadata.cpp should add these lines:
#include <__mutex/lock_guard.h>             // for lock_guard
#include <__mutex/mutex.h>                  // for mutex
#include <stdint.h>                         // for int32_t, int64_t
#include <cstring>                          // for size_t, memcpy
#include <unordered_map>                    // for unordered_map
#include "LightGBM/arrow.h"                 // for ArrowChunkedArray
#include "LightGBM/arrow.tpp"               // for operator-, ArrowChunkedAr...
#include "LightGBM/meta.h"                  // for data_size_t, label_t
#include "LightGBM/utils/binary_writer.h"   // for BinaryWriter
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/log.h"             // for Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/text_reader.h"     // for TextReader

/Users/jlamb/repos/LightGBM/src/io/metadata.cpp should remove these lines:
- #include <set>  // lines 8-8

The full include-list for /Users/jlamb/repos/LightGBM/src/io/metadata.cpp:
#include <LightGBM/dataset.h>               // for Metadata
#include <LightGBM/utils/common.h>          // for AvoidInf, Atof, Split, Atoi
#include <__mutex/lock_guard.h>             // for lock_guard
#include <__mutex/mutex.h>                  // for mutex
#include <stdint.h>                         // for int32_t, int64_t
#include <cstring>                          // for size_t, memcpy
#include <string>                           // for basic_string, string, hash
#include <unordered_map>                    // for unordered_map
#include <vector>                           // for vector
#include "LightGBM/arrow.h"                 // for ArrowChunkedArray
#include "LightGBM/arrow.tpp"               // for operator-, ArrowChunkedAr...
#include "LightGBM/meta.h"                  // for data_size_t, label_t
#include "LightGBM/utils/binary_writer.h"   // for BinaryWriter
#include "LightGBM/utils/file_io.h"         // for VirtualFileWriter
#include "LightGBM/utils/log.h"             // for Log
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/text_reader.h"     // for TextReader
---

[ 44%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/parser.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/io/parser.hpp should add these lines:
#include <cmath>                    // for fabs, isnan
#include "LightGBM/meta.h"          // for kZeroThreshold

/Users/jlamb/repos/LightGBM/src/io/parser.hpp should remove these lines:
- #include <unordered_map>  // lines 12-12

The full include-list for /Users/jlamb/repos/LightGBM/src/io/parser.hpp:
#include <LightGBM/dataset.h>       // for Parser
#include <LightGBM/utils/common.h>  // for SkipSpaceAndTab, Atoi, Atof
#include <LightGBM/utils/log.h>     // for Log
#include <cmath>                    // for fabs, isnan
#include <utility>                  // for pair
#include <vector>                   // for vector
#include "LightGBM/meta.h"          // for kZeroThreshold
---

/Users/jlamb/repos/LightGBM/src/io/parser.cpp should add these lines:
#include <__fwd/sstream.h>               // for stringstream
#include <stddef.h>                      // for size_t
#include <sstream>                       // for basic_stringstream, getline
#include "LightGBM/dataset.h"            // for Parser, ParserFactory
#include "LightGBM/utils/common.h"       // for Trim, GetFromParserConfig
#include "LightGBM/utils/file_io.h"      // for VirtualFileReader
#include "LightGBM/utils/log.h"          // for Log, CHECK_GT
#include "LightGBM/utils/text_reader.h"  // for TextReader

/Users/jlamb/repos/LightGBM/src/io/parser.cpp should remove these lines:
- #include <algorithm>  // lines 9-9

The full include-list for /Users/jlamb/repos/LightGBM/src/io/parser.cpp:
#include "parser.hpp"
#include <__fwd/sstream.h>               // for stringstream
#include <stddef.h>                      // for size_t
#include <functional>                    // for function
#include <map>                           // for map, __map_const_iterator
#include <memory>                        // for unique_ptr
#include <sstream>                       // for basic_stringstream, getline
#include <string>                        // for basic_string, string, to_string
#include "LightGBM/dataset.h"            // for Parser, ParserFactory
#include "LightGBM/utils/common.h"       // for Trim, GetFromParserConfig
#include "LightGBM/utils/file_io.h"      // for VirtualFileReader
#include "LightGBM/utils/log.h"          // for Log, CHECK_GT
#include "LightGBM/utils/text_reader.h"  // for TextReader
---

[ 47%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/train_share_states.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/train_share_states.h should add these lines:
#include <stdint.h>                         // for int8_t, int16_t, int32_t
#include <cstring>                          // for memset, size_t
#include <string>                           // for basic_string
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, Timer
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_INIT_EX, OMP_LOOP_EX_...
namespace LightGBM { class FeatureGroup; }

/Users/jlamb/repos/LightGBM/include/LightGBM/train_share_states.h should remove these lines:
- #include <LightGBM/feature_group.h>  // lines 9-9

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/train_share_states.h:
#include <LightGBM/bin.h>                   // for hist_t, MultiValBin
#include <LightGBM/meta.h>                  // for data_size_t, kAlignedSize
#include <LightGBM/utils/threading.h>       // for Threading
#include <stdint.h>                         // for int8_t, int16_t, int32_t
#include <algorithm>                        // for min
#include <cstring>                          // for memset, size_t
#include <memory>                           // for unique_ptr, operator!=
#include <string>                           // for basic_string
#include <vector>                           // for vector
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, Timer
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_INIT_EX, OMP_LOOP_EX_...
namespace LightGBM { class FeatureGroup; }
---

/Users/jlamb/repos/LightGBM/src/io/train_share_states.cpp should add these lines:
#include "LightGBM/bin.h"              // for BinMapper, MultiValBin, hist_t
#include "LightGBM/feature_group.h"    // for FeatureGroup
#include "LightGBM/meta.h"             // for kAlignedSize, data_size_t, kZe...
#include "LightGBM/utils/log.h"        // for CHECK, CHECK_EQ
#include "LightGBM/utils/threading.h"  // for Threading

/Users/jlamb/repos/LightGBM/src/io/train_share_states.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/train_share_states.cpp:
#include <LightGBM/train_share_states.h>
#include "LightGBM/bin.h"              // for BinMapper, MultiValBin, hist_t
#include "LightGBM/feature_group.h"    // for FeatureGroup
#include "LightGBM/meta.h"             // for kAlignedSize, data_size_t, kZe...
#include "LightGBM/utils/log.h"        // for CHECK, CHECK_EQ
#include "LightGBM/utils/threading.h"  // for Threading
---

[ 50%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/tree.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/tree.h should add these lines:
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for uint32_t, int8_t, uint8_t
#include <cmath>                            // for isnan
#include <utility>                          // for pair
#include "LightGBM/bin.h"                   // for MissingType
#include "LightGBM/utils/common.h"          // for FindInBitset
#include "LightGBM/utils/log.h"             // for CHECK_GE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
namespace LightGBM { class Dataset; }

/Users/jlamb/repos/LightGBM/include/LightGBM/tree.h should remove these lines:
- #include <LightGBM/dataset.h>  // lines 8-8
- #include <map>  // lines 12-12
- #include <memory>  // lines 13-13

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/tree.h:
#include <LightGBM/meta.h>                  // for data_size_t, kZeroThreshold
#include <stddef.h>                         // for size_t
#include <stdint.h>                         // for uint32_t, int8_t, uint8_t
#include <cmath>                            // for isnan
#include <string>                           // for string
#include <unordered_map>                    // for unordered_map, __hash_map...
#include <utility>                          // for pair
#include <vector>                           // for vector
#include "LightGBM/bin.h"                   // for MissingType
#include "LightGBM/utils/common.h"          // for FindInBitset
#include "LightGBM/utils/log.h"             // for CHECK_GE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
namespace LightGBM { class Dataset; }
---

/Users/jlamb/repos/LightGBM/src/io/tree.cpp should add these lines:
#include <__fwd/sstream.h>             // for stringstream
#include <algorithm>                   // for copy
#include <limits>                      // for numeric_limits
#include <memory>                      // for unique_ptr, allocator
#include "LightGBM/meta.h"             // for data_size_t

/Users/jlamb/repos/LightGBM/src/io/tree.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/io/tree.cpp:
#include <LightGBM/tree.h>
#include <LightGBM/dataset.h>          // for Dataset
#include <LightGBM/utils/common.h>     // for ArrayToString, StringToArrayFast
#include <LightGBM/utils/threading.h>  // for Threading
#include <__fwd/sstream.h>             // for stringstream
#include <algorithm>                   // for copy
#include <functional>                  // for function
#include <iomanip>                     // for operator<<, setprecision
#include <limits>                      // for numeric_limits
#include <memory>                      // for unique_ptr, allocator
#include <sstream>                     // for operator<<, basic_ostream, bas...
#include "LightGBM/meta.h"             // for data_size_t
---

[ 52%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/dcg_calculator.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/metric/dcg_calculator.cpp should add these lines:
#include <stddef.h>              // for size_t
#include "LightGBM/dataset.h"    // for Metadata
#include "LightGBM/meta.h"       // for data_size_t, label_t, kEpsilon

/Users/jlamb/repos/LightGBM/src/metric/dcg_calculator.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/metric/dcg_calculator.cpp:
#include <LightGBM/metric.h>     // for DCGCalculator
#include <LightGBM/utils/log.h>  // for Log, CHECK_GT
#include <stddef.h>              // for size_t
#include <algorithm>             // for stable_sort
#include <cmath>                 // for fabs, log2
#include <vector>                // for vector
#include "LightGBM/dataset.h"    // for Metadata
#include "LightGBM/meta.h"       // for data_size_t, label_t, kEpsilon
---

[ 55%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/metric.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/metric.h should add these lines:
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { class Metadata; }
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/metric.h should remove these lines:
- #include <LightGBM/config.h>  // lines 8-8
- #include <LightGBM/dataset.h>  // lines 9-9
- #include <LightGBM/objective_function.h>  // lines 11-11
- #include <LightGBM/utils/common.h>  // lines 13-13
- #include <LightGBM/utils/log.h>  // lines 12-12

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/metric.h:
#include <LightGBM/meta.h>    // for data_size_t, label_t
#include <string>             // for string
#include <vector>             // for vector
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { class Metadata; }
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/metric/metric.cpp should add these lines:
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/src/metric/metric.cpp should remove these lines:
- #include "cuda/cuda_binary_metric.hpp"  // lines 14-14
- #include "cuda/cuda_regression_metric.hpp"  // lines 15-15

The full include-list for /Users/jlamb/repos/LightGBM/src/metric/metric.cpp:
#include <LightGBM/metric.h>
#include "binary_metric.hpp"      // for AUCMetric, AveragePrecisionMetric
#include "map_metric.hpp"         // for MapMetric
#include "multiclass_metric.hpp"  // for AucMuMetric, MultiErrorMetric, Mult...
#include "rank_metric.hpp"        // for NDCGMetric
#include "regression_metric.hpp"  // for FairLossMetric, GammaDevianceMetric
#include "xentropy_metric.hpp"    // for CrossEntropyLambdaMetric, CrossEntr...
namespace LightGBM { struct Config; }
---

[ 58%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linker_topo.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/network/linker_topo.cpp should add these lines:
#include <stddef.h>            // for size_t

/Users/jlamb/repos/LightGBM/src/network/linker_topo.cpp should remove these lines:
- #include <LightGBM/utils/common.h>  // lines 6-6
- #include <LightGBM/utils/log.h>  // lines 7-7
- #include <string>  // lines 9-9
- #include <unordered_map>  // lines 10-10

The full include-list for /Users/jlamb/repos/LightGBM/src/network/linker_topo.cpp:
#include <LightGBM/network.h>  // for RecursiveHalvingMap, RecursiveHalvingN...
#include <stddef.h>            // for size_t
#include <vector>              // for vector
---

[ 61%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_mpi.cpp.o
[ 63%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_socket.cpp.o
Warning: include-what-you-use reported diagnostics:
/Users/jlamb/repos/LightGBM/src/network/linkers_socket.cpp:174:7: warning: variable 'need_connect_cnt' set but not used [-Wunused-but-set-variable]
  174 |   int need_connect_cnt = 0;
      |       ^

/Users/jlamb/repos/LightGBM/src/network/linkers_socket.cpp should add these lines:
#include <stdlib.h>                      // for atoi
#include <memory>                        // for unique_ptr, default_delete
#include <ratio>                         // for ratio, milli
#include <utility>                       // for pair
#include "LightGBM/network.h"            // for BruckMap, RecursiveHalvingMap
#include "LightGBM/utils/log.h"          // for Log
#include "socket_wrapper.hpp"            // for TcpSocket

/Users/jlamb/repos/LightGBM/src/network/linkers_socket.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/network/linkers_socket.cpp:
#include <LightGBM/config.h>             // for Config
#include <LightGBM/utils/common.h>       // for Split, Trim, Atoi
#include <LightGBM/utils/text_reader.h>  // for TextReader
#include <stdlib.h>                      // for atoi
#include <algorithm>                     // for max
#include <chrono>                        // for duration, operator*, millise...
#include <cstring>                       // for size_t
#include <memory>                        // for unique_ptr, default_delete
#include <ratio>                         // for ratio, milli
#include <string>                        // for basic_string, string
#include <thread>                        // for sleep_for, thread
#include <unordered_map>                 // for unordered_map, __hash_map_it...
#include <unordered_set>                 // for unordered_set
#include <utility>                       // for pair
#include <vector>                        // for vector
#include "LightGBM/network.h"            // for BruckMap, RecursiveHalvingMap
#include "LightGBM/utils/log.h"          // for Log
#include "linkers.h"                     // for Linkers
#include "socket_wrapper.hpp"            // for TcpSocket
---

[ 66%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/network.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/network.h should add these lines:
#include <cstring>               // for memcpy
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/network.h should remove these lines:
- #include <LightGBM/config.h>  // lines 8-8
- #include <functional>  // lines 12-12

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/network.h:
#include <LightGBM/meta.h>       // for comm_size_t, ReduceFunction, Allgath...
#include <LightGBM/utils/log.h>  // for THREAD_LOCAL
#include <cstring>               // for memcpy
#include <memory>                // for unique_ptr
#include <vector>                // for vector
namespace LightGBM { class Linkers; }  // lines 19-19
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/network/network.cpp should add these lines:
#include <algorithm>             // for reverse, min
#include "LightGBM/config.h"     // for Config
#include "LightGBM/meta.h"       // for comm_size_t, ReduceFunction, Allgath...
#include "LightGBM/utils/log.h"  // for THREAD_LOCAL, Log

/Users/jlamb/repos/LightGBM/src/network/network.cpp should remove these lines:
- #include <LightGBM/utils/common.h>  // lines 7-7
- #include <cstdlib>  // lines 9-9

The full include-list for /Users/jlamb/repos/LightGBM/src/network/network.cpp:
#include <LightGBM/network.h>
#include <algorithm>             // for reverse, min
#include <cstring>               // for memcpy
#include "LightGBM/config.h"     // for Config
#include "LightGBM/meta.h"       // for comm_size_t, ReduceFunction, Allgath...
#include "LightGBM/utils/log.h"  // for THREAD_LOCAL, Log
#include "linkers.h"             // for Linkers
---

[ 69%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/objective/objective_function.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/objective_function.h should add these lines:
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { class Metadata; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/include/LightGBM/objective_function.h should remove these lines:
- #include <LightGBM/config.h>  // lines 8-8
- #include <LightGBM/dataset.h>  // lines 9-9

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/objective_function.h:
#include <LightGBM/meta.h>    // for data_size_t, score_t, label_t
#include <functional>         // for function
#include <string>             // for string
#include "LightGBM/export.h"  // for LIGHTGBM_EXPORT
namespace LightGBM { class Metadata; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/objective/objective_function.cpp should add these lines:
#include <vector>                    // for vector
#include "LightGBM/utils/common.h"   // for Split
#include "LightGBM/utils/log.h"      // for Log
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/src/objective/objective_function.cpp should remove these lines:
- #include "cuda/cuda_binary_objective.hpp"  // lines 13-13
- #include "cuda/cuda_multiclass_objective.hpp"  // lines 14-14
- #include "cuda/cuda_rank_objective.hpp"  // lines 15-15
- #include "cuda/cuda_regression_objective.hpp"  // lines 16-16

The full include-list for /Users/jlamb/repos/LightGBM/src/objective/objective_function.cpp:
#include <LightGBM/objective_function.h>
#include <vector>                    // for vector
#include "LightGBM/utils/common.h"   // for Split
#include "LightGBM/utils/log.h"      // for Log
#include "binary_objective.hpp"      // for BinaryLogloss
#include "multiclass_objective.hpp"  // for MulticlassOVA, MulticlassSoftmax
#include "rank_objective.hpp"        // for LambdarankNDCG, RankXENDCG
#include "regression_objective.hpp"  // for RegressionFairLoss, RegressionGa...
#include "xentropy_objective.hpp"    // for CrossEntropy, CrossEntropyLambda
namespace LightGBM { struct Config; }
---

[ 72%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/data_parallel_tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/data_parallel_tree_learner.cpp should add these lines:
#include <stdint.h>                         // for int64_t, uint8_t, int32_t
#include <algorithm>                        // for max, min
#include <memory>                           // for unique_ptr, operator!=
#include <string>                           // for basic_string
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, kHistE...
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for comm_size_t, data_size_t
#include "LightGBM/network.h"               // for Network
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/array_args.h"      // for ArrayArgs
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, Timer
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "col_sampler.hpp"                  // for ColSampler
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram
#include "gpu_tree_learner.h"               // for GPUTreeLearner
#include "gradient_discretizer.hpp"         // for GradientDiscretizer
#include "leaf_splits.hpp"                  // for LeafSplits
#include "omp.h"                            // for omp_get_thread_num
#include "serial_tree_learner.h"            // for SerialTreeLearner
#include "split_info.hpp"                   // for SplitInfo
namespace LightGBM { class Tree; }

/Users/jlamb/repos/LightGBM/src/treelearner/data_parallel_tree_learner.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/data_parallel_tree_learner.cpp:
#include <stdint.h>                         // for int64_t, uint8_t, int32_t
#include <algorithm>                        // for max, min
#include <cstring>                          // for memcpy, memset, size_t
#include <memory>                           // for unique_ptr, operator!=
#include <string>                           // for basic_string
#include <tuple>                            // for get, tuple
#include <vector>                           // for vector
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, kHistE...
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for comm_size_t, data_size_t
#include "LightGBM/network.h"               // for Network
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/array_args.h"      // for ArrayArgs
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, Timer
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "col_sampler.hpp"                  // for ColSampler
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram
#include "gpu_tree_learner.h"               // for GPUTreeLearner
#include "gradient_discretizer.hpp"         // for GradientDiscretizer
#include "leaf_splits.hpp"                  // for LeafSplits
#include "omp.h"                            // for omp_get_thread_num
#include "parallel_tree_learner.h"          // for DataParallelTreeLearner
#include "serial_tree_learner.h"            // for SerialTreeLearner
#include "split_info.hpp"                   // for SplitInfo
namespace LightGBM { class Tree; }
---

[ 75%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/feature_histogram.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.hpp should add these lines:
#include <stdint.h>                         // for int32_t, int64_t, uint32_t
#include <functional>                       // for function
#include "LightGBM/config.h"                // for Config
#include "LightGBM/meta.h"                  // for data_size_t, kEpsilon
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, RoundInt
#include "LightGBM/utils/log.h"             // for CHECK_LE, Log, CHECK_GE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "LightGBM/utils/random.h"          // for Random

/Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.hpp should remove these lines:
- #include <utility>  // lines 17-17

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.hpp:
#include <LightGBM/bin.h>                   // for MissingType, hist_t, GET_...
#include <LightGBM/dataset.h>               // for Dataset
#include <LightGBM/utils/array_args.h>      // for ArrayArgs
#include <stdint.h>                         // for int32_t, int64_t, uint32_t
#include <algorithm>                        // for fill, max
#include <cmath>                            // for fabs, isnan, NAN
#include <cstring>                          // for memcpy
#include <functional>                       // for function
#include <memory>                           // for unique_ptr, swap
#include <vector>                           // for vector, operator!=
#include "LightGBM/config.h"                // for Config
#include "LightGBM/meta.h"                  // for data_size_t, kEpsilon
#include "LightGBM/utils/common.h"          // for AlignmentAllocator, RoundInt
#include "LightGBM/utils/log.h"             // for CHECK_LE, Log, CHECK_GE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "LightGBM/utils/random.h"          // for Random
#include "monotone_constraints.hpp"         // for BasicConstraint, FeatureC...
#include "split_info.hpp"                   // for SplitInfo
---

/Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.cpp should add these lines:
#include "LightGBM/bin.h"  // for GET_HESS, GET_GRAD

/Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/feature_histogram.cpp:
#include "feature_histogram.hpp"
#include "LightGBM/bin.h"  // for GET_HESS, GET_GRAD
---

[ 77%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/feature_parallel_tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/feature_parallel_tree_learner.cpp should add these lines:
#include <stdint.h>                     // for int8_t
#include <memory>                       // for unique_ptr
#include "LightGBM/config.h"            // for Config
#include "LightGBM/dataset.h"           // for Dataset
#include "LightGBM/network.h"           // for Network
#include "LightGBM/utils/array_args.h"  // for ArrayArgs
#include "col_sampler.hpp"              // for ColSampler
#include "gpu_tree_learner.h"           // for GPUTreeLearner
#include "leaf_splits.hpp"              // for LeafSplits
#include "serial_tree_learner.h"        // for SerialTreeLearner
#include "split_info.hpp"               // for SplitInfo
namespace LightGBM { class Tree; }

/Users/jlamb/repos/LightGBM/src/treelearner/feature_parallel_tree_learner.cpp should remove these lines:
- #include <cstring>  // lines 5-5

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/feature_parallel_tree_learner.cpp:
#include <stdint.h>                     // for int8_t
#include <memory>                       // for unique_ptr
#include <vector>                       // for vector
#include "LightGBM/config.h"            // for Config
#include "LightGBM/dataset.h"           // for Dataset
#include "LightGBM/network.h"           // for Network
#include "LightGBM/utils/array_args.h"  // for ArrayArgs
#include "col_sampler.hpp"              // for ColSampler
#include "gpu_tree_learner.h"           // for GPUTreeLearner
#include "leaf_splits.hpp"              // for LeafSplits
#include "parallel_tree_learner.h"      // for FeatureParallelTreeLearner
#include "serial_tree_learner.h"        // for SerialTreeLearner
#include "split_info.hpp"               // for SplitInfo
namespace LightGBM { class Tree; }
---

[ 80%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gpu_tree_learner.cpp.o
[ 83%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gradient_discretizer.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.hpp should add these lines:
#include <stdint.h>         // for int8_t, int32_t
#include <functional>       // for function
namespace LightGBM { class DataPartition; }
namespace LightGBM { class Dataset; }
namespace LightGBM { class Tree; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.hpp should remove these lines:
- #include <LightGBM/bin.h>  // lines 9-9
- #include <LightGBM/tree.h>  // lines 11-11
- #include <LightGBM/utils/threading.h>  // lines 12-12
- #include "data_partition.hpp"  // lines 17-17
- #include "feature_histogram.hpp"  // lines 18-18

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.hpp:
#include <LightGBM/meta.h>  // for data_size_t, score_t
#include <stdint.h>         // for int8_t, int32_t
#include <functional>       // for function
#include <random>           // for mt19937, uniform_int_distribution
#include <vector>           // for vector
namespace LightGBM { class DataPartition; }
namespace LightGBM { class Dataset; }
namespace LightGBM { class Tree; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.cpp should add these lines:
#include <cmath>                            // for fabs
#include "LightGBM/bin.h"                   // for BinMapper
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for data_size_t, score_t
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/common.h"          // for Timer, global_timer
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/threading.h"       // for Threading
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram
#include "omp.h"                            // for omp_get_thread_num

/Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/gradient_discretizer.cpp:
#include "gradient_discretizer.hpp"
#include <LightGBM/network.h>               // for Network
#include <algorithm>                        // for min
#include <cmath>                            // for fabs
#include <string>                           // for basic_string, operator==
#include <vector>                           // for vector
#include "LightGBM/bin.h"                   // for BinMapper
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for data_size_t, score_t
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/common.h"          // for Timer, global_timer
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "LightGBM/utils/threading.h"       // for Threading
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram
#include "omp.h"                            // for omp_get_thread_num
---

[ 86%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/linear_tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.h should add these lines:
#include <stdint.h>                         // for int8_t
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for score_t
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "data_partition.hpp"               // for DataPartition
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.h should remove these lines:
- #include <cstdio>  // lines 9-9
- #include <random>  // lines 11-11

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.h:
#include <stdint.h>                         // for int8_t
#include <cmath>                            // for isnan
#include <memory>                           // for unique_ptr
#include <vector>                           // for vector
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for score_t
#include "LightGBM/tree.h"                  // for Tree
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "data_partition.hpp"               // for DataPartition
#include "serial_tree_learner.h"            // for SerialTreeLearner
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.cpp should add these lines:
#include <cstdio>                                             // for size_t
#include <new>                                                // for operato...
#include <type_traits>                                        // for __remov...
#include <utility>                                            // for move, swap
#include "Eigen/src/Core/Assign.h"                            // for MatrixB...
#include "Eigen/src/Core/AssignEvaluator.h"                   // for call_as...
#include "Eigen/src/Core/Block.h"                             // for traits<...
#include "Eigen/src/Core/CoreEvaluators.h"                    // for evaluat...
#include "Eigen/src/Core/CwiseBinaryOp.h"                     // for MatrixB...
#include "Eigen/src/Core/CwiseNullaryOp.h"                    // for traits<...
#include "Eigen/src/Core/CwiseUnaryOp.h"                      // for CwiseUn...
#include "Eigen/src/Core/DenseBase.h"                         // for DenseBa...
#include "Eigen/src/Core/DenseCoeffsBase.h"                   // for inner_s...
#include "Eigen/src/Core/Dot.h"                               // for MatrixB...
#include "Eigen/src/Core/GeneralProduct.h"                    // for product...
#include "Eigen/src/Core/GenericPacketMath.h"                 // for default...
#include "Eigen/src/Core/Inverse.h"                           // for Inverse
#include "Eigen/src/Core/Map.h"                               // for traits<...
#include "Eigen/src/Core/MapBase.h"                           // for MapBase...
#include "Eigen/src/Core/MathFunctions.h"                     // for mini, maxi
#include "Eigen/src/Core/Matrix.h"                            // for Matrix
#include "Eigen/src/Core/MatrixBase.h"                        // for MatrixBase
#include "Eigen/src/Core/NoAlias.h"                           // for MatrixB...
#include "Eigen/src/Core/NumTraits.h"                         // for Generic...
#include "Eigen/src/Core/PartialReduxEvaluator.h"             // for evaluat...
#include "Eigen/src/Core/PermutationMatrix.h"                 // for operator*
#include "Eigen/src/Core/Product.h"                           // for Product
#include "Eigen/src/Core/Redux.h"                             // for DenseBa...
#include "Eigen/src/Core/SelfCwiseBinaryOp.h"                 // for DenseBa...
#include "Eigen/src/Core/SolverBase.h"                        // for SolverB...
#include "Eigen/src/Core/Stride.h"                            // for Stride<...
#include "Eigen/src/Core/Transpose.h"                         // for traits<...
#include "Eigen/src/Core/TriangularMatrix.h"                  // for MatrixB...
#include "Eigen/src/Core/VectorwiseOp.h"                      // for member_...
#include "Eigen/src/Core/arch/SSE/PacketMath.h"               // for unpacke...
#include "Eigen/src/Core/functors/BinaryFunctors.h"           // for functor...
#include "Eigen/src/Core/functors/NullaryFunctors.h"          // for functor...
#include "Eigen/src/Core/functors/UnaryFunctors.h"            // for functor...
#include "Eigen/src/Core/products/GeneralBlockPanelKernel.h"  // for gebp_tr...
#include "Eigen/src/Core/util/BlasUtil.h"                     // for blas_tr...
#include "Eigen/src/Core/util/Constants.h"                    // for Storage...
#include "Eigen/src/Core/util/ForwardDeclarations.h"          // for accesso...
#include "Eigen/src/Core/util/Memory.h"                       // for first_a...
#include "Eigen/src/Core/util/Meta.h"                         // for is_same...
#include "Eigen/src/Core/util/XprHelper.h"                    // for size_at...
#include "Eigen/src/LU/FullPivLU.h"                           // for FullPivLU
#include "LightGBM/bin.h"                                     // for BinType
#include "LightGBM/config.h"                                  // for Config
#include "LightGBM/train_share_states.h"                      // for Trainin...
#include "LightGBM/utils/array_args.h"                        // for ArrayArgs
#include "LightGBM/utils/common.h"                            // for Functio...
#include "monotone_constraints.hpp"                           // for LeafCon...
#include "omp.h"                                              // for omp_get...
#include "split_info.hpp"                                     // for SplitInfo
#include "src/Core/DenseBase.h"                               // for DenseBa...
#include "src/Core/MatrixBase.h"                              // for operator*

/Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.cpp should remove these lines:
- #include <Eigen/Dense>  // lines 7-7

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/linear_tree_learner.cpp:
#include "linear_tree_learner.h"
#include <algorithm>                                          // for fill
#include <cstdio>                                             // for size_t
#include <new>                                                // for operato...
#include <type_traits>                                        // for __remov...
#include <utility>                                            // for move, swap
#include "Eigen/src/Core/Assign.h"                            // for MatrixB...
#include "Eigen/src/Core/AssignEvaluator.h"                   // for call_as...
#include "Eigen/src/Core/Block.h"                             // for traits<...
#include "Eigen/src/Core/CoreEvaluators.h"                    // for evaluat...
#include "Eigen/src/Core/CwiseBinaryOp.h"                     // for MatrixB...
#include "Eigen/src/Core/CwiseNullaryOp.h"                    // for traits<...
#include "Eigen/src/Core/CwiseUnaryOp.h"                      // for CwiseUn...
#include "Eigen/src/Core/DenseBase.h"                         // for DenseBa...
#include "Eigen/src/Core/DenseCoeffsBase.h"                   // for inner_s...
#include "Eigen/src/Core/Dot.h"                               // for MatrixB...
#include "Eigen/src/Core/GeneralProduct.h"                    // for product...
#include "Eigen/src/Core/GenericPacketMath.h"                 // for default...
#include "Eigen/src/Core/Inverse.h"                           // for Inverse
#include "Eigen/src/Core/Map.h"                               // for traits<...
#include "Eigen/src/Core/MapBase.h"                           // for MapBase...
#include "Eigen/src/Core/MathFunctions.h"                     // for mini, maxi
#include "Eigen/src/Core/Matrix.h"                            // for Matrix
#include "Eigen/src/Core/MatrixBase.h"                        // for MatrixBase
#include "Eigen/src/Core/NoAlias.h"                           // for MatrixB...
#include "Eigen/src/Core/NumTraits.h"                         // for Generic...
#include "Eigen/src/Core/PartialReduxEvaluator.h"             // for evaluat...
#include "Eigen/src/Core/PermutationMatrix.h"                 // for operator*
#include "Eigen/src/Core/Product.h"                           // for Product
#include "Eigen/src/Core/Redux.h"                             // for DenseBa...
#include "Eigen/src/Core/SelfCwiseBinaryOp.h"                 // for DenseBa...
#include "Eigen/src/Core/SolverBase.h"                        // for SolverB...
#include "Eigen/src/Core/Stride.h"                            // for Stride<...
#include "Eigen/src/Core/Transpose.h"                         // for traits<...
#include "Eigen/src/Core/TriangularMatrix.h"                  // for MatrixB...
#include "Eigen/src/Core/VectorwiseOp.h"                      // for member_...
#include "Eigen/src/Core/arch/SSE/PacketMath.h"               // for unpacke...
#include "Eigen/src/Core/functors/BinaryFunctors.h"           // for functor...
#include "Eigen/src/Core/functors/NullaryFunctors.h"          // for functor...
#include "Eigen/src/Core/functors/UnaryFunctors.h"            // for functor...
#include "Eigen/src/Core/products/GeneralBlockPanelKernel.h"  // for gebp_tr...
#include "Eigen/src/Core/util/BlasUtil.h"                     // for blas_tr...
#include "Eigen/src/Core/util/Constants.h"                    // for Storage...
#include "Eigen/src/Core/util/ForwardDeclarations.h"          // for accesso...
#include "Eigen/src/Core/util/Memory.h"                       // for first_a...
#include "Eigen/src/Core/util/Meta.h"                         // for is_same...
#include "Eigen/src/Core/util/XprHelper.h"                    // for size_at...
#include "Eigen/src/LU/FullPivLU.h"                           // for FullPivLU
#include "LightGBM/bin.h"                                     // for BinType
#include "LightGBM/config.h"                                  // for Config
#include "LightGBM/train_share_states.h"                      // for Trainin...
#include "LightGBM/utils/array_args.h"                        // for ArrayArgs
#include "LightGBM/utils/common.h"                            // for Functio...
#include "monotone_constraints.hpp"                           // for LeafCon...
#include "omp.h"                                              // for omp_get...
#include "split_info.hpp"                                     // for SplitInfo
#include "src/Core/DenseBase.h"                               // for DenseBa...
#include "src/Core/MatrixBase.h"                              // for operator*
---

[ 88%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/serial_tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.h should add these lines:
#include <stdint.h>                         // for int8_t, int32_t
#include <functional>                       // for function
#include "LightGBM/meta.h"                  // for score_t, data_size_t, kAl...
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/common.h"          // for AlignmentAllocator
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
namespace LightGBM { class Dataset; }
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { struct Config; }

/Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.h should remove these lines:
- #include <LightGBM/cuda/vector_cudahost.h>  // lines 11-11
- #include <LightGBM/dataset.h>  // lines 8-8
- #include <LightGBM/utils/array_args.h>  // lines 12-12
- #include <LightGBM/utils/random.h>  // lines 14-14
- #include <cmath>  // lines 17-17
- #include <cstdio>  // lines 18-18
- #include <random>  // lines 20-20
- #include <string>  // lines 16-16

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.h:
#include <LightGBM/tree.h>                  // for Tree
#include <LightGBM/tree_learner.h>          // for TreeLearner
#include <LightGBM/utils/json11.h>          // for Json
#include <stdint.h>                         // for int8_t, int32_t
#include <functional>                       // for function
#include <memory>                           // for unique_ptr
#include <set>                              // for set
#include <vector>                           // for vector
#include "LightGBM/meta.h"                  // for score_t, data_size_t, kAl...
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/common.h"          // for AlignmentAllocator
#include "LightGBM/utils/log.h"             // for CHECK_LE
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS
#include "col_sampler.hpp"                  // for ColSampler
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for HistogramPool
#include "gradient_discretizer.hpp"         // for GradientDiscretizer
#include "leaf_splits.hpp"                  // for LeafSplits
#include "monotone_constraints.hpp"         // for LeafConstraintsBase
#include "split_info.hpp"                   // for SplitInfo
namespace LightGBM { class CostEfficientGradientBoosting; }  // lines 43-43
namespace LightGBM { class Dataset; }
namespace LightGBM { class ObjectiveFunction; }
namespace LightGBM { struct Config; }
---

/Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.cpp should add these lines:
#include <cstdio>                                // for size_t
#include <string>                                // for basic_string, operat...
#include "LightGBM/bin.h"                        // for hist_t, kHistOffset
#include "LightGBM/config.h"                     // for Config
#include "LightGBM/dataset.h"                    // for Dataset
#include "LightGBM/tree.h"                       // for Tree
#include "LightGBM/utils/json11.h"               // for Json
#include "omp.h"                                 // for omp_get_thread_num

/Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/serial_tree_learner.cpp:
#include "serial_tree_learner.h"
#include <LightGBM/network.h>                    // for Network
#include <LightGBM/objective_function.h>         // for ObjectiveFunction
#include <LightGBM/utils/array_args.h>           // for ArrayArgs
#include <LightGBM/utils/common.h>               // for AlignmentAllocator
#include <algorithm>                             // for max, min
#include <cstdio>                                // for size_t
#include <queue>                                 // for queue
#include <set>                                   // for set, operator==
#include <string>                                // for basic_string, operat...
#include <unordered_map>                         // for unordered_map, opera...
#include <utility>                               // for pair, make_pair
#include "LightGBM/bin.h"                        // for hist_t, kHistOffset
#include "LightGBM/config.h"                     // for Config
#include "LightGBM/dataset.h"                    // for Dataset
#include "LightGBM/tree.h"                       // for Tree
#include "LightGBM/utils/json11.h"               // for Json
#include "cost_effective_gradient_boosting.hpp"  // for CostEfficientGradien...
#include "omp.h"                                 // for omp_get_thread_num
---

[ 91%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/tree_learner.h should add these lines:
#include <functional>       // for function
namespace LightGBM { struct Config; }
namespace json11_internal_lightgbm { class Json; }

/Users/jlamb/repos/LightGBM/include/LightGBM/tree_learner.h should remove these lines:
- #include <LightGBM/config.h>  // lines 8-8
- #include <LightGBM/utils/json11.h>  // lines 10-10

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/tree_learner.h:
#include <LightGBM/meta.h>  // for score_t, data_size_t, label_t
#include <functional>       // for function
#include <string>           // for string
#include <vector>           // for vector
namespace LightGBM { class Dataset; }  // lines 21-21
namespace LightGBM { class ObjectiveFunction; }  // lines 22-22
namespace LightGBM { class Tree; }  // lines 20-20
namespace LightGBM { struct Config; }
namespace json11_internal_lightgbm { class Json; }
---

/Users/jlamb/repos/LightGBM/src/treelearner/tree_learner.cpp should add these lines:
#include "LightGBM/config.h"                      // for Config
#include "LightGBM/utils/log.h"                   // for Log

/Users/jlamb/repos/LightGBM/src/treelearner/tree_learner.cpp should remove these lines:

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/tree_learner.cpp:
#include <LightGBM/tree_learner.h>
#include "LightGBM/config.h"                      // for Config
#include "LightGBM/utils/log.h"                   // for Log
#include "cuda/cuda_single_gpu_tree_learner.hpp"  // for CUDASingleGPUTreeLe...
#include "gpu_tree_learner.h"                     // for GPUTreeLearner
#include "linear_tree_learner.h"                  // for LinearTreeLearner
#include "parallel_tree_learner.h"                // for DataParallelTreeLea...
#include "serial_tree_learner.h"                  // for SerialTreeLearner
---

[ 94%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/voting_parallel_tree_learner.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/src/treelearner/voting_parallel_tree_learner.cpp should add these lines:
#include <stdint.h>                         // for int8_t, uint32_t
#include <algorithm>                        // for max, min, stable_sort
#include <functional>                       // for greater
#include <memory>                           // for unique_ptr, operator!=
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, kHistE...
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for data_size_t, comm_size_t
#include "LightGBM/network.h"               // for Network
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/array_args.h"      // for ArrayArgs
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "col_sampler.hpp"                  // for ColSampler
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram, Feature...
#include "gpu_tree_learner.h"               // for GPUTreeLearner
#include "leaf_splits.hpp"                  // for LeafSplits
#include "omp.h"                            // for omp_get_thread_num
#include "serial_tree_learner.h"            // for SerialTreeLearner
#include "split_info.hpp"                   // for LightSplitInfo, SplitInfo
namespace LightGBM { class Tree; }

/Users/jlamb/repos/LightGBM/src/treelearner/voting_parallel_tree_learner.cpp should remove these lines:
- #include <LightGBM/utils/common.h>  // lines 5-5

The full include-list for /Users/jlamb/repos/LightGBM/src/treelearner/voting_parallel_tree_learner.cpp:
#include <stdint.h>                         // for int8_t, uint32_t
#include <algorithm>                        // for max, min, stable_sort
#include <cstring>                          // for memcpy, size_t, memset
#include <functional>                       // for greater
#include <memory>                           // for unique_ptr, operator!=
#include <tuple>                            // for get, tuple
#include <vector>                           // for vector
#include "LightGBM/bin.h"                   // for BinMapper, hist_t, kHistE...
#include "LightGBM/config.h"                // for Config
#include "LightGBM/dataset.h"               // for Dataset
#include "LightGBM/meta.h"                  // for data_size_t, comm_size_t
#include "LightGBM/network.h"               // for Network
#include "LightGBM/train_share_states.h"    // for TrainingShareStates
#include "LightGBM/utils/array_args.h"      // for ArrayArgs
#include "LightGBM/utils/openmp_wrapper.h"  // for OMP_NUM_THREADS, OMP_INIT_EX
#include "col_sampler.hpp"                  // for ColSampler
#include "data_partition.hpp"               // for DataPartition
#include "feature_histogram.hpp"            // for FeatureHistogram, Feature...
#include "gpu_tree_learner.h"               // for GPUTreeLearner
#include "leaf_splits.hpp"                  // for LeafSplits
#include "omp.h"                            // for omp_get_thread_num
#include "parallel_tree_learner.h"          // for VotingParallelTreeLearner
#include "serial_tree_learner.h"            // for SerialTreeLearner
#include "split_info.hpp"                   // for LightSplitInfo, SplitInfo
namespace LightGBM { class Tree; }
---

[ 97%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/utils/openmp_wrapper.cpp.o
Warning: include-what-you-use reported diagnostics:

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/openmp_wrapper.h should add these lines:
#include <__exception/exception_ptr.h>  // for exception_ptr, operator!=
#include <__exception/operations.h>     // for current_exception, rethrow_ex...
#include <__mutex/mutex.h>              // for mutex
#include <__mutex/unique_lock.h>        // for unique_lock

/Users/jlamb/repos/LightGBM/include/LightGBM/utils/openmp_wrapper.h should remove these lines:
- #include <LightGBM/utils/log.h>  // lines 19-19
- #include <omp.h>  // lines 21-21
- #include <exception>  // lines 23-23
- #include <memory>  // lines 24-24
- #include <mutex>  // lines 25-25
- #include <stdexcept>  // lines 26-26
- #include <vector>  // lines 27-27

The full include-list for /Users/jlamb/repos/LightGBM/include/LightGBM/utils/openmp_wrapper.h:
#include <LightGBM/export.h>            // for LIGHTGBM_EXTERN_C
#include <__exception/exception_ptr.h>  // for exception_ptr, operator!=
#include <__exception/operations.h>     // for current_exception, rethrow_ex...
#include <__mutex/mutex.h>              // for mutex
#include <__mutex/unique_lock.h>        // for unique_lock
---

(/Users/jlamb/repos/LightGBM/src/utils/openmp_wrapper.cpp has correct #includes/fwd-decls)

[ 97%] Built target lightgbm_objs
[100%] Linking CXX shared library ../lib_lightgbm.so
[100%] Built target _lightgbm

@StrikerRUS
Copy link
Collaborator

Ah, I thought that cppcheck is useful for such problems. But it seems that I was wrong - no "unused includes" check:

@StrikerRUS
Copy link
Collaborator

I spent about 2 hours trying to make it work in our CI, but unfortunately I wasn't able to make it output anything.
Probably it's the same issue as described here: https://gitlab.kitware.com/cmake/cmake/-/issues/19706#note_626545, but I don't see any compilation warnings in our usual Clang job: https://dev.azure.com/lightgbm-ci/lightgbm-ci/_build/results?buildId=17393&view=logs&j=275189f9-c769-596a-7ef9-49fb48a9ab70&t=3a9e7a4a-04e6-52a0-67ea-6e8f6cfda74f&l=3040

What I've done:
  • Added
echo "running include-what-you-use"
# cmake -B build -S . -DCMAKE_C_INCLUDE_WHAT_YOU_USE="include-what-you-use;-Xiwyu;any;-Xiwyu;iwyu;-Xiwyu;args" -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-Xiwyu;any;-Xiwyu;iwyu;-Xiwyu;args" -G Ninja
# cmake --build build -j4 || true
cmake \
    -B build \
    -S . \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_C_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--verbose=7" \
    -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--verbose=7"

cmake \
    --build build \
    --target _lightgbm \
    >./logs.txt 2>&1
cat ./logs.txt
echo "done running include-what-you-use"

here

  • Modified this line to install libomp for lint CI job
if [[ $TASK == "r-package" || $TASK == "lint" ]] && [[ $COMPILER == "clang" ]]; then

if [[ $TASK == "r-package" ]] && [[ $COMPILER == "clang" ]]; then

  • Installed IWYU via conda here
'include-what-you-use>=0.23' \

'cpplint>=1.6.0' \

  • Switched to clang in lint job and fetched git submodules for it
COMPILER: 'clang'

submodules: true

And after all these changes and multiple versions of DCMAKE_C_INCLUDE_WHAT_YOU_USE values I got clean build logs without any IWYU outputs

running include-what-you-use
-- The C compiler identification is Clang 14.0.0
-- The CXX compiler identification is Clang 14.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/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/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -fopenmp=libomp (found version "5.0")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
-- Performing Test MM_PREFETCH
-- Performing Test MM_PREFETCH - Success
-- Using _mm_prefetch
-- Performing Test MM_MALLOC
-- Performing Test MM_MALLOC - Success
-- Using _mm_malloc
-- Configuring done (1.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/runner/work/LightGBM/LightGBM/build
[  2%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.o
[  5%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.o
[  8%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_model_text.cpp.o
[ 11%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_prediction.cpp.o
[ 13%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt.cpp.o
[ 16%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/prediction_early_stop.cpp.o
[ 19%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/sample_strategy.cpp.o
[ 22%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/bin.cpp.o
[ 25%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config_auto.cpp.o
[ 27%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/config.cpp.o
[ 27%] Built target lightgbm_capi_objs
[ 30%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset_loader.cpp.o
[ 33%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/dataset.cpp.o
[ 36%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/file_io.cpp.o
[ 38%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/json11.cpp.o
[ 41%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/metadata.cpp.o
[ 44%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/parser.cpp.o
[ 47%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/train_share_states.cpp.o
[ 50%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/io/tree.cpp.o
[ 52%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/dcg_calculator.cpp.o
[ 55%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/metric/metric.cpp.o
[ 58%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linker_topo.cpp.o
[ 61%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_mpi.cpp.o
[ 63%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/linkers_socket.cpp.o
[ 66%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/network/network.cpp.o
[ 69%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/objective/objective_function.cpp.o
[ 72%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/data_parallel_tree_learner.cpp.o
[ 75%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/feature_histogram.cpp.o
[ 77%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/feature_parallel_tree_learner.cpp.o
[ 80%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gpu_tree_learner.cpp.o
[ 83%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/gradient_discretizer.cpp.o
[ 86%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/linear_tree_learner.cpp.o
[ 88%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/serial_tree_learner.cpp.o
[ 91%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/tree_learner.cpp.o
[ 94%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/treelearner/voting_parallel_tree_learner.cpp.o
[ 97%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/utils/openmp_wrapper.cpp.o
[ 97%] Built target lightgbm_objs
[100%] Linking CXX shared library /home/runner/work/LightGBM/LightGBM/lib_lightgbm.so
[100%] Built target _lightgbm
done running include-what-you-use

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Dec 15, 2024

As an alternative I think we can try clang-tidy's misc-include-cleaner.

Some refs.:

Logs:
-- Build files have been written to: /home/runner/work/LightGBM/LightGBM/build
[  2%] Building CXX object CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.o
[  5%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.o
[  8%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_model_text.cpp.o
[ 11%] Building CXX object CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_prediction.cpp.o
/home/runner/miniforge/envs/test-env/x86_64-conda-linux-gnu/sysroot/usr/include/wchar.h:39:11: error: 'stdarg.h' file not found [clang-diagnostic-error]
   39 | # include <stdarg.h>
      |           ^~~~~~~~~~
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_prediction.cpp:7:1: warning: included header openmp_wrapper.h is not used directly [misc-include-cleaner]
    7 | #include <LightGBM/utils/openmp_wrapper.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    8 | 
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_prediction.cpp:16:8: warning: no header providing "std::memset" is directly included [misc-include-cleaner]
    8 | 
    9 | #include "gbdt.h"
   10 | 
   11 | namespace LightGBM {
   12 | 
   13 | void GBDT::PredictRaw(const double* features, double* output, const PredictionEarlyStopInstance* early_stop) const {
   14 |   int early_stop_round_counter = 0;
   15 |   // set zero
   16 |   std::memset(output, 0, sizeof(double) * num_tree_per_iteration_);
      |        ^
2 warnings and 1 error generated.
Error while processing /home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_prediction.cpp.
Found compiler error(s).
/home/runner/miniforge/envs/test-env/x86_64-conda-linux-gnu/sysroot/usr/include/wchar.h:39:11: error: 'stdarg.h' file not found [clang-diagnostic-error]
   39 | # include <stdarg.h>
      |           ^~~~~~~~~~
/home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp:13:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
    6 | 
    7 | #include "dart.hpp"
    8 | #include "gbdt.h"
    9 | #include "rf.hpp"
   10 | 
   11 | namespace LightGBM {
   12 | 
   13 | std::string GetBoostingTypeFromModelFile(const char* filename) {
      |      ^
/home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp:20:34: warning: no header providing "std::chrono::steady_clock" is directly included [misc-include-cleaner]
    6 | 
    7 | #include "dart.hpp"
    8 | #include "gbdt.h"
    9 | #include "rf.hpp"
   10 | 
   11 | namespace LightGBM {
   12 | 
   13 | std::string GetBoostingTypeFromModelFile(const char* filename) {
   14 |   TextReader<size_t> model_reader(filename, true);
   15 |   std::string type = model_reader.first_line();
   16 |   return type;
   17 | }
   18 | 
   19 | bool Boosting::LoadFileToBoosting(Boosting* boosting, const char* filename) {
   20 |   auto start_time = std::chrono::steady_clock::now();
      |                                  ^
/home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp:29:16: warning: no header providing "std::chrono::duration" is directly included [misc-include-cleaner]
   29 |   std::chrono::duration<double, std::milli> delta = (std::chrono::steady_clock::now() - start_time);
      |                ^
/home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp:29:38: warning: no header providing "std::milli" is directly included [misc-include-cleaner]
    6 |   std::chrono::duration<double, std::milli> delta = (std::chrono::steady_clock::now() - start_time);
      |                                      ^
/home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp:30:3: warning: no header providing "LightGBM::Log" is directly included [misc-include-cleaner]
    7 |   Log::Debug("Time for loading model: %f seconds", 1e-3*delta);
      |   ^
5 warnings and 1 error generated.
Error while processing /home/runner/work/LightGBM/LightGBM/src/boosting/boosting.cpp.
Found compiler error(s).
gmake[3]: *** [CMakeFiles/lightgbm_objs.dir/build.make:104: CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_prediction.cpp.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[3]: *** [CMakeFiles/lightgbm_objs.dir/build.make:76: CMakeFiles/lightgbm_objs.dir/src/boosting/boosting.cpp.o] Error 1
/home/runner/miniforge/envs/test-env/x86_64-conda-linux-gnu/sysroot/usr/include/wchar.h:39:11: error: 'stdarg.h' file not found [clang-diagnostic-error]
   39 | # include <stdarg.h>
      |           ^~~~~~~~~~
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:5:1: warning: included header config.h is not used directly [misc-include-cleaner]
    5 | #include <LightGBM/config.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6 | #include <LightGBM/metric.h>
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:6:1: warning: included header metric.h is not used directly [misc-include-cleaner]
    6 | #include <LightGBM/metric.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    7 | #include <LightGBM/objective_function.h>
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:8:1: warning: included header array_args.h is not used directly [misc-include-cleaner]
    8 | #include <LightGBM/utils/array_args.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    9 | #include <LightGBM/utils/common.h>
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:13:1: warning: included header vector is not used directly [misc-include-cleaner]
   13 | #include <vector>
      | ^~~~~~~~~~~~~~~~~
   14 | 
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:56:28: warning: no header providing "std::setprecision" is directly included [misc-include-cleaner]
   11 |       json_str_buf << std::setprecision(std::numeric_limits<double>::digits10 + 2);
      |                            ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:56:46: warning: no header providing "std::numeric_limits" is directly included [misc-include-cleaner]
   11 |       json_str_buf << std::setprecision(std::numeric_limits<double>::digits10 + 2);
      |                                              ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:288:8: warning: no header providing "std::ofstream" is directly included [misc-include-cleaner]
   11 |   std::ofstream output_file;
      |        ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:289:8: warning: no header providing "std::ifstream" is directly included [misc-include-cleaner]
  289 |   std::ifstream ifs(filename);
      |        ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:357:40: warning: no header providing "OMP_NUM_THREADS" is directly included [misc-include-cleaner]
   15 |   #pragma omp parallel for num_threads(OMP_NUM_THREADS()) schedule(static)
      |                                        ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:414:5: warning: no header providing "LightGBM::Log" is directly included [misc-include-cleaner]
   15 |     Log::Fatal("Model file %s is not available for writes", filename);
      |     ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:554:5: warning: no header providing "OMP_INIT_EX" is directly included [misc-include-cleaner]
  554 |     OMP_INIT_EX();
      |     ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:557:7: warning: no header providing "OMP_LOOP_EX_BEGIN" is directly included [misc-include-cleaner]
  557 |       OMP_LOOP_EX_BEGIN();
      |       ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:569:7: warning: no header providing "OMP_LOOP_EX_END" is directly included [misc-include-cleaner]
  569 |       OMP_LOOP_EX_END();
      |       ^
/home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp:571:5: warning: no header providing "OMP_THROW_EX" is directly included [misc-include-cleaner]
  571 |     OMP_THROW_EX();
      |     ^
14 warnings and 1 error generated.
Error while processing /home/runner/work/LightGBM/LightGBM/src/boosting/gbdt_model_text.cpp.
Found compiler error(s).
gmake[3]: *** [CMakeFiles/lightgbm_objs.dir/build.make:90: CMakeFiles/lightgbm_objs.dir/src/boosting/gbdt_model_text.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:89: CMakeFiles/lightgbm_objs.dir/all] Error 2
gmake[2]: *** Waiting for unfinished jobs....
/home/runner/miniforge/envs/test-env/x86_64-conda-linux-gnu/sysroot/usr/include/stdlib.h:32:10: error: 'stddef.h' file not found [clang-diagnostic-error]
   32 | #include <stddef.h>
      |          ^~~~~~~~~~
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:12:1: warning: included header metric.h is not used directly [misc-include-cleaner]
   12 | #include <LightGBM/metric.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 | #include <LightGBM/network.h>
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:14:1: warning: included header objective_function.h is not used directly [misc-include-cleaner]
   14 | #include <LightGBM/objective_function.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   15 | #include <LightGBM/prediction_early_stop.h>
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:15:1: warning: included header prediction_early_stop.h is not used directly [misc-include-cleaner]
   15 | #include <LightGBM/prediction_early_stop.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   16 | #include <LightGBM/utils/byte_buffer.h>
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:21:1: warning: included header threading.h is not used directly [misc-include-cleaner]
   21 | #include <LightGBM/utils/threading.h>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   22 | 
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:27:1: warning: included header memory is not used directly [misc-include-cleaner]
   27 | #include <memory>
      | ^~~~~~~~~~~~~~~~~
   28 | #include <mutex>
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:29:1: warning: included header stdexcept is not used directly [misc-include-cleaner]
   29 | #include <stdexcept>
      | ^~~~~~~~~~~~~~~~~~~~
   30 | #include <vector>
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:30:1: warning: included header vector is not used directly [misc-include-cleaner]
   30 | #include <vector>
      | ^~~~~~~~~~~~~~~~~
   31 | 
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:38:47: warning: no header providing "std::exception" is directly included [misc-include-cleaner]
   23 | #include <string>
   24 | #include <cstdio>
   25 | #include <cstdint>
   26 | #include <functional>
   27 | #include <memory>
   28 | #include <mutex>
   29 | #include <stdexcept>
   30 | #include <vector>
   31 | 
   32 | #include "application/predictor.hpp"
   33 | #include <LightGBM/utils/yamc/alternate_shared_mutex.hpp>
   34 | #include <LightGBM/utils/yamc/yamc_shared_lock.hpp>
   35 | 
   36 | namespace LightGBM {
   37 | 
   38 | inline int LGBM_APIHandleException(const std::exception& ex) {
      |                                               ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:65:3: warning: no header providing "LightGBM::PredictFunction" is directly included [misc-include-cleaner]
   32 |   PredictFunction predict_function;
      |   ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:416:27: warning: no header providing "LightGBM::score_t" is directly included [misc-include-cleaner]
  416 |   bool TrainOneIter(const score_t* gradients, const score_t* hessians) {
      |                           ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:895:17: warning: no header providing "LightGBM::AllgatherFunction" is directly included [misc-include-cleaner]
  895 | using LightGBM::AllgatherFunction;
      |                 ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:904:17: warning: no header providing "LightGBM::data_size_t" is directly included [misc-include-cleaner]
  904 | using LightGBM::data_size_t;
      |                 ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:907:17: warning: no header providing "LightGBM::kZeroThreshold" is directly included [misc-include-cleaner]
  907 | using LightGBM::kZeroThreshold;
      |                 ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:912:17: warning: no header providing "LightGBM::ReduceScatterFunction" is directly included [misc-include-cleaner]
  912 | using LightGBM::ReduceScatterFunction;
      |                 ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:[940](https://github.com/microsoft/LightGBM/actions/runs/12342122944/job/34441580895#step:3:941):8: warning: no header providing "std::pair" is directly included [misc-include-cleaner]
   30 |   std::pair<int, double> NextNonZero();
      |        ^
/home/runner/work/LightGBM/LightGBM/src/c_api.cpp:963:10: warning: no header providing "std::memcpy" is directly included [misc-include-cleaner]
   23 |     std::memcpy(out_str, aliases.c_str(), *out_len);
      |          ^
16 warnings and 1 error generated.
Error while processing /home/runner/work/LightGBM/LightGBM/src/c_api.cpp.
Found compiler error(s).
gmake[3]: *** [CMakeFiles/lightgbm_capi_objs.dir/build.make:76: CMakeFiles/lightgbm_capi_objs.dir/src/c_api.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:141: CMakeFiles/lightgbm_capi_objs.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:175: CMakeFiles/_lightgbm.dir/rule] Error 2
gmake: *** [Makefile:208: _lightgbm] Error 2

@jameslamb
Copy link
Collaborator Author

Thanks for trying this out! Some time, I'll try this again (as I was able to get it working on my mac back in #6284 (comment)

Separately... I'd support trying to get clang-tidy running in this project if you're interested in pursuing that! I think it could be really helpful, and I trust our coverage of compilers / operating systems in CI here to catch any issues caused by its recommendations.

Some RAPIDS projects have recently started adopting that tool and it seems helpful to me, e.g. https://github.com/rapidsai/legate-boost/pull/186/files#diff-4d2a8eefdf2a9783512a35da4dc7676a66404b6f3826a8af9aad038722da6823

@StrikerRUS
Copy link
Collaborator

As a next step I'll

Try reverting the change from #6265 and test if clang-tidy would have caught it.

In case of success, I'll prepare a PR with clang-tidy.

@StrikerRUS
Copy link
Collaborator

Unfortunately, clang-tidy wasn't able to catch the error from #6265.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants