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

build: use Bazel 1.1.0 #8739

Merged
merged 7 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ build:sizeopt -c opt --copt -Os
build --test_env=HEAPCHECK=normal --test_env=PPROF_PATH

# Remote execution: https://docs.bazel.build/versions/master/remote-execution.html
build:rbe-toolchain --host_platform=@envoy//bazel/toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --platforms=@envoy//bazel/toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --host_platform=@envoy_build_tools//toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --platforms=@envoy_build_tools//toolchains:rbe_ubuntu_clang_platform
build:rbe-toolchain --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

build:rbe-toolchain-clang --config=rbe-toolchain
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.29.1
1.1.0
4 changes: 3 additions & 1 deletion bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def envoy_cmake_external(
copy_pdb = False,
pdb_name = "",
cmake_files_dir = "$BUILD_TMPDIR/CMakeFiles",
generate_crosstool_file = False,
**kwargs):
cache_entries.update({"CMAKE_BUILD_TYPE": "Bazel"})
cache_entries_debug = dict(cache_entries)
Expand Down Expand Up @@ -98,9 +99,10 @@ def envoy_cmake_external(
"//conditions:default": cache_entries_debug,
}),
cmake_options = cmake_options,
# TODO(lizan): Make this always true
generate_crosstool_file = select({
"@envoy//bazel:windows_x86_64": True,
"//conditions:default": False,
"//conditions:default": generate_crosstool_file,
}),
lib_source = lib_source,
make_commands = make_commands,
Expand Down
6 changes: 5 additions & 1 deletion bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ configure_make(
"--enable-shared=no",
"--enable-frame-pointers",
"--disable-libunwind",
],
] + select({
Copy link
Member Author

Choose a reason for hiding this comment

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

@keith I believe this is workaround for bazelbuild/bazel#9154

Copy link
Member

Choose a reason for hiding this comment

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

We should update rules_foriegn_cc instead where this is fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

@keith No that doesn't fix, I guess rules_foreign_cc only fixed cmake, not configure_make, I still need this one.

Copy link
Member

Choose a reason for hiding this comment

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

We should fix it there too then 😞

"//bazel:apple": ["AR=/usr/bin/ar"],
"//conditions:default": [],
}),
lib_source = "@com_github_gperftools_gperftools//:all",
linkopts = ["-lpthread"],
make_commands = ["make install-libLTLIBRARIES install-perftoolsincludeHEADERS"],
Expand Down Expand Up @@ -94,6 +97,7 @@ envoy_cmake_external(
"CMAKE_CXX_COMPILER_FORCED": "on",
},
defines = ["CURL_STATICLIB"],
generate_crosstool_file = True,
lib_source = "@com_github_curl//:all",
static_libraries = select({
"//bazel:windows_x86_64": ["libcurl.lib"],
Expand Down
26 changes: 23 additions & 3 deletions bazel/io_opentracing_cpp.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
diff --git a/mocktracer/BUILD b/mocktracer/BUILD
Copy link
Member

Choose a reason for hiding this comment

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

Can we get this fixed upstream? CC @g-easy

Copy link
Contributor

Choose a reason for hiding this comment

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

CC @rnburn for OpenTracing ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

index 3b22bab..d425e2e 100644
--- a/mocktracer/BUILD
+++ b/mocktracer/BUILD
@@ -7,11 +7,13 @@ cc_library(
deps = [
"//:opentracing",
],
+ alwayslink = 1,
)

cc_binary(
name = "libmocktracer_plugin.so",
linkshared = 1,
+ linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
"//mocktracer:mocktracer"
diff --git a/src/dynamic_load_unix.cpp b/src/dynamic_load_unix.cpp
index 17e08fd..d25e0c8 100644
index 17e08fd..7e8ac02 100644
--- a/src/dynamic_load_unix.cpp
+++ b/src/dynamic_load_unix.cpp
@@ -35,7 +35,11 @@ DynamicallyLoadTracingLibrary(const char* shared_library,
@@ -35,7 +35,13 @@ DynamicallyLoadTracingLibrary(const char* shared_library,
std::string& error_message) noexcept try {
dlerror(); // Clear any existing error.

- const auto handle = dlopen(shared_library, RTLD_NOW | RTLD_LOCAL);
+ const auto handle = dlopen(shared_library, RTLD_NOW | RTLD_LOCAL
+#ifdef __SANITIZE_ADDRESS__
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+ | RTLD_NODELETE
+#endif
+#endif
+ );
if (handle == nullptr) {
error_message = dlerror();
Expand Down
14 changes: 7 additions & 7 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.19.0/bazel-gazelle-v0.19.0.tar.gz"],
),
bazel_toolchains = dict(
sha256 = "a1e273b6159ae858f53046f5bab9678cffa82a72f0bf0c0a9e4af8fddb91209c",
strip_prefix = "bazel-toolchains-0.29.6",
sha256 = "1e16833a9f0e32b292568c0dfee7bd48133c2038605757d3a430551394310006",
strip_prefix = "bazel-toolchains-1.1.0",
urls = [
"https://github.com/bazelbuild/bazel-toolchains/releases/download/0.29.6/bazel-toolchains-0.29.6.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/0.29.6.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/releases/download/1.1.0/bazel-toolchains-1.1.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/1.1.0.tar.gz",
],
),
envoy_build_tools = dict(
sha256 = "7cae08267737c77e92958b9b04b3da88cc2ce5a6ee9c572236688a1fa5f873f0",
strip_prefix = "envoy-build-tools-57c24964ee4965e1c35509f3f099d5ad172bd10a",
urls = ["https://github.com/envoyproxy/envoy-build-tools/archive/57c24964ee4965e1c35509f3f099d5ad172bd10a.tar.gz"],
sha256 = "d0f88bef8bd7f76c3684407977f5673f3d06a6c50d4ddaffb8f0e7df6b0ef69e",
strip_prefix = "envoy-build-tools-a6b28555badcb18d6be924c8fc1bea49971656b8",
urls = ["https://github.com/envoyproxy/envoy-build-tools/archive/a6b28555badcb18d6be924c8fc1bea49971656b8.tar.gz"],
),
boringssl = dict(
sha256 = "891352824e0f7977bc0c291b8c65076e3ed23630334841b93f346f12d4484b06",
Expand Down
50 changes: 21 additions & 29 deletions tools/api_proto_plugin/plugin.bzl
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
# Borrowed from
# https://github.com/bazelbuild/rules_go/blob/master/proto/toolchain.bzl. This
# does some magic munging to remove workspace prefixes from output paths to
# convert path as understood by Bazel into paths as understood by protoc.
def _proto_path(proto):
"""
The proto path is not really a file path
It's the path to the proto that was seen when the descriptor file was generated.
"""
path = proto.path
root = proto.root.path
ws = proto.owner.workspace_root
if path.startswith(root):
path = path[len(root):]
if path.startswith("/"):
path = path[1:]
if path.startswith(ws):
path = path[len(ws):]
if path.startswith("/"):
path = path[1:]
return path
# Borrowed from https://github.com/grpc/grpc-java/blob/v1.24.1/java_grpc_library.bzl#L61
def _path_ignoring_repository(f):
# Bazel creates a _virtual_imports directory in case the .proto source files
# need to be accessed at a path that's different from their source path:
# https://github.com/bazelbuild/bazel/blob/0.27.1/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java#L289
#
# In that case, the import path of the .proto file is the path relative to
# the virtual imports directory of the rule in question.
virtual_imports = "/_virtual_imports/"
if virtual_imports in f.path:
return f.path.split(virtual_imports)[1].split("/", 1)[1]
elif len(f.owner.workspace_root) == 0:
# |f| is in the main repository
return f.short_path
else:
# If |f| is a generated file, it will have "bazel-out/*/genfiles" prefix
# before "external/workspace", so we need to add the starting index of "external/workspace"
return f.path[f.path.find(f.owner.workspace_root) + len(f.owner.workspace_root) + 1:]

def api_proto_plugin_impl(target, ctx, output_group, mnemonic, output_suffixes):
# Compute output files from the current proto_library node's dependencies.
Expand All @@ -36,18 +33,13 @@ def api_proto_plugin_impl(target, ctx, output_group, mnemonic, output_suffixes):
# extractions. See https://github.com/bazelbuild/bazel/issues/3971.
import_paths = []
for f in target[ProtoInfo].transitive_sources.to_list():
if f.root.path:
import_path = f.root.path + "/" + f.owner.workspace_root
else:
import_path = f.owner.workspace_root
if import_path:
import_paths += [import_path]
import_paths += ["{}={}".format(_path_ignoring_repository(f), f.path)]

# The outputs live in the ctx.label's package root. We add some additional
# path information to match with protoc's notion of path relative locations.
outputs = []
for output_suffix in output_suffixes:
outputs += [ctx.actions.declare_file(ctx.label.name + "/" + _proto_path(f) +
outputs += [ctx.actions.declare_file(ctx.label.name + "/" + _path_ignoring_repository(f) +
output_suffix) for f in proto_sources]

# Create the protoc command-line args.
Expand All @@ -56,7 +48,7 @@ def api_proto_plugin_impl(target, ctx, output_group, mnemonic, output_suffixes):
args = ["-I./" + ctx.label.workspace_root]
args += ["-I" + import_path for import_path in import_paths]
args += ["--plugin=protoc-gen-api_proto_plugin=" + ctx.executable._api_proto_plugin.path, "--api_proto_plugin_out=" + output_path]
args += [_proto_path(src) for src in target[ProtoInfo].direct_sources]
args += [src.path for src in target[ProtoInfo].direct_sources]
ctx.actions.run(
executable = ctx.executable._protoc,
arguments = args,
Expand Down