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

MSVC builds are broken #64904

Closed
SaracenOne opened this issue Aug 25, 2022 · 13 comments · Fixed by #64921
Closed

MSVC builds are broken #64904

SaracenOne opened this issue Aug 25, 2022 · 13 comments · Fixed by #64921

Comments

@SaracenOne
Copy link
Member

SaracenOne commented Aug 25, 2022

Godot version

f03ac21

System information

Windows 10, Vulkan, Intel® Core™ i7-8700K, Nvidia GTX 1080 (471.11)

Issue description

Bisected issue to this #55778. Seems to consistently break with the error 'Arch argument should not be used when using VCINSTALLDIR' when compiling with the Visual Studio toolchain regardless whether the arch argument is absent or any other are seemingly used. Seems to compile fine though if this block of code is outright removed:

    print(env["arch"])
    if env["arch"] != "auto":
        print(
            """
            Arch argument is not supported for MSVC manual configuration (VCINSTALLDIR configured).
            Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons.
            As a consequence, the arch argument is disabled. Run scons again without arch argument (example: scons p=windows)
            and SCons will attempt to detect what MSVC compiler will be executed and inform you.
            """
        )
        raise SCons.Errors.UserError("Arch argument should not be used when using VCINSTALLDIR")```

Steps to reproduce

Simply attempt to run SCons with the MSVC toolchain. This is the command I'm using
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 && scons platform=windows

Minimal reproduction project

N/A

@akien-mga
Copy link
Member

I believe @bruvzg is working on cleaning this up.

@aaronfranke
Copy link
Member

We should probably have it either allow auto or the same value as the MSVC manual configuration's arch, and only error if the arch mismatches what the MSVC configuration is providing.

@bruvzg
Copy link
Member

bruvzg commented Aug 25, 2022

I guess custom version of detect_arch() to detect environment and set default arch value (for both MSVC and MinGW, with a test runs of compiler and windres in case of MinGW), and check for mismatching arch when using vcvarsall.

@akien-mga
Copy link
Member

BTW, this part is not urgent, but the whole Windows detect.py seems really convoluted and outdated. It could use a thorough cleanup.

@SaracenOne
Copy link
Member Author

Yeah, there are messages to that effect. I know I pointed this whole regression out earlier, but it felt right to properly log this issue as soon as possible so it can be tracked

@RandomShaper
Copy link
Member

Same here. But it seems it just works if I don't call any of the vcvars*.bat before invoking SCons.

Aside, @SaracenOne, x86_amd64 in your command line has drawn my attention. That's meant for cross-compiling to x64 from a 32-bit host, isn't it? I just call vcvars64.bat, which boils down to vcvarsall.bat" x64 for native x64 compilation.

@Zylann
Copy link
Contributor

Zylann commented Aug 26, 2022

I don't call vcvars*.bat but still get this error when running scons from a VS 2019 command prompt

D:\PROJETS\INFO\GODOT\Engine\godot4_fork>scons p=windows target=debug -j4
scons: Reading SConscript files ...

            Arch argument is not supported for MSVC manual configuration (VCINSTALLDIR configured).
            Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons.
            As a consequence, the arch argument is disabled. Run scons again without arch argument (example: scons p=windows)
            and SCons will attempt to detect what MSVC compiler will be executed and inform you.

NameError: name 'SCons' is not defined:
  File "D:\PROJETS\INFO\GODOT\Engine\godot4_fork\SConstruct", line 509:
    detect.configure(env)
  File "./platform/windows\detect.py", line 497:
    setup_msvc_manual(env)
  File "./platform/windows\detect.py", line 121:
    raise SCons.Errors.UserError("Arch argument should not be used when using VCINSTALLDIR")

@RandomShaper
Copy link
Member

Do you have the VCINSTALLDIR env variable set?

@bruvzg
Copy link
Member

bruvzg commented Aug 26, 2022

Here's an almost finished fix (MSVC part should work, but need some extra work on MinGW detection and cleanup) - #64921

@Zylann
Copy link
Contributor

Zylann commented Aug 26, 2022

@RandomShaper I don't see it in system or user variables. I don't know if the VS 2019 command line is adding more. I never had to deal with this before.
Edit: running the set command shows VCINSTALLDIR is defined in that command prompt.

@RandomShaper
Copy link
Member

@Zylann, then I guess you can just unset it from Widows advanced settings to have your builds working again even while this issue exists. (Well, or alternatively unset it manually —SET VCINSTALLDIR=— on every ocassion.)

@Zylann
Copy link
Contributor

Zylann commented Aug 27, 2022

Also for some reason my CI builds fine with MSVC https://github.com/Zylann/godot_voxel/actions/runs/2937174477 (without the PR)

@derammo
Copy link
Contributor

derammo commented Aug 27, 2022

This may be obvious, but unsetting VCINSTALLDIR is not an option for people with multiple installed compilers. We really should be testing with the officially supported way of doing Visual Studio command line builds (which is via the platform/arch specific command prompts or equivalent scripts) and not just with the default command prompt. https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170

Thanks for already developing a fix bruvzg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment