Skip to content

Conversation

htuch
Copy link
Member

@htuch htuch commented Sep 24, 2018

This demonstrates the use of the new cmake_external() rule provided by rules_foreign_cc.

There are a number of issues to address and discuss in this PR before merging.

Risk level: Low
Testing: bazel test //test/... on Linux.

Signed-off-by: Harvey Tuch htuch@google.com

This demonstrates the use of the new cmake_external() rule provided by rules_foreign_cc.

There are a number of issues to address and discuss in this PR before merging.

Risk level: Low
Testing: bazel test //test/... on Linux.

Signed-off-by: Harvey Tuch <htuch@google.com>
Copy link
Member Author

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

@irengrig FYI. Thanks so much for driving this effort, it "just worked" for us out of the box.

@@ -4,6 +4,9 @@ load("//bazel:repositories.bzl", "envoy_dependencies")
load("//bazel:cc_configure.bzl", "cc_configure")

envoy_dependencies()
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to figure out how to roll this into envoy_dependencies(), but it depends on some of the setup there. load can't be used inside a macro, only at file level or in WORKSPACE. Might be possibly with a multi-phase envoy_dependencies() setup.

Choose a reason for hiding this comment

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

afaik, unfortunately you can only call the initialization function directly in WORKSPACE file. Should be resolved when recursive workspace paring be implemented.

tools_deps = NINJA_DEP,
)

cmake_external(
Copy link
Member Author

Choose a reason for hiding this comment

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

@sesmith177 any chance you can try out this PR and let me know if it does the right thing on Windows?

Copy link
Member

Choose a reason for hiding this comment

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

we can take a look at it when we get a chance. One thing we noticed is that the names of the static libraries are different on Windows and Linux ( cares.lib and nghttp2.lib vs libcares.a and libnghttp2.a)

Choose a reason for hiding this comment

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

Hi, here's my modified cares build for Windows (I just completed it, will update the examples):

cmake_external(
name = "cares",
cache_entries = {
"CARES_SHARED": "no",
"CARES_STATIC": "on",
},
defines = ["CARES_STATICLIB"],
cmake_options = ["-GNinja"],
lib_source = "@cares//:all",
make_commands = [
"ninja",
"ninja install",
],
)

  1. Since on Wndows cares.lib is created, "static_libraries" can be omitted (cares.lib is the calculated default)
  2. defines = ["CARES_STATICLIB"], is very important, for some reason CMake script does not set this up because of corresponding CMake variable
  3. I used the preinstalled ninja, seems one should not build it on Windows

Hope it helps. Will be happy to answer any questions.

`envoy_dependencies()` function.
2. Add a `cmake_external` rule to [`bazel/foreign_cc/BUILD`](bazel/foreign_cc/BUILD). This will
reference the source repository in step 1.
3. Reference your new external dependency in some `envoy_cc_library` via Y in the
Copy link
Member Author

Choose a reason for hiding this comment

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

Will improve the writeup before we merge here. This is now like the 5th way of handling external deps (obligatory https://xkcd.com/927/).

],
static_libraries = ["libnghttp2.a"],
tools_deps = NINJA_DEP,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

We should add some more of the cmake deps as well once we have agreement on when we will be merging this.

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

Choose a reason for hiding this comment

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

This is the main blocker to use merging this PR; we don't want folks to have to be setting this when importing Envoy to their own projects. CC @irengrig.

Copy link
Member Author

Choose a reason for hiding this comment

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

@irengrig this aged out of our review process, because we haven't figured out these last few steps and weren't able to verify Windows support (@sesmith177). Do you think there is any way to resolve these?

Copy link
Member

Choose a reason for hiding this comment

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

@htuch we have used a version of bazel that has the fix for bazelbuild/bazel#6292 and verified that we can build Envoy with it.

We have not had a chance yet to take another look at this PR

Choose a reason for hiding this comment

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

Hi @htuch, I asked the people from Bazel C++ team, they estimate the work for getting rid of the --experimental_cc_skylark_api_enabled_packages flag as at least two weeks.
The task is their priority, but it takes time.

Nice to hear about Windows build.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @irengrig. Please ping me when this is done and we will try and switch this on in master (hopefully @sesmith177 and MSFT will have time to evaluate by then).

Copy link
Member

Choose a reason for hiding this comment

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

it gets farther on windows with the newer bazel, but still fails to build:

ERROR: C:/vmfiles/envoy/bazel/foreign_cc/BUILD:25:1: no such package '@com_github_nghttp2_nghttp2//': Traceback (most recent call last):
        File "C:/_eb/external/bazel_tools/tools/build_defs/repo/http.bzl", line 55
                patch(ctx)
        File "C:/_eb/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 85, in patch
                fail(("Error applying patch command %...)))
Error applying patch command find . -name '*.sh' -exec sed -i.orig '1s|#!/usr/bin/env sh\$|/bin/sh\$|' {} +:

---------- LTMAIN.SH
Access denied - .
File not found - -NAME
File not found - -EXEC
File not found - SED
File not found - -I.ORIG
File not found - {}
File not found - +
 and referenced by '//bazel/foreign_cc:nghttp2'

we haven't had too much time to debug this

Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
@stale
Copy link

stale bot commented Oct 1, 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 Oct 1, 2018
@sesmith177
Copy link
Member

@htuch as is, it doesn't look like this works on Windows, bazel threw an exception while trying to build (see attached java.log)

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Oct 2, 2018
@irengrig
Copy link

irengrig commented Oct 2, 2018

@htuch as is, it doesn't look like this works on Windows, bazel threw an exception while trying to build (see attached java.log)

Hi, I was able to reproduce it and recorded an issue: bazelbuild/bazel#6292.
The problem is not relevant to the cmake_external...
On Thursday I will ping the guys, tomorrow we are having a public holiday in Germany.

@sesmith177
Copy link
Member

@irengrig thanks for reporting the issue -- we saw the same thing with bazel 0.17.2 and without these cmake_external changes.

As a side note, the master branch of envoyproxy/envoy doesn't currently build on Windows -- we are currently working on this. If you need a branch that does build on Windows, we maintain one here: https://github.com/greenhouse-org/envoy/tree/windows-linux-build

@stale
Copy link

stale bot commented Oct 9, 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 Oct 9, 2018
@stale
Copy link

stale bot commented Oct 16, 2018

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@sesmith177
Copy link
Member

@htuch @irengrig We've taken another look at this and were able to get it working on Windows, so I think we can remove Windows from the blockers here

@htuch
Copy link
Member Author

htuch commented Nov 12, 2018

@sesmith177 appreciated, thanks for the update.

@htuch
Copy link
Member Author

htuch commented Dec 4, 2018

FWIW, I'm resuming this work now, hope to have a PR out in next day @sesmith177 @mattklein123

@@ -62,6 +67,11 @@ REPOSITORY_LOCATIONS = dict(
strip_prefix = "nanopb-f8ac463766281625ad710900479130c7fcb4d63b",
urls = ["https://github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz"],
),
com_github_nghttp2_nghttp2 = dict(
sha256 = "42fff7f290100c02234ac3b0095852e4392e6bfd95ebed900ca8bd630850d88c",
strip_prefix = "nghttp2-1.33.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

@htuch nghttp2 version 1.35.0 is out if you would like to bump to that version. Master is currently set at 1.34.0
SHA256 for 1.35.0 is ea04e4e749df13d60a88b706752e04f6f907227bf380aefd7aeeb4aa0db43407

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, thanks, already bumped the versions.

htuch added a commit to htuch/envoy that referenced this pull request Dec 4, 2018
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 added a commit that referenced this pull request Jan 30, 2019
This revives #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>
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>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants