-
Notifications
You must be signed in to change notification settings - Fork 5.1k
build: external_cmake for cmake deps. #5218
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
Conversation
This revives envoyproxy#4516, replacing all external cmake deps with the pending bazel foreign_cc support. To make use of this, with the current release Bazel version, it's necessary to set --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs on the CLI or in .bazelrc. Risk Level: Low Testing: bazel test //test/... Signed-off-by: Harvey Tuch <htuch@google.com>
This PR requires changes to .bazelrc still for the experimental flags. Question; should we provide a fallback to the deprecated build recipes if missing? The downside of this is it might involve Bazel hackery and would have two sources of truth for the build in the interim. |
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.
For the Windows builds, I don't think we need to provide a fallback to the build scripts, given that getting those to work with both release builds + debug builds was both tricky to get right and never made it upstream. And since you can't build Envoy on Windows without a forked version of Bazel (due to bazelbuild/bazel#5163), I don't think we have to worry about breaking people in this case
tools/bazel.rc
Outdated
@@ -1,6 +1,7 @@ | |||
# Envoy specific Bazel build/test options. | |||
|
|||
build --workspace_status_command=bazel/get_workspace_status | |||
build --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs |
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.
I think we might need to add "@foreign_cc_impl" to this list; see https://github.com/bazelbuild/rules_foreign_cc/blob/master/README.md#rules_foreign_cc
COMPILE_FLAGS "${WARNCFLAGS}" | ||
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION} | ||
ARCHIVE_OUTPUT_NAME nghttp2 | ||
+ ARCHIVE_OUTPUT_DIRECTORY static |
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.
This diff isn't going to work -- it builds the static nghttp2.lib in a different directory from the dynamic nghttp2.lib, but when ninja install
is run, it installs both on top of each other.
To get this to work we updated our patch: https://github.com/greenhouse-org/envoy/blob/66776969519e993ea022bb385947897208704abe/bazel/foreign_cc/nghttp2.patch and associated PR: nghttp2/nghttp2#1198
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.
Ack. I'm going to go ahead with the PR as-is and we can update this when the nghttp2 patch merges.
bazel/repositories.bzl
Outdated
http_archive( | ||
name = "rules_foreign_cc", | ||
strip_prefix = "rules_foreign_cc-master", | ||
# TODO(htuch): Pin to SHA or release. |
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.
I assume we want to do this before we merge?
make_commands = [ | ||
NINJA_COMMAND, | ||
NINJA_COMMAND + " install", | ||
], |
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.
We need to copy pdb files on Windows debug builds; see: https://github.com/greenhouse-org/envoy/blob/66776969519e993ea022bb385947897208704abe/bazel/foreign_cc/BUILD#L55-L58
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.
Ack. Let's merge as-is and you can do a small diff PR for this. I can't verify these steps, so will let you folks take this on.
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.
Not a problem -- we can submit a followup PR that cleans up the Windows bits
NINJA_COMMAND, | ||
NINJA_COMMAND + " install", | ||
], | ||
static_libraries = ["libcares.a"], |
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.
The output static library files are going to be different on Windows and Linux
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.
Ditto.
"CARES_SHARED": "no", | ||
"CARES_STATIC": "on", | ||
}, | ||
cmake_options = ["-GNinja"], |
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.
We need to set generate_crosstool_file = true
on Windows
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.
Ditto.
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
@sesmith177 @mattklein123 PTAL. I think we should ship with the required additional CLI args. This will break anyone not using the repo's |
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.
Nice, let's do it. Agreed on just sending out an email to envoy-dev about the CLI required args.
As an aside, do you know the status of having native Bazel in gperftools? Seems like Google should provide that at some point?
@mattklein123 gperftools is being tracked at gperftools/gperftools#800. Doesn't look like much recent progress. I will ping the thread. I just synced with Bazel team, who say that we will be able to use external_cmake without CLI flags in 0.22, which will happen mid-late Jan. @sesmith177 @mattklein123 thoughts on whether we just wait until then rather than going back-and-forth with the dev community on this? |
Since Envoy having "real" support for Windows is blocked on bazelbuild/bazel#5163, we're OK with waiting until January. This specific PR isn't going to block us, since we have these changes on our fork anyways |
Sure, waiting till January is fine with me. |
bazel/EXTERNAL_DEPS.md
Outdated
@@ -17,6 +17,18 @@ build process. | |||
`external_deps` attribute. | |||
3. `bazel test //test/...` | |||
|
|||
# Adding external dependencies to Envoy (external cmake) |
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.
Nit: s/cmake/CMake/
bazel/EXTERNAL_DEPS.md
Outdated
@@ -17,6 +17,18 @@ build process. | |||
`external_deps` attribute. | |||
3. `bazel test //test/...` | |||
|
|||
# Adding external dependencies to Envoy (external cmake) | |||
|
|||
This is the preferred style of adding dependencies that use cmake for their build system. |
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.
Nit: s/cmake/CMake/
|
||
cmake_external( | ||
name = "ares", | ||
cache_entries = { |
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.
Add "CMAKE_BUILD_TYPE": "RelWithDebInfo"
(possibly "Debug"
for Windows builds?)
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.
Done, but I'm going to skip the Windows parts and let @sesmith177 take this.
|
||
cmake_external( | ||
name = "nghttp2", | ||
cache_entries = { |
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.
Add "CMAKE_BUILD_TYPE": "RelWithDebInfo"
(possibly "Debug"
for Windows builds?)
cmake_external( | ||
name = "yaml", | ||
cache_entries = { | ||
"YAML_CPP_BUILD_TESTS": "off", |
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.
Add "CMAKE_BUILD_TYPE": "RelWithDebInfo"
(possibly "Debug"
for Windows builds?)
This needs to be rebased to pull BoringSSL FIPS (which, even though is built using CMake, should continue to be build that way using the provided script and not |
@PiotrSikora for BoringSSL FIPS, I think if we're going to keep it script based in the long term, it should be moved to https://github.com/envoyproxy/envoy/blob/master/bazel/EXTERNAL_DEPS.md#adding-external-dependencies-to-envoy-genrule-repository style of external repo. We want to completely retire build recipes and the repository rules. Will you do the migration or should we file an issue? |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Harvey Tuch <htuch@google.com>
All tests are passing; @mattklein123 @PiotrSikora @sesmith177 are we good to go with this? |
Looks good on our end -- we'll submit a follow up PR to fix up the Windows bits |
Looks great. Will make dependency maintenance easier. |
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.
Nice!
I think this was the intended code, I noticed a failure in compile_time_options for envoyproxy#5218. Risk Level: Low Testing: bazel build --config=libc++ //source/exe:envoy-static Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: htuch <htuch@users.noreply.github.com>
This revives envoyproxy#4516, replacing all external cmake deps with the pending bazel foreign_cc support. Risk Level: Low Testing: bazel test //test/... Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: htuch <htuch@users.noreply.github.com>
*Description*: YAML tools build with bazel cmake from #5218 (it pulls our cc_configure and I think that is the reason) requires newer version of GLIBCXX that CentOS doesn't have. It also speed up build so lets just turn off building them. *Risk Level*: Low *Testing*: CI *Docs Changes*: *Release Notes*: Signed-off-by: Lizan Zhou <lizan@tetrate.io>
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/...` Signed-off-by: Sam Smith <sesmith177@gmail.com>
I think this was the intended code, I noticed a failure in compile_time_options for envoyproxy#5218. Risk Level: Low Testing: bazel build --config=libc++ //source/exe:envoy-static Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
This revives envoyproxy#4516, replacing all external cmake deps with the pending bazel foreign_cc support. Risk Level: Low Testing: bazel test //test/... Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
*Description*: YAML tools build with bazel cmake from envoyproxy#5218 (it pulls our cc_configure and I think that is the reason) requires newer version of GLIBCXX that CentOS doesn't have. It also speed up build so lets just turn off building them. *Risk Level*: Low *Testing*: CI *Docs Changes*: *Release Notes*: Signed-off-by: Lizan Zhou <lizan@tetrate.io> Signed-off-by: Fred Douglas <fredlas@google.com>
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>
This revives #4516, replacing all external cmake deps with the pending bazel foreign_cc support.
To make use of this, with the current release Bazel version, it's necessary to set
--experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs
on the CLI or in .bazelrc.
Risk Level: Low
Testing: bazel test //test/...
Signed-off-by: Harvey Tuch htuch@google.com