Skip to content

build: enable release builds on Windows#5812

Merged
htuch merged 6 commits intoenvoyproxy:masterfrom
greenhouse-org:windows-release
Feb 8, 2019
Merged

build: enable release builds on Windows#5812
htuch merged 6 commits intoenvoyproxy:masterfrom
greenhouse-org:windows-release

Conversation

@sesmith177
Copy link
Copy Markdown
Member

Description:

Now that #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/...

Docs Changes:
N/A
Release Notes:
N/A

Signed-off-by: Sam Smith <sesmith177@gmail.com>
@sesmith177
Copy link
Copy Markdown
Member Author

Note: on our fork, we've actually commented out the CMAKE_BUILD_TYPE cache_entries in bazel/foreign_cc -- it looks like Bazel / rules_foreign_cc are correctly passing the right arguments through on Windows. Similarly, if we don't comment out those lines, they would have to switch between "Debug" and "'Release" depending on the build type.

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

@lizan lizan self-assigned this Feb 2, 2019
}),
)

cmake_external(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create an envoy_cmake_external macro that hides the boiler plate?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Signed-off-by: Sam Smith <sesmith177@gmail.com>
@sesmith177
Copy link
Copy Markdown
Member Author

@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 benchmark has its own postfix_script might be a little tricky

Signed-off-by: Sam Smith <sesmith177@gmail.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is a good direction, thanks.

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]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Starlark not have dictionary comprehensions? Should be 1 line in Python.

],
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",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@sesmith177
Copy link
Copy Markdown
Member Author

@htuch ready for another look

# 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":
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, we want to use the computed value for CMAKE_BUILD_TYPE so we can get the desired release / debug builds

pf = ""
if copy_pdb:
name_to_pdb = {"ares": "c-ares", "nghttp2": "nghttp2_static", "zlib": "zlibstatic"}
pdb_name = name_to_pdb.get(name, name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, done

@htuch htuch added the waiting label Feb 8, 2019
Signed-off-by: Sam Smith <sesmith177@gmail.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rad, thanks!

@htuch htuch merged commit 8d89d77 into envoyproxy:master Feb 8, 2019
)

cmake_external(
envoy_cmake_external(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, @sesmith177 could you followup on this one? Thanks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
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>
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

Successfully merging this pull request may close these issues.

5 participants