Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure compiling Godot for Windows with LLVM MinGW (missing file) #92259

Closed
MBCX opened this issue May 22, 2024 · 14 comments · Fixed by #92325
Closed

Build failure compiling Godot for Windows with LLVM MinGW (missing file) #92259

MBCX opened this issue May 22, 2024 · 14 comments · Fixed by #92325

Comments

@MBCX
Copy link

MBCX commented May 22, 2024

Tested versions

  • Reproducible in master [8e2141e]
  • Not reproducible in Godot 4.3.dev6 [64520fe]

System information

Godot v4.3.beta (2311e0462) - Windows 10.0.22631 - Vulkan (Forward+) - dedicated Radeon RX 580 Series (Advanced Micro Devices, Inc.; 31.0.21912.14) - Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz (6 Threads)

Issue description

When I try to compile Godot for windows using LLVM MinGW, before reaching the Generating ... stages, it silently fails the build.

Building editor for x86_64. Build may take longer.
scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... no
scons: done reading SConscript files.
scons: Building targets ...
Copy("bin/D3D12Core.dll", "/home/mbcx/Documents/d3d12/agilitysdk/build/native/bin/x64/D3D12Core.dll")
Copy("bin/WinPixEventRuntime.dll", "/home/mbcx/Documents/d3d12/pix/bin/x64/WinPixEventRuntime.dll")
Copy("bin/d3d12SDKLayers.dll", "/home/mbcx/Documents/d3d12/agilitysdk/build/native/bin/x64/d3d12SDKLayers.dll")
Copy("bin/dxil.dll", "/home/mbcx/Documents/d3d12/dxc/bin/x64/dxil.dll")
BUILD: Elapsed time [00:00:04]
Compiling platform/windows/console_wrapper_windows.cpp ...
build_res_file(["platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o"], ["platform/windows/godot_res_wrap.rc"])
Generating core/disabled_classes.gen.h ...
scons: *** [platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o] Error -1

I found out that this commit is the culprit. When I run the command manually, this is causing the build to fail.

/home/mbcx/sysroot/llvm-mingw/bin/x86_64-w64-mingw32-windres --include-dir . --target=pe-x86-64 -i platform/windows/godot_res_wrap.rc -o platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o
In file included from platform/windows/godot_res_wrap.rc:1:
./core/version.h:34:10: fatal error: 'core/version_generated.gen.h' file not found
   34 | #include "core/version_generated.gen.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
llvm-rc: Preprocessing failed.

Steps to reproduce

I'm not sure if this is a LLVM MinGW specific bug.

  1. Download the latest LLVM MinGW
  2. Specify it in your MINGW_PREFIX environment variable.
  3. As I build Godot through a script, this is the full command.
scons -j${THREADS_PER_JOB} platform="windows" precision="single" \ # $os $precision
    use_mingw=yes use_llvm=yes linker=mold lto=none module_text_server_fb_enabled=yes \
    arch=x86_64 d3d12=yes agility_sdk_multi_arch=yes use_pix=yes \
    dxc_path=$HOME/Documents/d3d12/dxc \
    mesa_libs=$HOME/Documents/nir/win \
    agility_sdk_path=$HOME/Documents/d3d12/agilitysdk \
    pix_path=$HOME/Documents/d3d12/pix \
    angle_libs=$HOME/sources/godot-angle-static/bin
  1. Wait for failure

Minimal reproduction project (MRP)

N/A

@Repiteo
Copy link
Contributor

Repiteo commented May 22, 2024

Given this is failing on godot_res_wrap, it's possible that this would be fixed via #91847. But the error mentioning not finding core/version_generated.gen.h is particularly strange; that should be one of the first files auto-generated in all circumstances. If that aforementioned PR doesn't fix things for you, I'll have to dig into why that file failed to generate.

@MBCX
Copy link
Author

MBCX commented May 22, 2024

I will try that PR and let you know @Repiteo

@MBCX
Copy link
Author

MBCX commented May 22, 2024

Nope, even that PR did not fix the issue. When I try to build that branch, this is the error that gives me:

Building editor for x86_64. Build will take longer.
scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-43/SConstruct", line 1029:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 676:
    return method(*args, **kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-43/platform/windows/SCsub", line 51:
    res_obj = env.RES(res_target, res_file)

By the way, I use SCons 4.7.0 running on PyPy 3.10, if that's useful.

SCons by Steven Knight et al.:
	SCons: v4.7.0.265be6883fadbb5a545612265acc919595158366, Sun, 17 Mar 2024 17:33:54 -0700, by bdbaddog on M1Dog2021
	SCons path: ['/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons']
Copyright (c) 2001 - 2024 The SCons Foundation

@fire
Copy link
Member

fire commented May 23, 2024

I suspect that a clean clone or git clean will resolve this issue since I tested mingw-llvm yesterday.

@MBCX
Copy link
Author

MBCX commented May 24, 2024

Nope @fire, that did not fix the issue 😔.

These are all the steps that I took, in the specified order.
First

  1. git clone https://github.com/godotengine/godot godot-test
  2. cd godot-test
  3. export MINGW_PREFIX=<llvm-mingw-location>
  4. scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes"

This results in, from before:

scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... no
scons: done reading SConscript files.
scons: Building targets ...
[Initial build] Compiling platform/windows/console_wrapper_windows.cpp ...
[Initial build] build_res_file(["platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o"], ["platform/windows/godot_res_wrap.rc"])
[Initial build] Generating core/disabled_classes.gen.h ...
scons: *** [platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o] Error -1
scons: building terminated because of errors.
[Time elapsed: 00:00:06.16]

Then I integrated @Repiteo's pull request #91847

  1. git clean -fixd
  2. git fetch origin pull/91847/head:mingw-fix
  3. git checkout mingw-fix
  4. scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes"

Results in

scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-test/SConstruct", line 1029:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 676:
    return method(*args, **kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-test/platform/windows/SCsub", line 51:
    res_obj = env.RES(res_target, res_file)

Then I merged the pull request with the master branch:

  1. git clean -fixd
  2. git checkout master
  3. git merge mingw-fix
  4. Fix merge conflicts then git merge --continue
  5. scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes"

Again results in

scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-test/SConstruct", line 1029:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 676:
    return method(*args, **kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-test/platform/windows/SCsub", line 51:
    res_obj = env.RES(res_target, res_file)

@fire
Copy link
Member

fire commented May 24, 2024

That's not good. I'll try to look into it if there's some spare time.

@akien-mga
Copy link
Member

Given this is failing on godot_res_wrap, it's possible that this would be fixed via #91847. But the error mentioning not finding core/version_generated.gen.h is particularly strange; that should be one of the first files auto-generated in all circumstances. If that aforementioned PR doesn't fix things for you, I'll have to dig into why that file failed to generate.

#91624 deferred the generation of core/version_generated.gen.h, which used to happen in SConstruct sequentially, and now is being registered as a command in core/SCsub. Assuming the command is still executed right away, core/SCsub comes before platform/windows/SCsub so it should be fine. But Windows is notoriously slow at getting and releasing file handles, maybe the PR worsened a possible race condition which is now being hit? Possibly specifically with PyPi, more than the use of LLVM per se, which shouldn't have an impact here?

Can we register the RES build to Depend on core/version_generated.gen.h maybe?

@Repiteo
Copy link
Contributor

Repiteo commented May 24, 2024

AttributeError: 'SConsEnvironment' object has no attribute 'RES'

This… Shouldn't be possible. I have no idea why, but your SCons seems to simply not register the RES builder outright; that's a global default builder, one that should always be availble, so something is very awry internally. Even after downloading pypy 3.10 & the provided LLVM MinGW, I cannot replicate this behavior on my PR nor master.

The only discrepancy I can think of atm is that you aren't passing a mingw_prefix variable in your examples. Even if it's an environment variable, could you try passing mingw_prefix explicitly to see if that makes a difference?

@MBCX
Copy link
Author

MBCX commented May 24, 2024

@Repiteo Still nothing :/

scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes" mingw_prefix="$HOME/sysroot/llvm-mingw"
scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-test/SConstruct", line 1039:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 676:
    return method(*args, **kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 612:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/mbcx/pypy3.10/lib/pypy3.10/site-packages/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-test/platform/windows/SCsub", line 52:
    res_obj = env.RES(res_target, res_file)

You know, I will try unsetting $HOME/pypy3.10/bin on my $PATH and see if that makes a difference

@MBCX
Copy link
Author

MBCX commented May 24, 2024

Yup. Even after unsetting $HOME/pypy3.10/bin from my $PATH and using the SCons from Debian 13 package manager and from the (dated) Pyston it sill gives me the same errors:

SCons from Package Manager

AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-test/SConstruct", line 1039:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 662:
    return method(*args, **kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/usr/lib/python3/dist-packages/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-test/platform/windows/SCsub", line 52:
    res_obj = env.RES(res_target, res_file)

From Pyston 2.3.5

AttributeError: 'SConsEnvironment' object has no attribute 'RES':
  File "/home/mbcx/sources/godot-test/SConstruct", line 1039:
    SConscript("platform/" + env["platform"] + "/SCsub")  # Build selected platform.
  File "/home/mbcx/pyston_2.3.5/lib/python3.8-pyston2.3/site-packages/SCons/Script/SConscript.py", line 673:
    return method(*args, **kw)
  File "/home/mbcx/pyston_2.3.5/lib/python3.8-pyston2.3/site-packages/SCons/Script/SConscript.py", line 609:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/mbcx/pyston_2.3.5/lib/python3.8-pyston2.3/site-packages/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/mbcx/sources/godot-test/platform/windows/SCsub", line 52:
    res_obj = env.RES(res_target, res_file)

@MBCX
Copy link
Author

MBCX commented May 24, 2024

Going back a commit before the merger of the pull request, still gives the errors of core/version_generated.gen.h that cause the build to fail.

Pyston 2.3.5

$ export PATH="$HOME/pyston_2.3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
$ which scons
$ /home/mbcx/pyston_2.3.5/bin/scons
scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes" mingw_prefix="$HOME/sysroot/llvm-mingw"
scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
[Initial build] build_res_file(["platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o"], ["platform/windows/godot_res_wrap.rc"])
[Initial build] Generating core/object/gdvirtual.gen.inc ...
[Initial build] Generating core/version_generated.gen.h ...
[Initial build] scons: *** [platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o] Error -1
Generating servers/rendering/renderer_rd/shaders/blit.glsl.gen.h ...
scons: building terminated because of errors.
[Time elapsed: 00:00:01.58]

SCons from Package Manager

$ export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
$ which scons
$ /usr/bin/scons
scons -j4 platform="windows" target="editor" use_mingw="yes" use_llvm="yes" mingw_prefix="$HOME/sysroot/llvm-mingw"
scons: Reading SConscript files ...
Using MinGW, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... no
scons: done reading SConscript files.
scons: Building targets ...
[Initial build] Compiling platform/windows/console_wrapper_windows.cpp ...
[Initial build] build_res_file(["platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o"], ["platform/windows/godot_res_wrap.rc"])
[Initial build] Generating core/disabled_classes.gen.h ...
[Initial build] scons: *** [platform/windows/godot_res_wrap.windows.editor.x86_64.llvm.o] Error -1
Generating modules/modules_enabled.gen.h ...
scons: building terminated because of errors.
[Time elapsed: 00:00:02.11]

@Repiteo
Copy link
Contributor

Repiteo commented May 24, 2024

Is "a commit before the merger of the pull request" referring to the commit prior to 6fcdd24?

@MBCX
Copy link
Author

MBCX commented May 24, 2024

Yes, I meant the commit before I merge your pull request

f3dca43ff2 (HEAD -> master) Merge branch 'mingw-fix'
b7feebefab (this one) (origin/master, origin/HEAD) Merge pull request #92288 from smix8/navregion_debug

@Repiteo
Copy link
Contributor

Repiteo commented May 24, 2024

This is beyond the scope of that PR then; made a separate one that explicitly assigns a dependancy for core/version_generated.gen.h as @akien-mga suggested: #92325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants