Ver código fonte

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

SCons: Remove transitive includes in `libc++`
Thaddeus Crews 1 semana atrás
pai
commit
63e14e13f9

+ 12 - 0
SConstruct

@@ -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("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("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(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("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))
 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":
     if sys.platform == "win32":
         env.AppendUnique(CCFLAGS=["-fansi-escape-codes"])
         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.
 # Set optimize and debug_symbols flags.
 # "custom" means do nothing and let users set their own optimization flags.
 # "custom" means do nothing and let users set their own optimization flags.
 # Needs to happen after configure to have `env.msvc` defined.
 # Needs to happen after configure to have `env.msvc` defined.

+ 1 - 0
core/typedefs.h

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

+ 1 - 0
drivers/metal/metal_objects.h

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

+ 4 - 0
thirdparty/README.md

@@ -90,6 +90,7 @@ Patches:
 - `0003-remove-tinydds-qoi.patch` (GH-97582)
 - `0003-remove-tinydds-qoi.patch` (GH-97582)
 - `0004-clang-warning-exclude.patch` (GH-111346)
 - `0004-clang-warning-exclude.patch` (GH-111346)
 - `0005-unused-typedef.patch` (GH-111445)
 - `0005-unused-typedef.patch` (GH-111445)
+- `0006-explicit-includes.patch` (GH-111557)
 
 
 
 
 ## brotli
 ## brotli
@@ -220,6 +221,7 @@ Patches:
 - `0003-emscripten-nthreads.patch` (GH-69799)
 - `0003-emscripten-nthreads.patch` (GH-69799)
 - `0004-mingw-no-cpuidex.patch` (GH-92488)
 - `0004-mingw-no-cpuidex.patch` (GH-92488)
 - `0005-mingw-llvm-arm64.patch` (GH-93364)
 - `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
 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.
 relevant files from the latest Embree release and apply patches automatically.
@@ -707,6 +709,7 @@ Patches:
 
 
 - `0001-disable-exceptions.patch` (GH-85039)
 - `0001-disable-exceptions.patch` (GH-85039)
 - `0002-clang-std-replacements-leak.patch` (GH-85208)
 - `0002-clang-std-replacements-leak.patch` (GH-85208)
+- `0003-explicit-includes.patch` (GH-111557)
 
 
 
 
 ## minimp3
 ## minimp3
@@ -1069,6 +1072,7 @@ Patches:
 
 
 - `0001-revert-tvglines-bezier-precision.patch` (GH-96658)
 - `0001-revert-tvglines-bezier-precision.patch` (GH-96658)
 - `0002-use-heap-alloc.patch` (GH-109530)
 - `0002-use-heap-alloc.patch` (GH-109530)
+- `0003-explicit-includes.patch` (GH-111557)
 
 
 
 
 ## tinyexr
 ## tinyexr

+ 3 - 2
thirdparty/basis_universal/patches/0005-msvc-include-ctype.patch → 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
 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
 --- a/thirdparty/basis_universal/transcoder/basisu_containers_impl.h
 +++ b/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
  // basisu_containers_impl.h
  // Do not include directly
  // Do not include directly
  
  
 +#include <ctype.h>
 +#include <ctype.h>
++#include <exception>
 +
 +
  #ifdef _MSC_VER
  #ifdef _MSC_VER
  #pragma warning (disable:4127) // warning C4127: conditional expression is constant
  #pragma warning (disable:4127) // warning C4127: conditional expression is constant

+ 1 - 0
thirdparty/basis_universal/transcoder/basisu_containers_impl.h

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

+ 1 - 0
thirdparty/embree/common/sys/vector.h

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

+ 1 - 0
thirdparty/embree/common/tasking/taskschedulerinternal.h

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

+ 24 - 0
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 <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

+ 1 - 0
thirdparty/jolt_physics/Jolt/Core/Core.h

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

+ 1 - 0
thirdparty/mingw-std-threads/mingw.condition_variable.h

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

+ 1 - 0
thirdparty/mingw-std-threads/mingw.mutex.h

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

+ 24 - 0
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 <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)

+ 36 - 0
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 <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"
+ 

+ 1 - 0
thirdparty/thorvg/src/common/tvgCompressor.cpp

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

+ 1 - 0
thirdparty/thorvg/src/common/tvgStr.cpp

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

+ 1 - 0
thirdparty/thorvg/src/loaders/svg/tvgSvgUtil.cpp

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