diff --git a/SConstruct b/SConstruct index 61691b22992..d44388916e4 100644 --- a/SConstruct +++ b/SConstruct @@ -267,6 +267,11 @@ opts.Add( ) opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) opts.Add(BoolVariable("strict_checks", "Enforce stricter checks (debug option)", False)) +opts.Add( + BoolVariable( + "limit_transitive_includes", "Attempt to limit the amount of transitive includes in system headers", True + ) +) opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False)) opts.Add("scu_limit", "Max includes per SCU file when using scu_build (determines RAM use)", "0") opts.Add(BoolVariable("engine_update_check", "Enable engine update checks in the Project Manager", True)) @@ -778,6 +783,13 @@ elif methods.using_clang(env) or methods.using_emcc(env): if sys.platform == "win32": env.AppendUnique(CCFLAGS=["-fansi-escape-codes"]) +# Attempt to reduce transitive includes. +if env["limit_transitive_includes"]: + if not env.msvc: + # FIXME: This define only affects `libcpp`, but lack of guaranteed, granular detection means + # we're better off applying it universally. + env.AppendUnique(CPPDEFINES=["_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"]) + # Set optimize and debug_symbols flags. # "custom" means do nothing and let users set their own optimization flags. # Needs to happen after configure to have `env.msvc` defined. diff --git a/core/typedefs.h b/core/typedefs.h index bb9ec9a8ca6..0928f8aaff0 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -51,6 +51,7 @@ static_assert(__cplusplus >= 201703L, "Minimum of C++17 required."); #include #include #include +#include #include // IWYU pragma: end_exports diff --git a/drivers/metal/metal_objects.h b/drivers/metal/metal_objects.h index 3860218a0e7..a93cc64ee1f 100644 --- a/drivers/metal/metal_objects.h +++ b/drivers/metal/metal_objects.h @@ -65,6 +65,7 @@ #import #import #import +#import #import enum StageResourceUsage : uint32_t { diff --git a/thirdparty/README.md b/thirdparty/README.md index 979c1b4d889..ae34e0a2801 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -90,6 +90,7 @@ Patches: - `0003-remove-tinydds-qoi.patch` (GH-97582) - `0004-clang-warning-exclude.patch` (GH-111346) - `0005-unused-typedef.patch` (GH-111445) +- `0006-explicit-includes.patch` (GH-111557) ## brotli @@ -220,6 +221,7 @@ Patches: - `0003-emscripten-nthreads.patch` (GH-69799) - `0004-mingw-no-cpuidex.patch` (GH-92488) - `0005-mingw-llvm-arm64.patch` (GH-93364) +- `0006-explicit-includes.patch` (GH-111557) The `modules/raycast/godot_update_embree.py` script can be used to pull the relevant files from the latest Embree release and apply patches automatically. @@ -707,6 +709,7 @@ Patches: - `0001-disable-exceptions.patch` (GH-85039) - `0002-clang-std-replacements-leak.patch` (GH-85208) +- `0003-explicit-includes.patch` (GH-111557) ## minimp3 @@ -1046,6 +1049,7 @@ Patches: - `0001-revert-tvglines-bezier-precision.patch` (GH-96658) - `0002-use-heap-alloc.patch` (GH-109530) +- `0003-explicit-includes.patch` (GH-111557) ## tinyexr diff --git a/thirdparty/basis_universal/patches/0005-msvc-include-ctype.patch b/thirdparty/basis_universal/patches/0006-explicit-includes.patch similarity index 86% rename from thirdparty/basis_universal/patches/0005-msvc-include-ctype.patch rename to thirdparty/basis_universal/patches/0006-explicit-includes.patch index 3a38950bbcc..3d7c860c847 100644 --- a/thirdparty/basis_universal/patches/0005-msvc-include-ctype.patch +++ b/thirdparty/basis_universal/patches/0006-explicit-includes.patch @@ -1,12 +1,13 @@ diff --git a/thirdparty/basis_universal/transcoder/basisu_containers_impl.h b/thirdparty/basis_universal/transcoder/basisu_containers_impl.h -index d4d3eb23bc..3d7aaddcad 100644 +index 3d7aaddcad..db3a567450 100644 --- a/thirdparty/basis_universal/transcoder/basisu_containers_impl.h +++ b/thirdparty/basis_universal/transcoder/basisu_containers_impl.h -@@ -1,6 +1,8 @@ +@@ -1,6 +1,9 @@ // basisu_containers_impl.h // Do not include directly +#include ++#include + #ifdef _MSC_VER #pragma warning (disable:4127) // warning C4127: conditional expression is constant diff --git a/thirdparty/basis_universal/transcoder/basisu_containers_impl.h b/thirdparty/basis_universal/transcoder/basisu_containers_impl.h index 3d7aaddcade..6d570133d14 100644 --- a/thirdparty/basis_universal/transcoder/basisu_containers_impl.h +++ b/thirdparty/basis_universal/transcoder/basisu_containers_impl.h @@ -2,6 +2,7 @@ // Do not include directly #include +#include #ifdef _MSC_VER #pragma warning (disable:4127) // warning C4127: conditional expression is constant diff --git a/thirdparty/embree/common/sys/vector.h b/thirdparty/embree/common/sys/vector.h index 2d30d6725b6..a8138de8321 100644 --- a/thirdparty/embree/common/sys/vector.h +++ b/thirdparty/embree/common/sys/vector.h @@ -5,6 +5,7 @@ #include "alloc.h" #include +#include namespace embree { diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.h b/thirdparty/embree/common/tasking/taskschedulerinternal.h index d4e0c7386bf..99e47608d6e 100644 --- a/thirdparty/embree/common/tasking/taskschedulerinternal.h +++ b/thirdparty/embree/common/tasking/taskschedulerinternal.h @@ -14,6 +14,7 @@ #include "../sys/atomic.h" #include "../math/range.h" +#include #include namespace embree diff --git a/thirdparty/embree/patches/0006-explicit-includes.patch b/thirdparty/embree/patches/0006-explicit-includes.patch new file mode 100644 index 00000000000..6332f7c93f9 --- /dev/null +++ b/thirdparty/embree/patches/0006-explicit-includes.patch @@ -0,0 +1,24 @@ +diff --git a/thirdparty/embree/common/sys/vector.h b/thirdparty/embree/common/sys/vector.h +index 2d30d6725b..a8138de832 100644 +--- a/thirdparty/embree/common/sys/vector.h ++++ b/thirdparty/embree/common/sys/vector.h +@@ -5,6 +5,7 @@ + + #include "alloc.h" + #include ++#include + + namespace embree + { +diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.h b/thirdparty/embree/common/tasking/taskschedulerinternal.h +index d4e0c7386b..99e47608d6 100644 +--- a/thirdparty/embree/common/tasking/taskschedulerinternal.h ++++ b/thirdparty/embree/common/tasking/taskschedulerinternal.h +@@ -14,6 +14,7 @@ + #include "../sys/atomic.h" + #include "../math/range.h" + ++#include + #include + + namespace embree diff --git a/thirdparty/jolt_physics/Jolt/Core/Core.h b/thirdparty/jolt_physics/Jolt/Core/Core.h index b306f5a6868..b433a779462 100644 --- a/thirdparty/jolt_physics/Jolt/Core/Core.h +++ b/thirdparty/jolt_physics/Jolt/Core/Core.h @@ -453,6 +453,7 @@ JPH_SUPPRESS_WARNINGS_STD_BEGIN #include #include #include +#include #if defined(JPH_COMPILER_MSVC) || (defined(JPH_COMPILER_CLANG) && defined(_MSC_VER)) // MSVC or clang-cl #include // for alloca #endif diff --git a/thirdparty/mingw-std-threads/mingw.condition_variable.h b/thirdparty/mingw-std-threads/mingw.condition_variable.h index d099fad2ec1..d2982fb0871 100644 --- a/thirdparty/mingw-std-threads/mingw.condition_variable.h +++ b/thirdparty/mingw-std-threads/mingw.condition_variable.h @@ -29,6 +29,7 @@ #include #include +#include #include #include // Detect Windows version. diff --git a/thirdparty/mingw-std-threads/mingw.mutex.h b/thirdparty/mingw-std-threads/mingw.mutex.h index 1e881e6c7d4..d9802ea2ae7 100644 --- a/thirdparty/mingw-std-threads/mingw.mutex.h +++ b/thirdparty/mingw-std-threads/mingw.mutex.h @@ -37,6 +37,7 @@ #include #include #include +#include #include //need for call_once() #if STDMUTEX_RECURSION_CHECKS || !defined(NDEBUG) diff --git a/thirdparty/mingw-std-threads/patches/0003-explicit-includes.patch b/thirdparty/mingw-std-threads/patches/0003-explicit-includes.patch new file mode 100644 index 00000000000..65f82919c52 --- /dev/null +++ b/thirdparty/mingw-std-threads/patches/0003-explicit-includes.patch @@ -0,0 +1,24 @@ +diff --git a/thirdparty/mingw-std-threads/mingw.condition_variable.h b/thirdparty/mingw-std-threads/mingw.condition_variable.h +index d099fad2ec..d2982fb087 100644 +--- a/thirdparty/mingw-std-threads/mingw.condition_variable.h ++++ b/thirdparty/mingw-std-threads/mingw.condition_variable.h +@@ -29,6 +29,7 @@ + + #include + #include ++#include + #include + + #include // Detect Windows version. +diff --git a/thirdparty/mingw-std-threads/mingw.mutex.h b/thirdparty/mingw-std-threads/mingw.mutex.h +index 1e881e6c7d..d9802ea2ae 100644 +--- a/thirdparty/mingw-std-threads/mingw.mutex.h ++++ b/thirdparty/mingw-std-threads/mingw.mutex.h +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + #include //need for call_once() + + #if STDMUTEX_RECURSION_CHECKS || !defined(NDEBUG) diff --git a/thirdparty/thorvg/patches/0003-explicit-includes.patch b/thirdparty/thorvg/patches/0003-explicit-includes.patch new file mode 100644 index 00000000000..98ef3761c47 --- /dev/null +++ b/thirdparty/thorvg/patches/0003-explicit-includes.patch @@ -0,0 +1,36 @@ +diff --git a/thirdparty/thorvg/src/common/tvgCompressor.cpp b/thirdparty/thorvg/src/common/tvgCompressor.cpp +index 714f21e07c..d97ae85705 100644 +--- a/thirdparty/thorvg/src/common/tvgCompressor.cpp ++++ b/thirdparty/thorvg/src/common/tvgCompressor.cpp +@@ -57,6 +57,7 @@ + + + ++#include + #include + #include + #include "tvgCompressor.h" +diff --git a/thirdparty/thorvg/src/common/tvgStr.cpp b/thirdparty/thorvg/src/common/tvgStr.cpp +index 957fe18d53..fe2e13bc71 100644 +--- a/thirdparty/thorvg/src/common/tvgStr.cpp ++++ b/thirdparty/thorvg/src/common/tvgStr.cpp +@@ -22,6 +22,7 @@ + + #include "config.h" + #include ++#include + #include + #include + #include "tvgMath.h" +diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp +index 542cd17e56..45fdc9cf0d 100644 +--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp ++++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp +@@ -20,6 +20,7 @@ + * SOFTWARE. + */ + ++#include + #include + #include "tvgSvgUtil.h" + diff --git a/thirdparty/thorvg/src/common/tvgCompressor.cpp b/thirdparty/thorvg/src/common/tvgCompressor.cpp index 714f21e07c9..d97ae857050 100644 --- a/thirdparty/thorvg/src/common/tvgCompressor.cpp +++ b/thirdparty/thorvg/src/common/tvgCompressor.cpp @@ -57,6 +57,7 @@ +#include #include #include #include "tvgCompressor.h" diff --git a/thirdparty/thorvg/src/common/tvgStr.cpp b/thirdparty/thorvg/src/common/tvgStr.cpp index 957fe18d532..fe2e13bc713 100644 --- a/thirdparty/thorvg/src/common/tvgStr.cpp +++ b/thirdparty/thorvg/src/common/tvgStr.cpp @@ -22,6 +22,7 @@ #include "config.h" #include +#include #include #include #include "tvgMath.h" diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp index 542cd17e563..45fdc9cf0d7 100644 --- a/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp +++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp @@ -20,6 +20,7 @@ * SOFTWARE. */ +#include #include #include "tvgSvgUtil.h"