Skip to content
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

contrib: Shift vpp build -> rules_foreign_cc #27243

Merged
merged 2 commits into from
May 8, 2023
Merged

Conversation

phlax
Copy link
Member

@phlax phlax commented May 7, 2023

Fix #27236

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label May 7, 2023
@repokitteh-read-only
Copy link

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @RyanTheOptimist

🐱

Caused by: #27243 was opened by phlax.

see: more, trace.

@phlax phlax changed the title contrib: Shift vpp build -> rules_foreign_cc [WIP] contrib: Shift vpp build -> rules_foreign_cc May 7, 2023
@phlax phlax marked this pull request as draft May 7, 2023 09:32
@phlax
Copy link
Member Author

phlax commented May 7, 2023

cc @florincoras

i think this builds a lot unnecessarily but does kinda work (at least testing locally)

i tried setting the target to "" in that case it builds everything apart from the vppcom.h

ive tried to find a way of triggering ninja after as was done in the original build, but struggling to find a way to re/use the binary provided by rules_foreign_cc (cc @keith )

contrib/vcl/source/BUILD Outdated Show resolved Hide resolved
targets = ["", "install"],
build_data = [requirement("ply")],
env = {
"PLYPATHS": "$(locations %s)" % requirement("ply"),
Copy link
Member Author

Choose a reason for hiding this comment

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

there is probably a more elegant way to do this - but i was struggling to think of one

bazel/repositories.bzl Outdated Show resolved Hide resolved
##############################################################################
# vat2
##############################################################################
-add_vpp_executable(vat2 ENABLE_EXPORTS
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 stripped out quite a bit here, possibly its not needed and was only building due to incorrect cmake flags, not sure

either way it was throwing errors about duplicate symbols

+ tools/vppapigen tools/g2 tools/perftool cmake pkg
tools/appimage
- tools/appimage
+ tools/vppapigen cmake pkg
Copy link
Member Author

Choose a reason for hiding this comment

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

im guessing a lot of this is not required, but i guess also that with the right flags/target it would be ignored

Copy link
Member

@florincoras florincoras May 7, 2023

Choose a reason for hiding this comment

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

Components in vpp are unfortunately not as cleanly separated as we'd want. Still, until now we could do with a minimal build because of this snippet in vpp_vcl_build.sh:

cmake -G Ninja ../src -DCMAKE_BUILD_TYPE:STRING=release
ninja -C . vppcom

In other words, we're only building vppcom lib target and its dependencies, not the whole of vpp. The heavy part is vnet not the binary api. Did the build_args in envoy_cmake lower not work?

Copy link
Member Author

@phlax phlax May 7, 2023

Choose a reason for hiding this comment

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

not sure what should/not build tbh

it was my first real experience of cmake and i now understand why its so disliked

i tried so many different ways, but cmake's use of anything i set was patchy at best and a long way from the scant docs i could find

ideally we update the cmake config in such a way as we can cleanly call just the target we actually need

if its difficult to do there, its an order of manitude more difficult doing it with patches etc

**kwargs):
cache_entries.update({"CMAKE_BUILD_TYPE": "Bazel"})
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure why this is enforced - i think in the case of vpp we want it to be 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'd have to dig up the history, there was a reason

@phlax
Copy link
Member Author

phlax commented May 7, 2023

interesting, i now understand why the arm build can be much faster than x64

when this build (and probably same with other foreign builds) gets triggered, and the job is sent to RBE it gets built with 2 cores, whereas on arm its building locally with much more cores and everything on tmpfs

probably for these foreign builds we want to make it no-remote-exec but only when its a larger machine

&& find . -name "*.a" | xargs -I{} cp -a {} $INSTALLDIR/lib/ \
&& find . -name "*.h" | xargs -I{} cp -a {} $INSTALLDIR/include
""",
tags = ["skip_on_windows", "cpu:16"],
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if this cpu setting does anything

Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax phlax changed the title [WIP] contrib: Shift vpp build -> rules_foreign_cc contrib: Shift vpp build -> rules_foreign_cc May 7, 2023
@phlax phlax marked this pull request as ready for review May 7, 2023 10:45
working_directory = "src",
)

genrule(
Copy link
Member

@florincoras florincoras May 7, 2023

Choose a reason for hiding this comment

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

Could we maybe leverage something like this first approach to building vppcom? Note that the file eventually had some additional changes but was finally removed here in favor of the approach we're now deprecating.

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure which bit of that approach you mean, but that is the issue

ideally we do this with rules_foreign_cc - doing it with a genrule requires getting a hermetic cmake toolchain, which i think is not trivial with foreign_cc (not sure why the documented example doesnt seem to work, and it was for make - there was no equivalent setup for cmake anyway)

Copy link
Member Author

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.

getting a hermetic cmake toolchain, which i think is not trivial with foreign_cc

this should be easy - ive certainly found it so with other toolchains that ive worked with

possibly we could do something similar to how we fish out the zstd bin here https://github.com/envoyproxy/envoy/blob/main/tools/zstd/zstd.bzl - altho its a little different as cmake/ninja are provided as a toolchain rather than just a tool

tbh tho its just fighting the system - the better, easier to maintain way would be to get the cmake <> foreign_cc setup correct i think

Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

I don't really understand what's going on in this PR, though I'm sure you do :) Is there another maintainer who might? If so, I think it would be good to have them review. If not, I can stamp it, but if someone else is knowledgable, that'd be great!

@phlax
Copy link
Member Author

phlax commented May 8, 2023

experimentiing further with this locally and discussing offline with @florincoras - my take is that this is probably not a bad approximation to what we have now

i have tried removing the install step - so we are only running cmake with the default target (and with a lot of hacking to remove stuff) but it doesnt seem to decrease the compile time (ie the cmake step) much/any

running without install we dont get the header produced, but with it we do - this is essentially what was being created by running the vppcom build in the previous way

despite various attempts we didnt manage to get the patch to produce the header as part of a default (build?) run

keith
keith previously approved these changes May 8, 2023
**kwargs):
cache_entries.update({"CMAKE_BUILD_TYPE": "Bazel"})
Copy link
Member

Choose a reason for hiding this comment

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

i'd have to dig up the history, there was a reason

contrib/vcl/source/BUILD Outdated Show resolved Hide resolved
contrib/vcl/source/BUILD Outdated Show resolved Hide resolved
Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
Member

@florincoras florincoras left a comment

Choose a reason for hiding this comment

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

LGTM

@phlax phlax enabled auto-merge (squash) May 8, 2023 22:20
@phlax phlax merged commit b896b6d into envoyproxy:main May 8, 2023
phlax added a commit to phlax/envoy that referenced this pull request Jun 1, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>
phlax added a commit to phlax/envoy that referenced this pull request Jun 1, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit to phlax/envoy that referenced this pull request Jun 1, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit to phlax/envoy that referenced this pull request Jun 1, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit that referenced this pull request Jun 2, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit that referenced this pull request Jun 2, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit that referenced this pull request Jun 2, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
phlax added a commit that referenced this pull request Jun 5, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>
reskin89 pushed a commit to reskin89/envoy that referenced this pull request Jul 11, 2023
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Eskin <ryan.eskin89@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps Approval required for changes to Envoy's external dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VPP build is currently broken (and needs to shift to rules_foreign_cc)
4 participants