Skip to content

Conversation

htuch
Copy link
Member

@htuch htuch commented Dec 4, 2018

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

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

htuch commented Dec 4, 2018

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.

CC @dprotaso @moderation @irengrig

Copy link
Member

@sesmith177 sesmith177 left a 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
Copy link
Member

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

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

Copy link
Member Author

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.

http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-master",
# TODO(htuch): Pin to SHA or release.
Copy link
Member

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

Choose a reason for hiding this comment

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

Copy link
Member Author

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.

Copy link
Member

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

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

Copy link
Member Author

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto.

@stale
Copy link

stale bot commented Dec 12, 2018

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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 12, 2018
@htuch htuch removed the stale stalebot believes this issue/PR has not been touched recently label Dec 18, 2018
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch
Copy link
Member Author

htuch commented Dec 18, 2018

@sesmith177 @mattklein123 PTAL. I think we should ship with the required additional CLI args. This will break anyone not using the repo's bazel.rc, but we can do a mail to envoy-dev warning folks. The advantages are we can move towards Windows support, unblock the mobile client work for next year and also effectively retire most uses of build recipes.

mattklein123
mattklein123 previously approved these changes Dec 18, 2018
Copy link
Member

@mattklein123 mattklein123 left a 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?

@htuch
Copy link
Member Author

htuch commented Dec 18, 2018

@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?

@sesmith177
Copy link
Member

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

@mattklein123
Copy link
Member

Sure, waiting till January is fine with me.

@@ -17,6 +17,18 @@ build process.
`external_deps` attribute.
3. `bazel test //test/...`

# Adding external dependencies to Envoy (external cmake)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: s/cmake/CMake/

@@ -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.
Copy link
Contributor

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 = {
Copy link
Contributor

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

Copy link
Member Author

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 = {
Copy link
Contributor

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",
Copy link
Contributor

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

@PiotrSikora
Copy link
Contributor

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

@htuch
Copy link
Member Author

htuch commented Dec 21, 2018

@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?

@stale
Copy link

stale bot commented Dec 29, 2018

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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Dec 29, 2018
@mattklein123 mattklein123 added the no stalebot Disables stalebot from closing an issue label Jan 3, 2019
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jan 3, 2019
Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch removed the no stalebot Disables stalebot from closing an issue label Jan 29, 2019
@htuch
Copy link
Member Author

htuch commented Jan 30, 2019

All tests are passing; @mattklein123 @PiotrSikora @sesmith177 are we good to go with this?

@sesmith177
Copy link
Member

Looks good on our end -- we'll submit a follow up PR to fix up the Windows bits

@moderation
Copy link
Contributor

Looks great. Will make dependency maintenance easier.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice!

@htuch htuch merged commit 7fa5513 into envoyproxy:master Jan 30, 2019
@htuch htuch deleted the external-cmake-now branch January 30, 2019 22:12
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Jan 31, 2019
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>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Jan 31, 2019
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>
lizan added a commit that referenced this pull request Feb 1, 2019
*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>
htuch pushed a commit that referenced this pull request Feb 8, 2019
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>
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
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>
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
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>
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
*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>
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