From 064c3961b67fc72c4b39268c84d1e4f4a60ca3fb Mon Sep 17 00:00:00 2001 From: Christy Norman Date: Tue, 7 Aug 2018 18:00:22 -0400 Subject: [PATCH] ppc64le build 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. -- Another alternative is to have subproject for Power that has its own WORKSPACE file, like the ci, but in trying that route, I ran into the issue of not being able to read the build_id in the bazel-out directory (up a level). This way also has the advantage that you don't have to know to change directories if you want to build for Power. And hopefully we can do the same checks for ARM. Signed-off-by: Christy Norman --- bazel/BUILD | 5 +++++ bazel/repositories.bzl | 29 +++++++++++++++++++++++++--- source/exe/BUILD | 2 ++ source/extensions/all_extensions.bzl | 7 ++++--- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/bazel/BUILD b/bazel/BUILD index 223d2d0b7ee1..ce66abe17466 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -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 = { diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 50656e238e39..1cee041d58cd 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -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, @@ -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") @@ -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", @@ -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( @@ -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( @@ -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 diff --git a/source/exe/BUILD b/source/exe/BUILD index 8d1e932de1d1..52064272fa0a 100644 --- a/source/exe/BUILD +++ b/source/exe/BUILD @@ -11,6 +11,7 @@ load( "envoy_all_extensions", "envoy_windows_extensions", ) +load("//bazel:repositories.bzl", "PPC_SKIP_TARGETS") envoy_package() @@ -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(), }), ) diff --git a/source/extensions/all_extensions.bzl b/source/extensions/all_extensions.bzl index 1dc1a34aad6b..83dbeb4c8d9d 100644 --- a/source/extensions/all_extensions.bzl +++ b/source/extensions/all_extensions.bzl @@ -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 = [ @@ -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