Skip to content

Commit

Permalink
ppc64le build (envoyproxy#4183)
Browse files Browse the repository at this point in the history
Build for Linux on Power (ppc64le). There is no luajit support for ppc64le, so
this PR puts in logic to not add that recipe to the sandbox speedup that
envoy uses for its build.

There were already some differences taken into account for Windows, so
hopefully this isn't too far out there.

Description: Build for Linux on Power (ppc64le).
Risk Level: low
Testing: manual + have built this into istio/proxy for a few releases now
Docs Changes: Would need to add a bit about Power support
Release Notes: same

Signed-off-by: Christy Norman <christy@linux.vnet.ibm.com>
  • Loading branch information
clnperez authored and htuch committed Sep 4, 2018
1 parent 07efc6d commit 2d155f9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
5 changes: 5 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ config_setting(
values = {"cpu": "x64_windows"},
)

config_setting(
name = "linux_ppc",
values = {"cpu": "ppc"},
)

config_setting(
name = "windows_opt_build",
values = {
Expand Down
29 changes: 26 additions & 3 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ load(
)
load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_env_var")

# dict of {build recipe name: longform extension name,}
PPC_SKIP_TARGETS = {"luajit": "envoy.filters.http.lua"}

def _repository_impl(name, **kwargs):
# `existing_rule_keys` contains the names of repositories that have already
# been defined in the Bazel workspace. By skipping repos with existing keys,
Expand Down Expand Up @@ -71,6 +74,9 @@ def _repository_impl(name, **kwargs):
)

def _build_recipe_repository_impl(ctxt):
# modify the recipes list based on the build context
recipes = _apply_dep_blacklist(ctxt, ctxt.attr.recipes)

# Setup the build directory with links to the relevant files.
ctxt.symlink(Label("//bazel:repositories.sh"), "repositories.sh")
ctxt.symlink(Label("//bazel:repositories.bat"), "repositories.bat")
Expand All @@ -80,7 +86,7 @@ def _build_recipe_repository_impl(ctxt):
)
ctxt.symlink(Label("//ci/build_container:recipe_wrapper.sh"), "recipe_wrapper.sh")
ctxt.symlink(Label("//ci/build_container:Makefile"), "Makefile")
for r in ctxt.attr.recipes:
for r in recipes:
ctxt.symlink(
Label("//ci/build_container/build_recipes:" + r + ".sh"),
"build_recipes/" + r + ".sh",
Expand All @@ -99,9 +105,9 @@ def _build_recipe_repository_impl(ctxt):
env["CXX"] = "cl"
env["CXXFLAGS"] = "-DNDEBUG"
env["CFLAGS"] = "-DNDEBUG"
command = ["./repositories.bat"] + ctxt.attr.recipes
command = ["./repositories.bat"] + recipes
else:
command = ["./repositories.sh"] + ctxt.attr.recipes
command = ["./repositories.sh"] + recipes

print("Fetching external dependencies...")
result = ctxt.execute(
Expand Down Expand Up @@ -259,6 +265,7 @@ def envoy_dependencies(path = "@envoy_deps//", skip_targets = []):
name = "envoy_deps",
recipes = recipes.to_list(),
)

for t in TARGET_RECIPES:
if t not in skip_targets:
native.bind(
Expand Down Expand Up @@ -527,3 +534,19 @@ def _com_github_google_jwt_verify():
name = "jwt_verify_lib",
actual = "@com_github_google_jwt_verify//:jwt_verify_lib",
)

def _apply_dep_blacklist(ctxt, recipes):
newlist = []
skip_list = dict()
if _is_linux_ppc(ctxt):
skip_list = PPC_SKIP_TARGETS
for t in recipes:
if t not in skip_list.keys():
newlist.append(t)
return newlist

def _is_linux_ppc(ctxt):
if ctxt.os.name != "linux":
return False
res = ctxt.execute(["uname", "-m"])
return "ppc" in res.stdout
2 changes: 2 additions & 0 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ load(
"envoy_all_extensions",
"envoy_windows_extensions",
)
load("//bazel:repositories.bzl", "PPC_SKIP_TARGETS")

envoy_package()

Expand Down Expand Up @@ -40,6 +41,7 @@ envoy_cc_library(
"//source/server:test_hooks_lib",
] + select({
"//bazel:windows_x86_64": envoy_windows_extensions(),
"//bazel:linux_ppc": envoy_all_extensions(PPC_SKIP_TARGETS),
"//conditions:default": envoy_all_extensions(),
}),
)
Expand Down
7 changes: 4 additions & 3 deletions source/extensions/all_extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@envoy_build_config//:extensions_build_config.bzl", "EXTENSIONS", "WINDOWS_EXTENSIONS")

# Return all extensions to be compiled into Envoy.
def envoy_all_extensions():
def envoy_all_extensions(blacklist = dict()):
# These extensions are registered using the extension system but are required for the core
# Envoy build.
all_extensions = [
Expand All @@ -10,8 +10,9 @@ def envoy_all_extensions():
]

# These extensions can be removed on a site specific basis.
for path in EXTENSIONS.values():
all_extensions.append(path)
for name, path in EXTENSIONS.items():
if not name in blacklist.values():
all_extensions.append(path)

return all_extensions

Expand Down

0 comments on commit 2d155f9

Please sign in to comment.