From fabdfde93331b67d8280d7e681e7a47a23af814c Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Mon, 23 Sep 2024 09:13:51 -0500 Subject: [PATCH] CI: Add MinGW/GCC build to Windows GHA --- .github/workflows/windows_builds.yml | 27 ++++++++++++++----- drivers/d3d12/SCsub | 6 +++++ drivers/d3d12/dxil_hash.cpp | 2 +- .../d3d12/rendering_device_driver_d3d12.cpp | 9 +++++-- methods.py | 24 ++++++++++++----- platform/windows/detect.py | 15 ----------- 6 files changed, 53 insertions(+), 30 deletions(-) diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 95e3d4a553d1..384284b6047e 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -30,7 +30,7 @@ jobs: # Skip debug symbols, they're way too big with MSVC. sconsflags: debug_symbols=no vsproj=yes vsproj_gen_only=no windows_subsystem=console bin: ./bin/godot.windows.editor.x86_64.exe - artifact: true + compiler: msvc - name: Editor w/ clang-cl (target=editor, tests=yes, use_llvm=yes) cache-name: windows-editor-clang @@ -38,6 +38,7 @@ jobs: tests: true sconsflags: debug_symbols=no windows_subsystem=console use_llvm=yes bin: ./bin/godot.windows.editor.x86_64.llvm.exe + compiler: clang - name: Template (target=template_release, tests=yes) cache-name: windows-template @@ -45,7 +46,16 @@ jobs: tests: true sconsflags: debug_symbols=no bin: ./bin/godot.windows.template_release.x86_64.console.exe - artifact: true + compiler: msvc + + - name: Template w/ GCC (target=template_release, tests=yes, use_mingw=yes) + cache-name: windows-template-gcc + # MinGW takes MUCH longer to compile; save time by only targeting Template. + target: template_release + tests: true + sconsflags: debug_symbols=no use_mingw=yes + bin: ./bin/godot.windows.template_release.x86_64.console.exe + compiler: gcc steps: - name: Checkout @@ -69,16 +79,21 @@ jobs: uses: dsaltares/fetch-gh-release-asset@1.1.2 with: repo: godotengine/godot-angle-static - version: tags/chromium/6029 - file: Windows.6029-1.MSVC_17.x86_64.x86_32.zip + version: tags/chromium/6601.2 + file: godot-angle-static-x86_64-${{ matrix.compiler == 'gcc' && 'gcc' || 'msvc' }}-release.zip target: angle/angle.zip - name: Extract pre-built ANGLE static libraries run: Expand-Archive -Force angle/angle.zip ${{ github.workspace }}/ - name: Setup MSVC problem matcher + if: matrix.compiler == 'msvc' uses: ammaraskar/msvc-problem-matcher@master + - name: Setup GCC problem matcher + if: matrix.compiler != 'msvc' + uses: ammaraskar/gcc-problem-matcher@master + - name: Compilation uses: ./.github/actions/godot-build with: @@ -94,12 +109,12 @@ jobs: continue-on-error: true - name: Prepare artifact - if: ${{ matrix.artifact }} + if: matrix.compiler == 'msvc' run: | Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force - name: Upload artifact - if: ${{ matrix.artifact }} + if: matrix.compiler == 'msvc' uses: ./.github/actions/upload-artifact with: name: ${{ matrix.cache-name }} diff --git a/drivers/d3d12/SCsub b/drivers/d3d12/SCsub index b6ceed23ac83..beeb13398e37 100644 --- a/drivers/d3d12/SCsub +++ b/drivers/d3d12/SCsub @@ -4,6 +4,8 @@ from misc.utility.scons_hints import * import os from pathlib import Path +import methods + Import("env") env_d3d12_rdd = env.Clone() @@ -139,6 +141,10 @@ else: extra_defines += [ "HAVE_STRUCT_TIMESPEC", ] + if methods.using_gcc(env) and methods.get_compiler_version(env)["major"] < 13: + # `region` & `endregion` not recognized as valid pragmas. + env_d3d12_rdd.Append(CCFLAGS=["-Wno-unknown-pragmas"]) + env.Append(CCFLAGS=["-Wno-unknown-pragmas"]) # This is needed since rendering_device_d3d12.cpp needs to include some Mesa internals. env_d3d12_rdd.Prepend(CPPPATH=mesa_private_inc_paths) diff --git a/drivers/d3d12/dxil_hash.cpp b/drivers/d3d12/dxil_hash.cpp index f94a4a30df3c..e08492c9ea9f 100644 --- a/drivers/d3d12/dxil_hash.cpp +++ b/drivers/d3d12/dxil_hash.cpp @@ -96,7 +96,7 @@ void compute_dxil_hash(const BYTE *pData, UINT byteCount, BYTE *pOutHash) { UINT NextEndState = bTwoRowsPadding ? N - 2 : N - 1; const BYTE *pCurrData = pData; for (UINT i = 0; i < N; i++, offset += 64, pCurrData += 64) { - UINT x[16]; + UINT x[16] = {}; const UINT *pX; if (i == NextEndState) { if (!bTwoRowsPadding && i == N - 1) { diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index 52883de45e67..9db4fa09a4a1 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -1415,7 +1415,14 @@ RDD::TextureID RenderingDeviceDriverD3D12::texture_create(const TextureFormat &p } tex_info->states_ptr = &tex_info->owner_info.states; tex_info->format = p_format.format; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif tex_info->desc = *(CD3DX12_RESOURCE_DESC *)&resource_desc; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif tex_info->base_layer = 0; tex_info->layers = resource_desc.ArraySize(); tex_info->base_mip = 0; @@ -6645,8 +6652,6 @@ static Error create_command_signature(ID3D12Device *device, D3D12_INDIRECT_ARGUM Error RenderingDeviceDriverD3D12::_initialize_frames(uint32_t p_frame_count) { Error err; - D3D12MA::ALLOCATION_DESC allocation_desc = {}; - allocation_desc.HeapType = D3D12_HEAP_TYPE_DEFAULT; //CD3DX12_RESOURCE_DESC resource_desc = CD3DX12_RESOURCE_DESC::Buffer(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); uint32_t resource_descriptors_per_frame = GLOBAL_GET("rendering/rendering_device/d3d12/max_resource_descriptors_per_frame"); diff --git a/methods.py b/methods.py index 3f11d39bd0dc..a1e038f796f2 100644 --- a/methods.py +++ b/methods.py @@ -467,6 +467,16 @@ def use_windows_spawn_fix(self, platform=None): if os.name != "nt": return # not needed, only for windows + # On Windows, due to the limited command line length, when creating a static library + # from a very high number of objects SCons will invoke "ar" once per object file; + # that makes object files with same names to be overwritten so the last wins and + # the library loses symbols defined by overwritten objects. + # By enabling quick append instead of the default mode (replacing), libraries will + # got built correctly regardless the invocation strategy. + # Furthermore, since SCons will rebuild the library from scratch when an object file + # changes, no multiple versions of the same object file will be present. + self.Replace(ARFLAGS="cq") + def mySubProcess(cmdline, env): startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW @@ -490,17 +500,19 @@ def mySubProcess(cmdline, env): return rv def mySpawn(sh, escape, cmd, args, env): - # Used by TEMPFILE. - if cmd == "del": - os.remove(args[1]) - return 0 - newargs = " ".join(args[1:]) cmdline = cmd + " " + newargs rv = 0 env = {str(key): str(value) for key, value in iter(env.items())} - rv = mySubProcess(cmdline, env) + if len(cmdline) > 32000 and cmd.endswith("ar"): + cmdline = cmd + " " + args[1] + " " + args[2] + " " + for i in range(3, len(args)): + rv = mySubProcess(cmdline + args[i], env) + if rv: + break + else: + rv = mySubProcess(cmdline, env) return rv diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 4043f3a8c282..df913f65ee59 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -703,26 +703,11 @@ def get_is_ar_thin_supported(env): WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)") -def tempfile_arg_esc_func(arg): - from SCons.Subst import quote_spaces - - arg = quote_spaces(arg) - # GCC requires double Windows slashes, let's use UNIX separator - return WINPATHSEP_RE.sub(r"/\1", arg) - - def configure_mingw(env: "SConsEnvironment"): # Workaround for MinGW. See: # https://www.scons.org/wiki/LongCmdLinesOnWin32 env.use_windows_spawn_fix() - # In case the command line to AR is too long, use a response file. - env["ARCOM_ORIG"] = env["ARCOM"] - env["ARCOM"] = "${TEMPFILE('$ARCOM_ORIG', '$ARCOMSTR')}" - env["TEMPFILESUFFIX"] = ".rsp" - if os.name == "nt": - env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func - ## Build type if not env["use_llvm"] and not try_cmd("gcc --version", env["mingw_prefix"], env["arch"]):