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

SCons: Fix compilation database generation with MSVC #65440

Merged
merged 1 commit into from
Sep 7, 2022

Conversation

akien-mga
Copy link
Member

Fixes #54434.

Co-authored-by: @dmoody256

Didn't get to test it myself, would be great if a few MSVC users could confirm it works (to enable compilation database generation, you should pass compiledb=yes to SCons).

@akien-mga akien-mga added bug platform:windows topic:buildsystem cherrypick:3.x Considered for cherry-picking into a future 3.x release cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Sep 6, 2022
@akien-mga akien-mga added this to the 4.0 milestone Sep 6, 2022
@akien-mga akien-mga requested review from a team as code owners September 6, 2022 21:00
@akien-mga
Copy link
Member Author

The platform/windows/detect.py seems to break MSVC detection on CI it seems, it falls back partially to MinGW (but keeping MSVC parameters) and fails:

scons: Building targets ...
run(["core\object\gdvirtual.gen.inc"], ["core\object\make_virtuals.py"])
Executing builder function in subprocess: module_path='D:\\a\\godot\\godot\\core\\object\\make_virtuals.py', parameter_file='C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\7f6697c8b1d243b8b26da514830bd521.json', parameter_file_size=17774, target=['D:\\a\\godot\\godot\\core\\object\\gdvirtual.gen.inc'], source=['D:\\a\\godot\\godot\\core\\object\\make_virtuals.py']
build_rd_headers(["servers\rendering\renderer_rd\shaders\blit.glsl.gen.h"], ["servers\rendering\renderer_rd\shaders\blit.glsl"])
Executing builder function in subprocess: module_path='D:\\a\\godot\\godot\\glsl_builders.py', parameter_file='C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\302887ed57094ab2979a18b070002895.json', parameter_file_size=17834, target=['D:\\a\\godot\\godot\\servers\\rendering\\renderer_rd\\shaders\\blit.glsl.gen.h'], source=['D:\\a\\godot\\godot\\servers\\rendering\\renderer_rd\\shaders\\blit.glsl']
x86_64-w64-mingw32-g++ /Foplatform\windows\godot_windows.windows.opt.tools.x86_64.obj /c platform\windows\godot_windows.cpp -std=gnu++17 /TP -Wno-error=cpp /nologo -O2 -O2 -mwindows -Wall -Wshadow-local -Wno-misleading-indentation -Werror /DDEBUG_ENABLED /DNO_EDITOR_SPLASH /DWINDOWS_ENABLED /DWASAPI_ENABLED /DWINMIDI_ENABLED /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DVULKAN_ENABLED /DGLES3_ENABLED /DMINGW_ENABLED /DMINGW_HAS_SECURE_API=1 /DTOOLS_ENABLED /DMINIZIP_ENABLED /DZSTD_STATIC_LINKING_ONLY /DUSE_VOLK /DVK_USE_PLATFORM_WIN32_KHR /DGLAD_ENABLED /DGLES_OVER_GL /Ithirdparty\freetype\include /Ithirdparty\libpng /Ithirdparty\glad /Ithirdparty\volk /Ithirdparty\vulkan /Ithirdparty\vulkan\include /Ithirdparty\zstd /Ithirdparty\zlib /Iplatform\windows /I.
x86_64-w64-mingw32-g++ /Foplatform\windows\crash_handler_windows.windows.opt.tools.x86_64.obj /c platform\windows\crash_handler_windows.cpp -std=gnu++17 /TP -Wno-error=cpp /nologo -O2 -O2 -mwindows -Wall -Wshadow-local -Wno-misleading-indentation -Werror /DDEBUG_ENABLED /DNO_EDITOR_SPLASH /DWINDOWS_ENABLED /DWASAPI_ENABLED /DWINMIDI_ENABLED /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DVULKAN_ENABLED /DGLES3_ENABLED /DMINGW_ENABLED /DMINGW_HAS_SECURE_API=1 /DTOOLS_ENABLED /DMINIZIP_ENABLED /DZSTD_STATIC_LINKING_ONLY /DUSE_VOLK /DVK_USE_PLATFORM_WIN32_KHR /DGLAD_ENABLED /DGLES_OVER_GL /Ithirdparty\freetype\include /Ithirdparty\libpng /Ithirdparty\glad /Ithirdparty\volk /Ithirdparty\vulkan /Ithirdparty\vulkan\include /Ithirdparty\zstd /Ithirdparty\zlib /Iplatform\windows /I.
=====
platform\windows\godot_windows.cpp:31:10: fatal error: main/main.h: No such file or directory
   31 | #include "main/main.h"
      |          ^~~~~~~~~~~~~
scons: *** [platform\windows\godot_windows.windows.opt.tools.x86_64.obj] Error 1
compilation terminated.

=====
=====
platform\windows\crash_handler_windows.cpp:33:10: fatal error: core/config/project_settings.h: No such file or directory
   33 | #include "core/config/project_settings.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
scons: *** [platform\windows\crash_handler_windows.windows.opt.tools.x86_64.obj] Error 1

=====
scons: building terminated because of errors.

@akien-mga akien-mga marked this pull request as draft September 6, 2022 21:10
@dmoody256
Copy link
Contributor

dmoody256 commented Sep 6, 2022

The platform/windows/detect.py change may have been specific to the issue I was having when my visual studio was installed incorrectly. At first I did not supply that argument, but still always mingw was selected. I started supplying the msvc_version=14.2 to force it, which it then still was selecting mingw. So when I made that change to detect.py then it forced msvc selection and I saw my msvc install was corrupt and then I fixed the msvc install.

That change in platform/windows/detect.py should be reverted. SCons will set the MSVC_VERSION internally if your MSVC install is valid (My case it wasn't so it wasn't setting MSVC_VERSION internally). Although if msvc_version is set but MSVC_VERSION is not set, may be useful to raise an error. In this case the user explicitly wants MSVC but it is not a possible configuration, so diverting them to mingw is confusing.

@derammo
Copy link
Contributor

derammo commented Sep 7, 2022

I used the patch of this PR against master, using SCons: v4.3.0.559790274f66fa55251f5754de34820a29c7327a and it was successful in creating the compile_commands.json. I was running in x64 Native Tools Command Prompt for VS 2019 so the detect logic was using the easy path (everything already set up correctly.)

It is still not useful for my work, because I need the full build info (link commands etc.) but it does seem to fix the compile_commands.json :). Blatant plug for please reconsidering #63724

Fixes godotengine#54434.

Co-authored-by: Daniel Moody <daniel.moody@mongodb.com>
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test it right now, but moving it after toolchain setup seems like a right way to go.

@akien-mga akien-mga marked this pull request as ready for review September 7, 2022 07:10
@akien-mga akien-mga merged commit 9436149 into godotengine:master Sep 7, 2022
@akien-mga akien-mga deleted the scons-compiledb-msvc branch September 7, 2022 07:22
@akien-mga
Copy link
Member Author

Cherry-picked for 3.6.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Sep 9, 2022
@akien-mga
Copy link
Member Author

Cherry-picked for 3.5.1.

@akien-mga akien-mga removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building with scons > 4.0 results in an empty compile_commands.json
4 participants