-
Notifications
You must be signed in to change notification settings - Fork 247
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
[C++] Windows build support #1294
Conversation
Signed-off-by: LiangliangSui <coolsui.coding@gmail.com>
@chaokunyang PTAL, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a job to ci.yml for windows build?
Refer to https://github.com/actions/runner-images, you can use windows-2022
.
@LiangliangSui We can use COPTS = select({
"//:opt": ["-DBAZEL_OPT"],
"//conditions:default": [],
}) + select({
"@bazel_tools//src/conditions:windows": [
# TODO(mehrdadn): (How to) support dynamic linking?
"-DRAY_STATIC",
],
"//conditions:default": [
],
}) + select({
"//:clang-cl": [
"-Wno-builtin-macro-redefined", # To get rid of warnings caused by deterministic build macros (e.g. #define __DATE__ "redacted")
],
"//conditions:default": [
],
}) But it's OK to add it in |
@PragmaTwice Should we merge the pr first or wait until the windows ci is written and merged together? |
Looks fine to me. But BTW, we need to make something like |
Yeah, I will implement it next. |
Thank you for your contribution! |
When compiled using Windows bazel, the following error occurs: ``` cl: 命令行 warning D9002 :忽略未知选项“-pthread” cl: 命令行 warning D9002 :忽略未知选项“-std=c++17” time_util.cc src/fury/util/time_util.cc(43): warning C4477: “snprintf”: 格式字符串“%03ld”需要类型“long”的参数,但可变参数 1 拥有了类型“_Rep” with [ _Rep=__int64 ] src/fury/util/time_util.cc(43): note: 请考虑在格式字符串中使用“%lld” src/fury/util/time_util.cc(43): note: 请考虑在格式字符串中使用“%Id” src/fury/util/time_util.cc(43): note: 请考虑在格式字符串中使用“%I64d” INFO: From Compiling absl/debugging/failure_signal_handler.cc: failure_signal_handler.cc INFO: From Compiling absl/strings/str_replace.cc: str_replace.cc INFO: From Compiling absl/strings/match.cc: match.cc INFO: From Compiling absl/strings/internal/stringify_sink.cc: stringify_sink.cc ERROR: C:/users/sui/desktop/incubator-fury/src/fury/util/BUILD:5:11: Compiling src/fury/util/buffer.cc failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target //src/fury/util:fury_util) C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe @bazel-out/x64_windows-opt/bin/src/fury/util/_objs/fury_util/buffer.obj.params cl: 命令行 warning D9002 :忽略未知选项“-pthread” cl: 命令行 warning D9002 :忽略未知选项“-std=c++17” buffer.cc bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(31): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(50): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(50): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(50): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(50): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(51): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(55): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(55): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(55): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(55): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(56): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(59): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(59): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(61): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(61): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(61): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(61): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(66): error C3533: 参数不能为包 含“auto”的类型 bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(66): note: 非类型模板参数中的“auto”至少需要“/std:c++17” bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(97): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(105): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(108): error C7525: 内联变量至少 需要 "/std:c++17" bazel-out/x64_windows-opt/bin/src/fury/meta/_virtual_includes/fury_meta\fury/meta/type_traits.h(120): error C7525: 内联变量至少 需要 "/std:c++17" Target //src/fury/util:fury_util failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 13.649s, Critical Path: 2.07s INFO: 42 processes: 6 internal, 36 local. ERROR: Build did NOT complete successfully ``` The root cause is that in Windows, specifying C++17 requires the use of `/std:c++17`, while in unix/linux systems, use `-std=c++17`. Since the operating system name cannot be determined in fury.bzl to dynamically set COPTS, so I moved them to .bazelrc. Later, I will solve the warnings generated by compiling in windows, for example `src/fury/util/time_util.cc(43): note: 请考虑在格式字符串中使用“%lld”`. Signed-off-by: LiangliangSui <coolsui.coding@gmail.com> Co-authored-by: Twice <twice@apache.org>
When compiled using Windows bazel, the following error occurs:
The root cause is that in Windows, specifying C++17 requires the use of
/std:c++17
, while in unix/linux systems, use-std=c++17
.Since the operating system name cannot be determined in fury.bzl to dynamically set COPTS, so I moved them to .bazelrc.
Later, I will solve the warnings generated by compiling in windows, for example
src/fury/util/time_util.cc(43): note: 请考虑在格式字符串中使用“%lld”
.