Skip to content

Commit

Permalink
Use correct llvm libs for cmake build of bcc and bpftrace.
Browse files Browse the repository at this point in the history
Summary: Previously, bcc/bpftrace were building using the libs in /opt/clang-15.0. This diff makes them use the downloaded libs instead.

Test Plan: Checked the cmake logs to make sure its no longer using /opt/clang-15.0. #ci:bpf-build

Reviewers: zasgar, vihang, #third_party_approvers

Reviewed By: zasgar, #third_party_approvers

Signed-off-by: James Bartlett <[email protected]>

Differential Revision: https://phab.corp.pixielabs.ai/D12729

GitOrigin-RevId: b6f2a70e74009fb5669ee163c2e33c5f826ff609
  • Loading branch information
JamesMBartlett authored and copybaranaut committed Jan 7, 2023
1 parent 64625ce commit 3cfaf59
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
12 changes: 8 additions & 4 deletions bazel/external/bcc.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0

load("@px//bazel:llvm_cmake.bzl", "add_llvm_cache_entries", "llvm_build_data_deps")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

licenses(["notice"])
Expand All @@ -30,15 +31,15 @@ cmake(
"-j`nproc`",
"-l`nproc`",
],
cache_entries = {
build_data = llvm_build_data_deps(),
cache_entries = add_llvm_cache_entries({
"CMAKE_USE_LIBBPF_PACKAGE": "ON",
"ENABLE_EXAMPLES": "OFF",
"ENABLE_MAN": "OFF",
"ENABLE_TESTS": "OFF",
"LIBBPF_INCLUDE_DIR": "$EXT_BUILD_DEPS/libbpf/include",
"LIBBPF_LIBRARIES": "$EXT_BUILD_DEPS/libbpf/lib64/libbpf.a",
"LLVM_ROOT": "/opt/clang-15.0",
},
}),
includes = [
"bcc/compat",
],
Expand All @@ -65,5 +66,8 @@ cmake(
"clang_frontend",
],
visibility = ["//visibility:public"],
deps = ["@com_github_libbpf_libbpf//:libbpf"],
deps = [
"@com_github_libbpf_libbpf//:libbpf",
"@px//:llvm",
],
)
10 changes: 5 additions & 5 deletions bazel/external/bpftrace.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0

load("@px//bazel:llvm_cmake.bzl", "add_llvm_cache_entries", "llvm_build_data_deps")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

licenses(["notice"])
Expand All @@ -30,7 +31,8 @@ cmake(
"-j`nproc`",
"-l`nproc`",
],
cache_entries = {
build_data = llvm_build_data_deps(),
cache_entries = add_llvm_cache_entries({
"BUILD_FUZZ": "OFF",
"BUILD_TESTING": "OFF",

Expand All @@ -53,9 +55,7 @@ cmake(
"LIBBPF_INCLUDE_DIRS": "$EXT_BUILD_DEPS/libbpf/include",
"LIBBPF_LIBRARIES": "$EXT_BUILD_DEPS/libbpf/lib64/libbpf.a",
"LIBCEREAL_INCLUDE_DIRS": "$EXT_BUILD_DEPS/include",
"LLVM_REQUESTED_VERSION": "15.0.6",
"LLVM_ROOT": "/opt/clang-15.0",
},
}),
lib_source = ":bpftrace_source",
linkopts = [
"-lelf",
Expand All @@ -78,6 +78,6 @@ cmake(
"@com_github_USCiLab_cereal//:cereal",
"@com_github_iovisor_bcc//:bcc",
"@com_github_libbpf_libbpf//:libbpf",
"@com_llvm_lib//:llvm",
"@px//:llvm",
],
)
6 changes: 6 additions & 0 deletions bazel/external/llvm.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ cc_library(
visibility = ["//visibility:public"],
alwayslink = 1,
)

filegroup(
name = "cmake",
srcs = glob(["lib/cmake/llvm/**"]),
visibility = ["//visibility:public"],
)
33 changes: 33 additions & 0 deletions bazel/llvm_cmake.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

def add_llvm_cache_entries(cache_entries):
return select({
"@px//bazel:use_libcpp": dict(
cache_entries,
LLVM_ROOT = "$EXT_BUILD_ROOT/external/com_llvm_lib_libcpp",
),
"//conditions:default": dict(
cache_entries,
LLVM_ROOT = "$EXT_BUILD_ROOT/external/com_llvm_lib",
),
})

def llvm_build_data_deps():
return select({
"@px//bazel:use_libcpp": ["@com_llvm_lib_libcpp//:cmake"],
"//conditions:default": ["@com_llvm_lib//:cmake"],
})
8 changes: 4 additions & 4 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/oneapi-src/oneTBB/archive/e6104c9599f7f10473caf545199f7468c0a8e52f.tar.gz"],
),
com_llvm_lib = dict(
sha256 = "af503fd8660bbd29455588d1fa87ad8cc0cd2bf6e4f3c59c8d738c2f934c8140",
sha256 = "e2cdc560be2469f376558164ce51d75669e4ff0585712f04face168fa597740f",
strip_prefix = "",
urls = ["https://storage.googleapis.com/pixie-dev-public/clang/15.0-pl3/llvm-15.0-pl3.tar.gz"],
urls = ["https://storage.googleapis.com/pixie-dev-public/clang/15.0-pl5/llvm-15.0-pl5.tar.gz"],
),
com_llvm_lib_libcpp = dict(
sha256 = "4d904ae1df7e0ba8546cf901509034da2a129805ef0720cb10b6a8a41ae44a29",
sha256 = "1bd0b9d41a2cbc34d9abc64b1017cf08a956200bb41c14b6fe3e1ddb29d1ca6b",
strip_prefix = "",
urls = ["https://storage.googleapis.com/pixie-dev-public/clang/15.0-pl3/llvm-15.0-pl3-libcxx.tar.gz"],
urls = ["https://storage.googleapis.com/pixie-dev-public/clang/15.0-pl5/llvm-15.0-pl5-libcxx.tar.gz"],
),
com_oracle_openjdk_18 = dict(
sha256 = "3bfdb59fc38884672677cebca9a216902d87fe867563182ae8bc3373a65a2ebd",
Expand Down

0 comments on commit 3cfaf59

Please sign in to comment.