Skip to content

Commit

Permalink
Update build to use clang-15.
Browse files Browse the repository at this point in the history
Summary: TSIA

Test Plan: Existing tests.

Reviewers: michelle, jamesbartlett, oazizi, vihang, #third_party_approvers

Reviewed By: jamesbartlett, vihang, #third_party_approvers

Subscribers: yzhao

Signed-off-by: Zain Asgar <zasgar@pixielabs.ai>

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

GitOrigin-RevId: 1e53aace6cc3bb08438dce919fcb341ed2510c44
  • Loading branch information
zasgar authored and copybaranaut committed Dec 26, 2022
1 parent 1217cd1 commit 3970310
Show file tree
Hide file tree
Showing 28 changed files with 216 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Global bazelrc file, see https://docs.bazel.build/versions/master/guide.html#bazelrc.

# This is to flush bazel cache for new version of clang/gcc.
build --action_env=CLANG_COMPILER_VERSION=14.0_0
build --host_action_env=CLANG_COMPILER_VERSION=14.0_0
build --action_env=CLANG_COMPILER_VERSION=15.0_2
build --host_action_env=CLANG_COMPILER_VERSION=15.0_2

build --remote_download_minimal
test --remote_download_minimal
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pl_cc_base_packages = [
packages["libelf1"],
packages["liblzma5"],
packages["libtinfo6"],
packages["libunwind8"],
packages["zlib1g"],
]

Expand Down
16 changes: 9 additions & 7 deletions bazel/cc_toolchains/clang.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def _clang_x86_64_gnu_with_options(suffix = "", enable_sanitizers = True, extra_
"ar": "/usr/bin/ar",
"cpp": "/usr/bin/cpp",
"dwp": "/usr/bin/dwp",
"gcc": "/opt/clang-14.0/bin/clang-14",
"gcc": "/opt/clang-15.0/bin/clang-15",
"gcov": "/usr/bin/gcov",
"ld": "/usr/bin/ld",
"llvm-cov": "/opt/clang-14.0/bin/llvm-cov",
"llvm-cov": "/opt/clang-15.0/bin/llvm-cov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
Expand All @@ -62,15 +62,15 @@ def _clang_x86_64_gnu_with_options(suffix = "", enable_sanitizers = True, extra_
abi_version = "clang",
abi_libc_version = "glibc_unknown",
cxx_builtin_include_directories = [
"/opt/clang-14.0/lib/clang/14.0.4/include",
"/opt/clang-15.0/lib/clang/15.0.6/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"/opt/clang-14.0/lib/clang/14.0.4/share",
"/opt/clang-15.0/lib/clang/15.0.6/share",
"/usr/include/c++/11",
"/usr/include/x86_64-linux-gnu/c++/11",
"/usr/include/c++/11/backward",
"/opt/clang-14.0/include/c++/v1",
"/opt/clang-15.0/include/c++/v1",
],
tool_paths = tool_paths,
compile_flags = [
Expand All @@ -80,6 +80,8 @@ def _clang_x86_64_gnu_with_options(suffix = "", enable_sanitizers = True, extra_
"-Wself-assign",
"-Wunused-but-set-parameter",
"-Wno-free-nonheap-object",
"-Wno-deprecated-builtins",
"-Wno-deprecated-non-prototype",
"-fcolor-diagnostics",
"-fno-omit-frame-pointer",
],
Expand All @@ -100,7 +102,7 @@ def _clang_x86_64_gnu_with_options(suffix = "", enable_sanitizers = True, extra_
"-fuse-ld=lld",
"-Wl,-no-as-needed",
"-Wl,-z,relro,-z,now",
"-B/opt/clang-14.0/bin",
"-B/opt/clang-15.0/bin",
"-lm",
],
opt_link_flags = ["-Wl,--gc-sections"],
Expand All @@ -114,7 +116,7 @@ def _clang_x86_64_gnu_with_options(suffix = "", enable_sanitizers = True, extra_
coverage_compile_flags = ["--coverage"],
coverage_link_flags = ["--coverage"],
supports_start_end_lib = True,
libclang_rt_path = "/opt/clang-14.0/lib/clang/14.0.4/lib/linux",
libclang_rt_path = "/opt/clang-15.0/lib/clang/15.0.6/lib/linux",
enable_sanitizers = enable_sanitizers,
)

Expand Down
4 changes: 2 additions & 2 deletions bazel/cc_toolchains/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _gcc_x86_64_gnu():
"gcc": "/usr/bin/gcc-11",
"gcov": "/usr/bin/gcov",
"ld": "/usr/bin/ld",
"llvm-cov": "/opt/clang-14.0/bin/llvm-cov",
"llvm-cov": "/opt/clang-15.0/bin/llvm-cov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
Expand Down Expand Up @@ -133,7 +133,7 @@ def _gcc_x86_64_static_musl():
"gcc": "/usr/bin/gcc-11",
"gcov": "/usr/bin/gcov",
"ld": "/usr/bin/ld",
"llvm-cov": "/opt/clang-14.0/bin/llvm-cov",
"llvm-cov": "/opt/clang-15.0/bin/llvm-cov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
Expand Down
1 change: 1 addition & 0 deletions bazel/external/bcc.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cmake(
"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 Down
4 changes: 3 additions & 1 deletion bazel/external/bpftrace.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ 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 = [
Expand All @@ -64,7 +66,6 @@ cmake(
"libaot.a",
"libast.a",
"libruntime.a",
"libbpforc.a",
"libast_defs.a",
"libparser.a",
"libresources.a",
Expand All @@ -77,5 +78,6 @@ cmake(
"@com_github_USCiLab_cereal//:cereal",
"@com_github_iovisor_bcc//:bcc",
"@com_github_libbpf_libbpf//:libbpf",
"@com_llvm_lib//:llvm",
],
)
2 changes: 2 additions & 0 deletions bazel/external/llvm.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ cc_library(
"lib/libclangDriver.a",
"lib/libclangParse.a",
"lib/libclangSema.a",
"lib/libclangSupport.a",
"lib/libclangAnalysis.a",
"lib/libclangEdit.a",
"lib/libclangAST.a",
Expand Down Expand Up @@ -95,6 +96,7 @@ cc_library(
"lib/libLLVMJITLink.a",
"lib/libLLVMOrcTargetProcess.a",
"lib/libLLVMOrcShared.a",
"lib/libLLVMWindowsDriver.a",

# AArch64 libs.
"lib/libLLVMAArch64AsmParser.a",
Expand Down
4 changes: 4 additions & 0 deletions bazel/external/ubuntu_packages/debs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"path": "main/n/ncurses/libtinfo6_6.3-2_amd64.deb",
"checksum": "5f7618187c6d1924ec758c2d5422c67377af92ecb21695008edf83a2d0c85ecd"
},
{
"path": "main/libu/libunwind/libunwind8_1.3.2-2build2_amd64.deb",
"checksum": "475ae509da614dd5d7210f605fd5894a3c98b6fb8c18738b16d8d4b700553c30"
},
{
"path": "main/x/xz-utils/liblzma5_5.2.5-2ubuntu1_amd64.deb",
"checksum": "8f1c46e7d3f5102a5e4fdca7c949728a343ba71c2a7c124118df2c13d4c444f7"
Expand Down
7 changes: 7 additions & 0 deletions bazel/external/ubuntu_packages/packages.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def download_ubuntu_packages():
sha256 = "9751c8bfed7d4ecca1460f51e9a0e5ea1a5a270743855e31b328d86c8d692524",
downloaded_file_path = "out.deb",
)
http_file(
name = "libunwind8",
urls = ["https://storage.googleapis.com/pixie-dev-public/ubuntu-debs/1655507056/libunwind8_1.3.2-2build2_amd64.deb"],
sha256 = "d257e00e37886bd38040f0a79a79e961ffbf774119d63bfaebe46bf372003f19",
downloaded_file_path = "out.deb",
)
http_file(
name = "zlib1g",
urls = ["https://storage.googleapis.com/pixie-dev-public/ubuntu-debs/1655507056/zlib1g_1.2.11.dfsg-2ubuntu9_amd64.deb"],
Expand All @@ -61,5 +67,6 @@ packages = {
"libelf1": "@libelf1//file:out.deb",
"liblzma5": "@liblzma5//file:out.deb",
"libtinfo6": "@libtinfo6//file:out.deb",
"libunwind8": "@libunwind8//file:out.deb",
"zlib1g": "@zlib1g//file:out.deb",
}
2 changes: 1 addition & 1 deletion bazel/pl_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def pl_common_linkopts():
"@bazel_tools//tools/osx:darwin": [],
"//conditions:default": [
"-pthread",
"-l:libunwind.a",
"-lunwind",
"-llzma",
"-lrt",
"-ldl",
Expand Down
4 changes: 2 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ def _com_llvm_lib():
native.new_local_repository(
name = "com_llvm_lib",
build_file = "bazel/external/llvm.BUILD",
path = "/opt/clang-14.0",
path = "/opt/clang-15.0",
)

native.new_local_repository(
name = "com_llvm_lib_libcpp",
build_file = "bazel/external/llvm.BUILD",
path = "/opt/clang-14.0-libc++",
path = "/opt/clang-15.0-libc++",
)

def _cc_deps():
Expand Down
12 changes: 6 additions & 6 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/h2o/picohttpparser/archive/1d2b8a184e7ebe6651c30dcede37ba1d89691351.tar.gz"],
),
com_github_iovisor_bcc = dict(
sha256 = "0fe8e9f0ebac749db7bdc96dfc532fdf34f4f804a2103e4840a5160651ed3bf5",
strip_prefix = "bcc-b9cc317740d943173a493f2941f716679c560fa8",
sha256 = "46eac44c0cf68a94bafe01088081b71606982936ccdfe2808fcd28e0cc131ba8",
strip_prefix = "bcc-6bfdb074c276be69ace19da376a689d1dbb4963f",
urls = [
"https://github.com/pixie-io/bcc/archive/b9cc317740d943173a493f2941f716679c560fa8.tar.gz",
"https://github.com/pixie-io/bcc/archive/6bfdb074c276be69ace19da376a689d1dbb4963f.tar.gz",
],
),
com_github_iovisor_bpftrace = dict(
sha256 = "b8ebddb930aca0293f4f0f9ffaf3b550eba6e14a5ba3f0f3abbb3028873e5554",
strip_prefix = "bpftrace-ad53050229186cb71021bf4d6617e8765c666a3c",
sha256 = "92138b530a222efbe7506b337b91694f994d2bee1723263cb740766297be2156",
strip_prefix = "bpftrace-460adf093c226a3013ff389cf9a2d84834018b9b",
urls = [
"https://github.com/pixie-io/bpftrace/archive/ad53050229186cb71021bf4d6617e8765c666a3c.tar.gz",
"https://github.com/pixie-io/bpftrace/archive/460adf093c226a3013ff389cf9a2d84834018b9b.tar.gz",
],
),
com_github_jupp0r_prometheus_cpp = dict(
Expand Down
2 changes: 1 addition & 1 deletion docker.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DOCKER_IMAGE_TAG=202212202227
DOCKER_IMAGE_TAG=202212230615
2 changes: 0 additions & 2 deletions src/carnot/carnot_executable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ std::shared_ptr<px::table_store::Table> GetTableFromCsv(const std::string& filen
// Get the columns types and names.
auto row_idx = 0;
for (auto& row : parser) {
auto col_idx = 0;
for (auto& field : row) {
if (row_idx == 0) {
auto type = GetTypeFromHeaderString(field).ConsumeValueOrDie();
Expand All @@ -128,7 +127,6 @@ std::shared_ptr<px::table_store::Table> GetTableFromCsv(const std::string& filen
} else if (row_idx == 1) { // Reading second row, should be the names of columns.
names.push_back(field);
}
col_idx++;
}
row_idx++;
if (row_idx > 1) {
Expand Down
6 changes: 0 additions & 6 deletions src/stirling/bpf_tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ pl_cc_library(
"*.h",
],
),
# This is a critical define. The cmake build uses this define,
# and if we don't include it, the headers will mismatch the object files,
# resulting in obscure segmentation faults around BpfOrc.
# For reference, see the cmake build in bpftrace.BUILD.
# TODO(oazizi): See if we can contribute to the bpftrace repo to help with this case.
defines = ["LLVM_ORC_V2"],
deps = [
"//src/common/system:cc_library",
"//src/stirling/obj_tools:cc_library",
Expand Down
6 changes: 3 additions & 3 deletions src/stirling/bpf_tools/bpftrace_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "src/stirling/bpf_tools/bpftrace_wrapper.h"

#include <aot/aot.h>
#include <ast/bpforc/bpforc.h>
#include <ast/pass_manager.h>
#include <ast/passes/codegen_llvm.h>
#include <ast/passes/field_analyser.h>
Expand Down Expand Up @@ -191,6 +190,8 @@ Status BPFTraceWrapper::Compile(std::string_view script, const std::vector<std::
return error::Internal(ERR_MSG "failed to parse: $0", err_msg);
}

bpftrace_.parse_btf(driver.list_modules());

// This collects the error messages emitted during the FieldAnalyser's analysis.
std::ostringstream field_analyser_oss;
bpftrace::ast::FieldAnalyser fields(driver.root.get(), bpftrace_, field_analyser_oss);
Expand Down Expand Up @@ -238,8 +239,7 @@ Status BPFTraceWrapper::Compile(std::string_view script, const std::vector<std::
bpftrace::ast::CodegenLLVM llvm(ast_root.get(), bpftrace_);
llvm.generate_ir();
llvm.optimize();
std::unique_ptr<bpftrace::BpfOrc> bpforc = llvm.emit();
bytecode_ = bpforc->getBytecode();
bytecode_ = llvm.emit();

compiled_ = true;

Expand Down
2 changes: 1 addition & 1 deletion src/stirling/e2e_tests/stirling_wrapper_size_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace px {
namespace stirling {

#ifdef __OPTIMIZE__
constexpr uint64_t kFileSizeLimitMB = 110;
constexpr uint64_t kFileSizeLimitMB = 112;
#else
constexpr uint64_t kFileSizeLimitMB = 290;
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/stirling/obj_tools/dwarf_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <llvm/BinaryFormat/Dwarf.h>
#include <llvm/Config/llvm-config.h>
#include <llvm/DebugInfo/DWARF/DWARFExpression.h>
#include <llvm/Support/ScopedPrinter.h>

#include "src/stirling/obj_tools/dwarf_reader.h"

Expand Down Expand Up @@ -820,7 +822,7 @@ StatusOr<llvm::ArrayRef<uint8_t>> GetDieLocationAttrBytes(const DWARFDie& die) {

// For now, we use the first location, assuming that it is valid for the function entry.
const llvm::DWARFLocationExpression& loc = location_expr_vec->front();
VLOG(1) << to_string(loc);
VLOG(1) << llvm::to_string(loc);

return llvm::ArrayRef<uint8_t>(loc.Expr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ TEST_F(PerfProfileBPFTest, DISABLED_PerfProfilerCppTest) {
CheckExpectedCounts(observed_stack_traces_, kNumSubProcesses, elapsed_time, key1x, key2x));
}

TEST_F(PerfProfileBPFTest, GraalVM_AOT_Test) {
// TODO(jps/oazizi): This test is flaky.
TEST_F(PerfProfileBPFTest, DISABLED_GraalVM_AOT_Test) {
const std::string app_path = "JavaFib";
const std::filesystem::path bazel_app_path = BazelJavaTestAppPath(app_path);
ASSERT_TRUE(fs::Exists(bazel_app_path)) << absl::StrFormat("Missing: %s.", bazel_app_path);
Expand Down
2 changes: 1 addition & 1 deletion tools/chef/base_image_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
202211211444
202212230559
6 changes: 3 additions & 3 deletions tools/chef/cookbooks/pixielabs/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

default['clang'] = {}
default['clang']['deb'] =
'https://storage.googleapis.com/pixie-dev-public/clang-14.0-pl1.deb'
'https://storage.googleapis.com/pixie-dev-public/clang-15.0-pl1.deb'
default['clang']['deb_sha256'] =
'54d8712cad93eb5fe27d19384b6980ac1c319cdd9b678fdd52723b7447e5ba87'
default['clang']['version'] = "14.0-pl1"
'c8173e9ba5f75da1cc8e4c7fbeeafbbc264e38640b3608f1fc1f1633f1a04c90'
default['clang']['version'] = "15.0-pl1"

default['gperftools'] = {}
default['gperftools']['deb'] =
Expand Down
6 changes: 3 additions & 3 deletions tools/chef/cookbooks/pixielabs/recipes/linux_clang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
action :delete
end

ENV['PATH'] = "/opt/clang-14.0/bin:#{ENV['PATH']}"
ENV['LD_LIBRARY_PATH'] = "/opt/clang-14.0/lib:#{ENV['LD_LIBRARY_PATH']}"
ENV['PATH'] = "/opt/clang-15.0/bin:#{ENV['PATH']}"
ENV['LD_LIBRARY_PATH'] = "/opt/clang-15.0/lib:#{ENV['LD_LIBRARY_PATH']}"
ENV['CC'] = "clang"
ENV['CXX'] = "clang++"

# Provide LLD as a system linker.
execute 'lld alternatives selection' do
command 'update-alternatives --install "/usr/bin/ld.lld" "lld" "/opt/clang-14.0/bin/lld" 10'
command 'update-alternatives --install "/usr/bin/ld.lld" "lld" "/opt/clang-15.0/bin/lld" 10'
end
4 changes: 2 additions & 2 deletions tools/chef/cookbooks/pixielabs/templates/plenv.inc.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# If changing this file, make sure to also update the ENV in tools/chef/packer_docker_dev.json.
# DO NOT EDIT! This is an automatically generated file by Chef and may be changed.
export CLANG_PATH=/opt/clang-14.0
export CLANG_PATH=/opt/clang-15.0
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export PATH=/opt/google-cloud-sdk/bin:$PATH
export PATH=/opt/node/bin:$PATH
Expand All @@ -13,7 +13,7 @@ export LD_LIBRARY_PATH=${CLANG_PATH}/lib:${LD_LIBRARY_PATH}
export CC=clang
export CXX=clang++

export ASAN_SYMBOLIZER_PATH=/opt/clang-14.0/bin/llvm-symbolizer
export ASAN_SYMBOLIZER_PATH=/opt/clang-15.0/bin/llvm-symbolizer

if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
# Assume Zsh.
Expand Down
6 changes: 3 additions & 3 deletions tools/chef/packer_docker_dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"builders": [
{
"changes": [
"ENV PATH /opt/golang/bin:/opt/pixielabs/bin:/opt/clang-14.0/bin:/pl/bin:/opt/google-cloud-sdk/bin:/opt/gsutil:/opt/node/bin:/opt/phab/arcanist/bin:/usr/lib/go-1.10/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ENV LD_LIBRARY_PATH /opt/clang-14.0/lib",
"ENV PATH /opt/golang/bin:/opt/pixielabs/bin:/opt/clang-15.0/bin:/pl/bin:/opt/google-cloud-sdk/bin:/opt/gsutil:/opt/node/bin:/opt/phab/arcanist/bin:/usr/lib/go-1.10/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"ENV LD_LIBRARY_PATH /opt/clang-15.0/lib",
"ENV GOPATH /pl",
"ENV CC clang",
"ENV CXX clang++",
"ENV ASAN_SYMBOLIZER_PATH /opt/clang-14.0/bin/llvm-symbolizer",
"ENV ASAN_SYMBOLIZER_PATH /opt/clang-15.0/bin/llvm-symbolizer",
"WORKDIR /pl/src/px.dev/pixie",
"ENTRYPOINT [\"\"]",
"CMD [\"\"]"
Expand Down
Loading

0 comments on commit 3970310

Please sign in to comment.