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

TensorStore does not compile with latest Visual Studio #110

Closed
dzenanz opened this issue Aug 30, 2023 · 19 comments
Closed

TensorStore does not compile with latest Visual Studio #110

dzenanz opened this issue Aug 30, 2023 · 19 comments

Comments

@dzenanz
Copy link

dzenanz commented Aug 30, 2023

Using CMake 3.25.3 and Python 3.9.13, I run into hundreds of errors in Debug mode on VS 2022 (v17.7.3). This is with current tip of master (e371f6e). Build log is attached:
Output-Build.txt
This did not happen with 2868eab - build was successful.

@tbirdso
Copy link

tbirdso commented Aug 30, 2023

Hi @dzenanz , just weighing in out of interest, I am a bit confused because it looks like the first error is here:

916>/bin/bash: C:/Misc/tensorstore-vs22/bin/Debug/Protobuf_protoc.exe: No such file or directory

But VS22 seems to have built that executable earlier:

892>Protobuf_protoc.vcxproj -> C:\Misc\tensorstore-vs22\bin\Debug\Protobuf_protoc.exe

Could you confirm whether that file exists on your local machine? Does the error still throw when you try to build again?

@dzenanz
Copy link
Author

dzenanz commented Aug 30, 2023

It also fails to build in RelWithDebInfo mode:

1221>------ Skipped Build: Project: ALL_BUILD, Configuration: RelWithDebInfo x64 ------
1221>Project not selected to build for this solution configuration 
========== Build: 1042 succeeded, 173 failed, 0 up-to-date, 6 skipped ==========

@tbirdso Protobuf_protoc.exe exist in that path, and an incremental build is not successful either.

@dzenanz
Copy link
Author

dzenanz commented Aug 30, 2023

Incremental build built 15 more projects: Build: 15 succeeded, 173 failed, 1027 up-to-date, 6 skipped

@dzenanz
Copy link
Author

dzenanz commented Aug 30, 2023

Second incremental build had the same result. But as the number of failed projects remains at 173, it means that repeated builds do no compile anything new.

@laramiel
Copy link
Collaborator

First error snippet:

893>upb_upbc_protoc-gen-upb_stage0.vcxproj -> C:\Misc\tensorstore-vs22\bin\Debug\upb_upbc_protoc-gen-upb_stage0.exe
916>------ Build started: Project: genrule__upb_upbc_gen_plugin_upb_proto_stage1, Configuration: Debug x64 ------
917>------ Build started: Project: genrule__upb_gen_descriptor_upb_proto_stage1, Configuration: Debug x64 ------
916>Generating upbc/stage1/google/protobuf/compiler/plugin.upb.h, upbc/stage1/google/protobuf/compiler/plugin.upb.c
917>Generating upb/reflection/stage1/google/protobuf/descriptor.upb.h, upb/reflection/stage1/google/protobuf/descriptor.upb.c
916>/bin/bash: C:/Misc/tensorstore-vs22/bin/Debug/Protobuf_protoc.exe: No such file or directory
917>/bin/bash: C:/Misc/tensorstore-vs22/bin/Debug/Protobuf_protoc.exe: No such file or directory
916>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(249,5): error MSB8066: Custom build for 'C:\Misc\tensorstore-vs22\CMakeFiles\e6afb379168cf807d732f1d4cca98ee2\plugin.upb.h.rule;C:\Misc\tensorstore-vs22\CMakeFiles\f3312a6eaeeebee8f12b9640a0c43927\genrule__upb_upbc_gen_plugin_upb_proto_stage1.rule;C:\Misc\tensorstore-vs22\_deps\upb-src\CMakeLists.txt' exited with code 127.
916>Done building project "genrule__upb_upbc_gen_plugin_upb_proto_stage1.vcxproj" -- FAILED.
917>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(249,5): error MSB8066: Custom build for 'C:\Misc\tensorstore-vs22\CMakeFiles\18b5926fa1336130d811e53a248142b0\descriptor.upb.h.rule;C:\Misc\tensorstore-vs22\CMakeFiles\f3312a6eaeeebee8f12b9640a0c43927\genrule__upb_gen_descriptor_upb_proto_stage1.rule;C:\Misc\tensorstore-vs22\_deps\upb-src\CMakeLists.txt' exited with code 127.
917>Done building project "genrule__upb_gen_descriptor_upb_proto_stage1.vcxproj" -- FAILED.
918>------ Build started: Project: upb_descriptor_upb_proto_stage1, Configuration: Debug x64 ------
918>Building Custom Rule C:/Misc/tensorstore-vs22/_deps/upb-src/CMakeLists.txt
912>tensorstore_kvstore_grpc_common_proto__cpp_library.vcxproj -> C:\Misc\tensorstore-vs22\Debug\tensorstore_kvstore_grpc_common_proto__cpp_library.lib
907>Googleapis_google_api_annotations_proto__cpp_library.vcxproj -> C:\Misc\tensorstore-vs22\_deps\googleapis-build\Debug\Googleapis_google_api_annotations_proto__cpp_library.lib
919>------ Build started: Project: tensorstore_kvstore_grpc_kvstore_proto__cpp_library, Configuration: Debug x64 ------
891>objective_c_generator.cc
920>------ Build started: Project: Googleapis_google_iam_v1_policy_proto__cpp_library, Configuration: Debug x64 ------
921>------ Build started: Project: Googleapis_google_iam_v1_options_proto__cpp_library, Configuration: Debug x64 ------
918>descriptor.upb.c
918>c1 : fatal  error C1083: Cannot open source file: 'C:\Misc\tensorstore-vs22\_deps\upb-build\upb\reflection\stage1\google\protobuf\descriptor.upb.c': No such file or directory
918>Done building project "upb_descriptor_upb_proto_stage1.vcxproj" -- FAILED.
922>------ Build started: Project: upb_upbc_plugin_upb_proto_stage1, Configuration: Debug x64 ------
923>------ Build started: Project: upb_reflection_internal_stage1, Configuration: Debug x64 ------
919>Running cpp protocol buffer compiler on C:/Misc/tensorstore/tensorstore/kvstore/grpc/kvstore.proto, protoc-options: --experimental_allow_proto3_optional
923>Building Custom Rule C:/Misc/tensorstore-vs22/_deps/upb-src/CMakeLists.txt
921>Running cpp protocol buffer compiler on C:/Misc/tensorstore-vs22/_deps/googleapis-src/google/iam/v1/options.proto, protoc-options: --experimental_allow_proto3_optional
922>Building Custom Rule C:/Misc/tensorstore-vs22/_deps/upb-src/CMakeLists.txt
920>Running cpp protocol buffer compiler on C:/Misc/tensorstore-vs22/_deps/googleapis-src/google/iam/v1/policy.proto, protoc-options: --experimental_allow_proto3_optional
921>Building Custom Rule C:/Misc/tensorstore-vs22/_deps/googleapis-src/CMakeLists.txt
922>plugin.upb.c
922>c1 : fatal  error C1083: Cannot open source file: 'C:\Misc\tensorstore-vs22\_deps\upb-build\upbc\stage1\google\protobuf\compiler\plugin.upb.c': No such file or directory
922>Done building project "upb_upbc_plugin_upb_proto_stage1.vcxproj" -- FAILED.
923>def_builder.c
923>C:\Misc\tensorstore-vs22\_deps\upb-src\upb/reflection/common.h(44,10): fatal  error C1083: Cannot open include file: 'google/protobuf/descriptor.upb.h': No such file or directory
923>def_pool.c
923>C:\Misc\tensorstore-vs22\_deps\upb-src\upb/reflection/common.h(44,10): fatal  error C1083: Cannot open include file: 'google/protobuf/descriptor.upb.h': No such file or directory

What CMake generator are you using? We test with ninja, so maybe try that.

@dzenanz
Copy link
Author

dzenanz commented Aug 30, 2023

I am using Visual Studio 17 2022 generator. Ninja is friendly for automated builds, but I need to develop, so I am using VS generator. The bug in question is sporadic failure, which I think stems from a destructor not being always called: InsightSoftwareConsortium/ITKIOOMEZarrNGFF#36 (comment)

Is there some way to call that destructor from here: https://github.com/InsightSoftwareConsortium/ITKIOOMEZarrNGFF/blob/v0.1.7/src/itkOMEZarrNGFFImageIO.cxx#L811

@laramiel
Copy link
Collaborator

Yeah, I'm just wondering if it builds there as an independent data point.

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

That also fails:

C:\Misc\tensorstore-ninja22>ninja
[62/5038] Building CXX object CMakeFiles\tensorstore_data_type.dir\tensorstore\data_type.cc.obj
C:\Misc\tensorstore\tensorstore\data_type.cc(296): warning C4002: too many arguments for function-like macro invocation 'TENSORSTORE_INTERNAL_CONVERT_INT'
C:\Misc\tensorstore\tensorstore\data_type.cc(297): warning C4002: too many arguments for function-like macro invocation 'TENSORSTORE_INTERNAL_CONVERT_FLOAT'
[274/5038] Building CXX object CMakeFiles\tensorstore_data_type_test.dir\tensorstore\data_type_test.cc.obj
C:\Misc\tensorstore\tensorstore\data_type_test.cc(55): warning C4002: too many arguments for function-like macro invocation 'X'
C:\Misc\tensorstore\tensorstore\data_type_test.cc(85): warning C4002: too many arguments for function-like macro invocation 'X'
[566/5038] Building CXX object CMakeFiles\tensorstore_util_span_test.dir\tensorstore\util\span_test.cc.obj
C:\Misc\tensorstore\tensorstore\util\span.h(388) : warning C4715: 'tensorstore::span<int,3>::at': not all control paths return a value
C:\Misc\tensorstore\tensorstore\util\span.h(388) : warning C4715: 'tensorstore::span<int,-1>::at': not all control paths return a value
[606/5038] Building CXX object _deps\protobuf-build\CMakeF...\src\google\protobuf\generated_message_tctable_lite.cc.obj
C:\Misc\tensorstore-ninja22\_deps\protobuf-src\src\google\protobuf\generated_message_tctable_lite.cc(1441): warning C4141: 'inline': used more than once
C:\Misc\tensorstore-ninja22\_deps\protobuf-src\src\google\protobuf\generated_message_tctable_lite.cc(1458): warning C4141: 'inline': used more than once
C:\Misc\tensorstore-ninja22\_deps\protobuf-src\src\google\protobuf\generated_message_tctable_lite.cc(2448): warning C4141: 'inline': used more than once
[629/5038] Building CXX object _deps\protobuf-build\CMakeF..._protobuf_nowkt.dir\src\google\protobuf\text_format.cc.obj
C:\Misc\tensorstore-ninja22\_deps\protobuf-src\src\google\protobuf\text_format.cc(905): warning C4805: '==': unsafe mix of type 'bool' and type 'uint64_t' in operation
[980/5038] Building C object _deps\upb-build\CMakeFiles\upb_mem_internal.dir\upb\mem\arena.c.obj
C:\Misc\tensorstore-ninja22\_deps\upb-src\upb\mem\arena.c(186): warning C4116: unnamed type definition in parentheses
[987/5038] Building C object _deps\upb-build\CMakeFiles\upb_mini_table_internal.dir\upb\mini_table\decode.c.obj
C:\Misc\tensorstore-ninja22\_deps\upb-src\upb\mini_table\decode.c(359): warning C4116: unnamed type definition in parentheses
[1658/5038] Generating upb/reflection/stage1/google/protob....h, upb/reflection/stage1/google/protobuf/descriptor.upb.c
FAILED: _deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.h _deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.c C:/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.h C:/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.c
cmd.exe /C "cd /D C:\Misc\tensorstore-ninja22\_deps\upb-src && bash -c "C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe --plugin=protoc-gen-upb=C:/Misc/tensorstore-ninja22/bin/upb_upbc_protoc-gen-upb_stage0.exe -IC:/Misc/tensorstore-ninja22/_deps/upb-src/bootstrap --upb_out=C:\/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1 google/protobuf/descriptor.proto""
/bin/bash: C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe: No such file or directory
[1659/5038] Generating upbc/stage1/google/protobuf/compile...n.upb.h, upbc/stage1/google/protobuf/compiler/plugin.upb.c
FAILED: _deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.h _deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.c C:/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.h C:/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.c
cmd.exe /C "cd /D C:\Misc\tensorstore-ninja22\_deps\upb-src && bash -c "C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe --plugin=protoc-gen-upb=C:/Misc/tensorstore-ninja22/bin/upb_upbc_protoc-gen-upb_stage0.exe -IC:/Misc/tensorstore-ninja22/_deps/upb-src/bootstrap --upb_out=C:\/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1 google/protobuf/compiler/plugin.proto""
/bin/bash: C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe: No such file or directory
[1683/5038] Building ASM_NASM object _deps\aom-build\CMake...\aom_dsp_x86_asm.dir\aom_dsp\x86\highbd_sad4d_sse2.asm.obj
ninja: build stopped: subcommand failed.

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

A few reruns later:

C:\Misc\tensorstore-ninja22>ninja -k 99
[1/1413] Generating upb/reflection/stage1/google/protobuf/....h, upb/reflection/stage1/google/protobuf/descriptor.upb.c
FAILED: _deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.h _deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.c C:/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.h C:/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1/google/protobuf/descriptor.upb.c
cmd.exe /C "cd /D C:\Misc\tensorstore-ninja22\_deps\upb-src && bash -c "C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe --plugin=protoc-gen-upb=C:/Misc/tensorstore-ninja22/bin/upb_upbc_protoc-gen-upb_stage0.exe -IC:/Misc/tensorstore-ninja22/_deps/upb-src/bootstrap --upb_out=C:\/Misc/tensorstore-ninja22/_deps/upb-build/upb/reflection/stage1 google/protobuf/descriptor.proto""
/bin/bash: C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe: No such file or directory
[2/1413] Generating upbc/stage1/google/protobuf/compiler/plugin.upb.h, upbc/stage1/google/protobuf/compiler/plugin.upb.c
FAILED: _deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.h _deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.c C:/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.h C:/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1/google/protobuf/compiler/plugin.upb.c
cmd.exe /C "cd /D C:\Misc\tensorstore-ninja22\_deps\upb-src && bash -c "C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe --plugin=protoc-gen-upb=C:/Misc/tensorstore-ninja22/bin/upb_upbc_protoc-gen-upb_stage0.exe -IC:/Misc/tensorstore-ninja22/_deps/upb-src/bootstrap --upb_out=C:\/Misc/tensorstore-ninja22/_deps/upb-build/upbc/stage1 google/protobuf/compiler/plugin.proto""
/bin/bash: C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe: No such file or directory
ninja: build stopped: cannot make progress due to previous errors.

C:\Misc\tensorstore-ninja22>C:/Misc/tensorstore-ninja22/bin/Protobuf_protoc.exe --version
libprotoc 23.2

C:\Misc\tensorstore-ninja22>

It seems that bash is hardcoded as the command interpreter, and it does not interpret Windows-style path properly.

@tbirdso
Copy link

tbirdso commented Aug 31, 2023

As additional data point here, I am able to reproduce @dzenanz 's results with MSVC on Windows 11 when building from tensorstore@master in Release mode:

...
17>------ Build started: Project: genrule__upb_gen_descriptor_upb_proto_stage1, Configuration: Release x64 ------
17>Generating upb/reflection/stage1/google/protobuf/descriptor.upb.h, upb/reflection/stage1/google/protobuf/descriptor.upb.c
17>'bash' is not recognized as an internal or external command,
17>operable program or batch file.
17>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'D:\repos\ITKNGFF-tst\CMakeFiles\f2d05fd07f5c5d81252321f7bf5e710a\descriptor.upb.h.rule;D:\repos\ITKNGFF-tst\CMakeFiles\6df025c99a88b38c49b7e5d3fe69be96\genrule__upb_gen_descriptor_upb_proto_stage1.rule' exited with code 9009.
17>Done building project "genrule__upb_gen_descriptor_upb_proto_stage1.vcxproj" -- FAILED.
...

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

There are also 173 projects failing to build with Visual Studio 2019 (16.11.29).

@jbms
Copy link
Collaborator

jbms commented Aug 31, 2023

Thanks for your additional tests. It is helpful to know that it fails also with ninja because that means we don't need to worry about debugging with the visual studio generator in particular.

I suspect the issue may be related to the specific build of bash that you have in your path. Can you tell us what that is? We test with bash from git for windows.

@tbirdso I think you are actually getting a separate error --- that bash is not found.

I believe previously the build did not require bash on Windows but it is not required due to the changes in the protobuf build. We might be able to change the protobuf build to not require bash, which would simplify things on Windows.

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

C:\Users\Dzenan>bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

C:\Users\Dzenan>where bash
C:\Windows\System32\bash.exe

C:\Users\Dzenan>git-bash --version
'git-bash' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Dzenan>"C:\Program Files\Git\bin\bash.exe" --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

I don't remember installing a system-wide bash, so I don't know where C:\Windows\System32\bash.exe came from.

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

These are details of C:\Windows\System32\bash.exe:
Screenshot 2023-08-31 11 18 03

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

I have Windows 11 22H2 (OS Build 22621.2215).

@jbms
Copy link
Collaborator

jbms commented Aug 31, 2023

I think the version of bash in your path is a launcher for bash running in Windows subsystem for Linux 2 (WSL2). As that is a separate virtual machine it isn't going to work.

Can you try building with git bash (often at C:\Program Files\Git\bin\bash.exe) in your path?

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

With git's bash in the path before WSL's, ninja configuration builds.

@tbirdso
Copy link

tbirdso commented Aug 31, 2023

I can confirm adding "C:\Program Files\Git\bin" to env:PATH also resolves build failures with MSVC. Thank you @laramiel @jbms !

@dzenanz Let's plan to note bash as a build prerequisite for ITKIOOMEZarrNGFF when updating the tensorstore hash.

@dzenanz
Copy link
Author

dzenanz commented Aug 31, 2023

OK, but git's bash should be added to tensorstore's build requirements too, unless that dependence is alleviated. Which might be possible, as it was introduced recently-ish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants