Merge pull request #111767 from Repiteo/scons/libcpp-transitive

SCons: Remove transitive includes in `libc++`
This commit is contained in:
Thaddeus Crews 2025-12-03 21:02:01 -06:00
commit 63e14e13f9
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
17 changed files with 114 additions and 2 deletions

View file

@ -272,6 +272,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))
@ -783,6 +788,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.

View file

@ -51,6 +51,7 @@ static_assert(__cplusplus >= 201703L, "Minimum of C++17 required.");
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <type_traits>
#include <utility>
// IWYU pragma: end_exports

View file

@ -65,6 +65,7 @@
#import <simd/simd.h>
#import <zlib.h>
#import <initializer_list>
#import <memory>
#import <optional>
enum StageResourceUsage : uint32_t {

View file

@ -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
@ -1069,6 +1072,7 @@ Patches:
- `0001-revert-tvglines-bezier-precision.patch` (GH-96658)
- `0002-use-heap-alloc.patch` (GH-109530)
- `0003-explicit-includes.patch` (GH-111557)
## tinyexr

View file

@ -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 <ctype.h>
+#include <exception>
+
#ifdef _MSC_VER
#pragma warning (disable:4127) // warning C4127: conditional expression is constant

View file

@ -2,6 +2,7 @@
// Do not include directly
#include <ctype.h>
#include <exception>
#ifdef _MSC_VER
#pragma warning (disable:4127) // warning C4127: conditional expression is constant

View file

@ -5,6 +5,7 @@
#include "alloc.h"
#include <algorithm>
#include <type_traits>
namespace embree
{

View file

@ -14,6 +14,7 @@
#include "../sys/atomic.h"
#include "../math/range.h"
#include <exception>
#include <list>
namespace embree

View file

@ -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 <algorithm>
+#include <type_traits>
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 <exception>
#include <list>
namespace embree

View file

@ -453,6 +453,7 @@ JPH_SUPPRESS_WARNINGS_STD_BEGIN
#include <functional>
#include <algorithm>
#include <cstdint>
#include <type_traits>
#if defined(JPH_COMPILER_MSVC) || (defined(JPH_COMPILER_CLANG) && defined(_MSC_VER)) // MSVC or clang-cl
#include <malloc.h> // for alloca
#endif

View file

@ -29,6 +29,7 @@
#include <cassert>
#include <chrono>
#include <exception>
#include <system_error>
#include <sdkddkver.h> // Detect Windows version.

View file

@ -37,6 +37,7 @@
#include <chrono>
#include <system_error>
#include <atomic>
#include <exception>
#include <mutex> //need for call_once()
#if STDMUTEX_RECURSION_CHECKS || !defined(NDEBUG)

View file

@ -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 <cassert>
#include <chrono>
+#include <exception>
#include <system_error>
#include <sdkddkver.h> // 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 <chrono>
#include <system_error>
#include <atomic>
+#include <exception>
#include <mutex> //need for call_once()
#if STDMUTEX_RECURSION_CHECKS || !defined(NDEBUG)

View file

@ -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 <cstdlib>
#include <string>
#include <memory.h>
#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 <cmath>
+#include <cstdlib>
#include <cstring>
#include <memory.h>
#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 <cstdlib>
#include <cstring>
#include "tvgSvgUtil.h"

View file

@ -57,6 +57,7 @@
#include <cstdlib>
#include <string>
#include <memory.h>
#include "tvgCompressor.h"

View file

@ -22,6 +22,7 @@
#include "config.h"
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <memory.h>
#include "tvgMath.h"

View file

@ -20,6 +20,7 @@
* SOFTWARE.
*/
#include <cstdlib>
#include <cstring>
#include "tvgSvgUtil.h"