build: enable release builds on Windows#5812
build: enable release builds on Windows#5812htuch merged 6 commits intoenvoyproxy:masterfrom greenhouse-org:windows-release
Conversation
Signed-off-by: Sam Smith <sesmith177@gmail.com>
|
Note: on our fork, we've actually commented out the Since select doesn't work great with dicts (can't be used inside one to select a single value), we've held off on solving this problem (which would probably require wrapping cmake_external with some sort of macro) for now |
bazel/foreign_cc/BUILD
Outdated
| }), | ||
| ) | ||
|
|
||
| cmake_external( |
There was a problem hiding this comment.
Can we create an envoy_cmake_external macro that hides the boiler plate?
There was a problem hiding this comment.
The real boiler plate part is generate_crosstool_file, why this is needed @sesmith177? If it is a general issue probably upstream to rules_foreign_cc?
There was a problem hiding this comment.
According to the README (and our testing), you need to explicitly specify the option to generate the CMake crosstool file for rules_foreign_cc to work on Windows
There was a problem hiding this comment.
The boilerplate to me is both the postfix_script library retrieval of PDB and the crosstool code. Is there a better way to support them in rules_foreign_cc? CC @irengrig.
We also have the ninja configuration as boilerplate. Hence why I reckon it would be useful to make a envoy_cmake_external and hide some of this away, but I agree with @lizan we could push further back into rules_foreign_cc some more standard things.
| + endif() | ||
| endif() | ||
| # AC_TYPE_UINT8_T | ||
| # AC_TYPE_UINT16_T |
There was a problem hiding this comment.
What are the plans to upstream this? As it stands, having this patch will make version bumps hard as we will need to treat the patch manually.
There was a problem hiding this comment.
A previous attempt to fix the ssize_t issue on Windows: nghttp2/nghttp2#616 was reverted, since adding the typedef could break projects that have code that also #define ssize_t on Windows.
For the rest of the patch, there's been no movement on the PR we submitted back in July
There was a problem hiding this comment.
Thanks for the update. It would be great if we can get this Windows support landed upstream, CC @tatsuhiro-t. Do we at least have a roadmap for how to do this?
There was a problem hiding this comment.
How about adding a cmake flag to define ssize_t as int64_t? By default, ssize_t is int for backward compatibility.
Signed-off-by: Sam Smith <sesmith177@gmail.com>
|
@htuch I've added a macro that hides at least some of the boilerplate (and also handles removing CMAKE_BUILD_TYPE on Windows). I think it should be possible to push the PDB selection in there as well, though handling the fact that |
Signed-off-by: Sam Smith <sesmith177@gmail.com>
htuch
left a comment
There was a problem hiding this comment.
Yep, this is a good direction, thanks.
bazel/envoy_build_system.bzl
Outdated
| cache_entries_no_build_type = {} | ||
| for key in cache_entries.keys(): | ||
| if key != "CMAKE_BUILD_TYPE": | ||
| cache_entries_no_build_type[key] = cache_entries[key] |
There was a problem hiding this comment.
Does Starlark not have dictionary comprehensions? Should be 1 line in Python.
bazel/foreign_cc/BUILD
Outdated
| ], | ||
| static_libraries = ["libcares.a"], | ||
| postfix_script = select({ | ||
| "//bazel:windows_dbg_build": "cp $BUILD_TMPDIR/CMakeFiles/c-ares.dir/c-ares.pdb $INSTALLDIR/lib/c-ares.pdb", |
There was a problem hiding this comment.
Yeah, to the extent you can push in most of this that make sense and parameterize by path it'd be good. We can still add a postfix script for additional stuff as needed on each target.
Signed-off-by: Sam Smith <sesmith177@gmail.com>
|
@htuch ready for another look |
bazel/envoy_build_system.bzl
Outdated
| # rules_foreign_cc will figure it out for us | ||
| cache_entries_no_build_type = {} | ||
| for key in cache_entries.keys(): | ||
| if key != "CMAKE_BUILD_TYPE": |
There was a problem hiding this comment.
CMAKE_BUILD_TYPE is calculated by cmake_external internally, from the type of Bazel build.
I added the way how to avoid that: bazel-contrib/rules_foreign_cc#224
Please pass "CMAKE_BUILD_TYPE": "" (empty string) to cmake_external, and then the computed value for CMAKE_BUILD_TYPE will not be used (there would be no "-DCMAKE_BUILD_TYPE=" on the cmake call.)
There was a problem hiding this comment.
On Windows, we want to use the computed value for CMAKE_BUILD_TYPE so we can get the desired release / debug builds
bazel/envoy_build_system.bzl
Outdated
| pf = "" | ||
| if copy_pdb: | ||
| name_to_pdb = {"ares": "c-ares", "nghttp2": "nghttp2_static", "zlib": "zlibstatic"} | ||
| pdb_name = name_to_pdb.get(name, name) |
There was a problem hiding this comment.
I like all of this PR except this bit :) Can we pass in the pdf_name as an arg to envoy_cmake_external, to avoid having target specific logic/defines in the macro?
Signed-off-by: Sam Smith <sesmith177@gmail.com>
| ) | ||
|
|
||
| cmake_external( | ||
| envoy_cmake_external( |
There was a problem hiding this comment.
Hmm, I missed this, why did you need to add this? repositories.bzl doesn't add the :all target to benchmark and it is built with upstream BUILD.bazel file. #5890
There was a problem hiding this comment.
Yeah, @sesmith177 could you followup on this one? Thanks.
There was a problem hiding this comment.
Yeah, that's definitely a mistake -- I hadn't noticed that when 7fa5513 removed the benchmark.sh script, it did not add a corresponding cmake_external rule. So when I merged our branch in to fix the Windows issues, this extra rule came with it.
Sorry for the confusion.
Now that envoyproxy#5218 has been merged, we can enable release builds on Windows. This PR updates `ci/do_ci.ps1` to build release + fastbuild versions in addition to debug versions. It also removes support for build scripts in `ci/build_container/build_recipes/` on Windows, as there is no clean way to pass information from Bazel regarding the type of build to those scripts Risk Level: Low Testing: `bazel build //source/... && bazel test //test/...` Signed-off-by: Sam Smith <sesmith177@gmail.com> Signed-off-by: Fred Douglas <fredlas@google.com>
Description:
Now that #5218 has been merged, we can enable release builds on Windows. This PR updates
ci/do_ci.ps1to build release + fastbuild versions in addition to debug versions. It also removes support for build scripts inci/build_container/build_recipes/on Windows, as there is no clean way to pass information from Bazel regarding the type of build to those scriptsRisk Level:
Low
Testing:
bazel build //source/... && bazel test //test/...Docs Changes:
N/A
Release Notes:
N/A