Closed peakschris closed 1 month ago
Hej, thanks for opening the issue.
No, Swift isn't a prerequisite to building with Bazel. I would say it's mainly for macOS and Linux.
Unfortunately, my knowledge with Bazel is none-existing to solve this actually.
This can be fixed with these two changes:
build_grpc_with_cxx14.patch:
diff --git a/bazel/copts.bzl b/bazel/copts.bzl
index 10be944f25..879518b92f 100644
--- a/bazel/copts.bzl
+++ b/bazel/copts.bzl
@@ -59,4 +59,7 @@ GRPC_LLVM_WARNING_FLAGS = [
GRPC_DEFAULT_COPTS = select({
"//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
"//conditions:default": [],
-})
+}) + select({
+ "@bazel_tools//src/conditions:windows": ["/std:c++14"],
+ "//conditions:default": ["-std=c++14"],
+})
.bazelrc:
# As of bazel 6.3.0, common supports all options
common --deleted_packages=tests/bazel_repository_test_dir,tests/ts/bazel_repository_test_dir
# Workaround https://github.com/bazelbuild/bazel/issues/21712 until bazel 7.2.0 is out
common --experimental_worker_for_repo_fetching=off
# Point tools such as coursier (used in rules_jvm_external) to Bazel's internal JDK
# suggested in https://github.com/bazelbuild/rules_jvm_external/issues/445
common --repo_env=JAVA_HOME=../bazel_tools/jdk
common --action_env=JAVA_HOME=../bazel_tools/jdk
# Workaround "Error: need --enable_runfiles on Windows for to support rules_js"
common:windows --enable_runfiles
# Swift is not required on Windows
common:windows --deleted_packages=swift
The windows build command is then: bazel build //... --config=windows
Would you be able to upstream this?
Well, not anytime this week, but I can look at it on Monday. Would that be fine?
cc: @dbaileychess
Amazing! Thanks :-)
I'm also looking at whether we can add the bazel extensions to the conan package, so people using bazel can consume flatbuffers from conan. I'll followup on that one separately if successful.
@peakschris I wonder what would this code below fix:
diff --git a/bazel/copts.bzl b/bazel/copts.bzl
index 10be944f25..879518b92f 100644
--- a/bazel/copts.bzl
+++ b/bazel/copts.bzl
@@ -59,4 +59,7 @@ GRPC_LLVM_WARNING_FLAGS = [
GRPC_DEFAULT_COPTS = select({
"//:use_strict_warning": GRPC_LLVM_WARNING_FLAGS + ["-DUSE_STRICT_WARNING=1"],
"//conditions:default": [],
-})
+}) + select({
+ "@bazel_tools//src/conditions:windows": ["/std:c++14"],
+ "//conditions:default": ["-std=c++14"],
+})
Since I know we are having an issue building with Xcode 15.0 as well with gRPC that was fixed by limiting Xcode to 14.2 which isn't optimal commit. CI issue https://buildkite.com/bazel/flatbuffers/builds/9316#018e2ff5-e5ca-46e5-afc1-74d96b161517
All I've changed in that patch file is to use /std:c++14
on windows, whilst the default option used is -std=c++14
.
Original patch file:
+}) + ["-std=c++14"]
Modified patch file:
+}) + select({
+ "@bazel_tools//src/conditions:windows": ["/std:c++14"],
+ "//conditions:default": ["-std=c++14"],
+})
It looks like a different issue to the Xcode one.
I'm not sure if it's supposed to work, but the bazel build of latest on windows is broken:
We have a requirement to compile the flatbuffers library with msvc, so switching to clang is a non-starter for us. Is swift a real prerequisite for C++?