From f60845f2dda58ac441549aa449ecc3bea5da492d Mon Sep 17 00:00:00 2001 From: John Elliott Date: Wed, 28 Feb 2024 10:39:47 -0800 Subject: [PATCH] Workaround for build errors caused by vcvarsall.bat returning ERRORLEVEL=1 Summary: An update to the Windows toolchain broke OSS getdeps builds. This was caused by the execution of `vcvarsall.bat` returning an ERRORLEVEL=1 when any extension (optional tools) was absent. Given we don't install many extensions this meant that the setup script was failing. The resultant behavior was to fail all build steps. The fix was to wrap the invocation of `vcvarsall.bat` in a different batch file that always returns ERRORLEVEL=0. This should be OK as any real build failures will come by running the actual build scripts. NOTE: There are other known failures (i.e. folly not building due to new compiler) that will be exposed after this change. They will not be causing any new job failures, but should be addressed as well. Reviewed By: chadaustin Differential Revision: D54280190 fbshipit-source-id: 7bf38bb2cb084cf5c4cd5650b5f0f06bb1dbcd9b --- build/fbcode_builder/getdeps/builder.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index 25e2076e99d..4ad75b34685 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -62,7 +62,18 @@ def _get_cmd_prefix(self): # the cmd quoting rules to assemble a command that calls the script # to prep the environment and then triggers the actual command that # we wanted to run. - return [vcvarsall, "amd64", "&&"] + + # Due to changes in vscrsall.bat, it now reports an ERRORLEVEL of 1 + # even when succeeding. This occurs when an extension is not present. + # To continue, we must ignore the ERRORLEVEL returned. We do this by + # wrapping the call in a batch file that always succeeds. + wrapper = os.path.join(self.build_dir, "succeed.bat") + with open(wrapper, "w") as f: + f.write("@echo off\n") + f.write(f"call {vcvarsall} amd64\n") + f.write("set ERRORLEVEL=0\n") + f.write("exit /b 0\n") + return [wrapper, "&&"] return [] def _run_cmd(