Skip to content

Commit

Permalink
CI: Add MinGW/GCC build to Windows GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Sep 27, 2024
1 parent 76a1359 commit fabdfde
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,32 @@ 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
target: editor
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
target: template_release
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
Expand All @@ -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:
Expand All @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions drivers/d3d12/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/d3d12/dxil_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions drivers/d3d12/rendering_device_driver_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
24 changes: 18 additions & 6 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
15 changes: 0 additions & 15 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]):
Expand Down

0 comments on commit fabdfde

Please sign in to comment.