Index: Modules/Compiler/GNU.cmake
--- Modules/Compiler/GNU.cmake.orig	2025-04-10 16:58:22.000000000 +0200
+++ Modules/Compiler/GNU.cmake	2025-04-10 21:47:01.585027000 +0200
@@ -57,8 +57,8 @@
   # Initial configuration flags.
   string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
   string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
-  string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
-  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
+  string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2")
+  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2")
   string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
   if(NOT "x${lang}" STREQUAL "xFortran")
     string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
Index: Source/cmGlobalNinjaGenerator.cxx
--- Source/cmGlobalNinjaGenerator.cxx.orig	2025-04-10 21:47:01.585471000 +0200
+++ Source/cmGlobalNinjaGenerator.cxx	2025-04-10 21:49:07.807808000 +0200
@@ -2,6 +2,11 @@
    file LICENSE.rst or https://cmake.org/licensing for details.  */
 #include "cmGlobalNinjaGenerator.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include <algorithm>
 #include <cassert>
 #include <cctype>
Index: Source/kwsys/Encoding.h.in
--- Source/kwsys/Encoding.h.in.orig	2025-04-10 16:58:22.000000000 +0200
+++ Source/kwsys/Encoding.h.in	2025-04-10 21:47:01.585677000 +0200
@@ -5,6 +5,7 @@
 
 #include <@KWSYS_NAMESPACE@/Configure.h>
 
+#include <stdlib.h>
 #include <wchar.h>
 
 /* Redefine all public interface symbol names to be in the proper
