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

Add stacktrace #674

Merged
merged 26 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
80fcd54
deps: add libbacktrace
ripperi Jul 5, 2024
c154fd1
build: include debug symbols on all platforms
ripperi Jul 10, 2024
0abc468
manage: print stacktrace in sigsegv signal handler
ripperi Jul 11, 2024
5f8b225
manage: prettify stacktrace
ripperi Jul 11, 2024
f05d5aa
manage: print libbacktrace frames even when symbols were not found
ripperi Jul 11, 2024
0054a12
deps: add libexecinfo for linux
ripperi Jul 12, 2024
e0c2a32
deps: add libunwind for linux
ripperi Jul 18, 2024
94001b5
build: include frame pointers
ripperi Jul 18, 2024
5eeb0f7
manage: unwind backtrace frames with libunwind on linux
ripperi Jul 18, 2024
743987c
deps: remove redundant libexecinfo
ripperi Jul 18, 2024
2d6bbe2
bazel: upgrade gcc and musl in linux toolchain
ripperi Jul 22, 2024
34c9369
build: upgrade musl-cross-make and quick fix libunwind for arm linux
ripperi Jul 22, 2024
f34d5aa
manage: try to resolve symbols with dladdr as a fallback
ripperi Jul 23, 2024
742f14d
manage: move stacktrace printing under `u3m_bail`
ripperi Jul 24, 2024
c590851
actions: rebuild toolchain cache for toolchain upgrade
pkova Jul 24, 2024
1b4c2eb
build: add `configure_options` to libexpat build
ripperi Jul 25, 2024
d01d1d4
actions: set swap on linux
ripperi Jul 25, 2024
cc17895
build: decrease liburcrypt optimization level
ripperi Jul 25, 2024
e5fa962
bazel: bump openssl
pkova Jul 27, 2024
5e6fe6c
Merge remote-tracking branch 'origin/develop' into ripa/stacktrace
pkova Jul 27, 2024
a068cbd
manage: use `fprintf` instead of `u3l_log` for stacktrace
ripperi Jul 30, 2024
6c3103c
Merge branch 'ripa/stacktrace' of https://github.com/urbit/vere into …
pkova Jul 30, 2024
b5d53e2
manage: also print stacktrace on external fault
pkova Sep 16, 2024
d8fba62
manage: general cleanup of the stacktrace code
pkova Sep 16, 2024
62e4cc2
Revert "bazel: bump openssl"
pkova Sep 16, 2024
df8e34e
manage: fix error check in backtrace codepath
pkova Sep 16, 2024
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
29 changes: 28 additions & 1 deletion .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ jobs:
#
- uses: actions/checkout@v3

- name: Set swap space
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
echo "Memory and swap:"
free -h
echo
swapon --show
echo

export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
if test -z "${SWAP_FILE}"; then
export SWAP_FILE=/swapfile
else
sudo swapoff -a
sudo rm "${SWAP_FILE}"
fi
sudo fallocate -l 10G "${SWAP_FILE}"
sudo chmod 600 "${SWAP_FILE}"
sudo mkswap "${SWAP_FILE}"
sudo swapon "${SWAP_FILE}"

echo "Memory and swap:"
free -h
echo
swapon --show
echo

- name: chown /usr/local
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
Expand All @@ -64,7 +91,7 @@ jobs:
- name: Set up build cache
uses: actions/cache@v3
with:
key: ${{ matrix.target }}-cache
key: ${{ matrix.target }}-cache-1
path: |
# # Cache bazel path on Linux.
~/.cache/bazel/_bazel_$(whoami)
Expand Down
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ string_flag(
# Version flag for gcc.
string_flag(
name = "gcc_version",
# musl-cross-make uses `gcc-9.4.0` by default.
build_setting_default = "9.4.0",
# musl-cross-make uses `gcc-11.4.0` by default.
build_setting_default = "11.4.0",
visibility = ["//visibility:public"],
)

Expand Down
18 changes: 18 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,24 @@ versioned_http_file(
version = "255fb1ca8206072f1d09425f0db61ecfe7ff5b17",
)

versioned_http_archive(
name = "libbacktrace",
build_file = "//bazel/third_party/libbacktrace:libbacktrace.BUILD",
sha256 = "609c17352ec38eaf5ff6618fcbfb38cd8fa0e94a15a0d9aa259df514bbf47fcd",
url = "https://github.com/ianlancetaylor/libbacktrace/archive/{version}.tar.gz",
strip_prefix = "libbacktrace-{version}",
version = "4ead348bb45f753121ca0bd44170ff8352d4c514",
)

versioned_http_archive(
name = "libunwind",
build_file = "//bazel/third_party/libunwind:libunwind.BUILD",
sha256 = "ddf0e32dd5fafe5283198d37e4bf9decf7ba1770b6e7e006c33e6df79e6a6157",
url = "https://github.com/libunwind/libunwind/releases/download/v1.8.1/libunwind-1.8.1.tar.gz",
strip_prefix = "libunwind-{version}",
version = "1.8.1",
)

versioned_http_archive(
name = "lmdb",
build_file = "//bazel/third_party/lmdb:lmdb.BUILD",
Expand Down
25 changes: 8 additions & 17 deletions bazel/common_settings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ string_flag = rule(

def vere_library(copts = [], linkopts = [], **kwargs):
native.cc_library(
copts = copts + select({
copts = copts + [
"-fno-omit-frame-pointer",
] + select({
"//:debug": ["-O0", "-g3", "-DC3DBG", "-fdebug-compilation-dir=."],
"//conditions:default": ["-O3"]
"//conditions:default": ["-O3", "-g"]
}) + select({
"//:lto": ['-flto'],
"//:thinlto": ['-flto=thin'],
"//conditions:default": []
}) + select({
# Don't include source level debug info on macOS. See
# https://github.com/urbit/urbit/issues/5561 and
# https://github.com/urbit/vere/issues/131.
"//:debug": [],
"@platforms//os:linux": ["-g"],
"//conditions:default": [],
}),
linkopts = linkopts + ['-g'] + select({
"//:lto": ['-flto'],
Expand All @@ -38,17 +32,14 @@ def vere_library(copts = [], linkopts = [], **kwargs):

def vere_binary(copts = [], linkopts = [], **kwargs):
native.cc_binary(
copts = copts + select({
copts = copts + [
"-fno-omit-frame-pointer",
] + select({
"//:debug": ["-O0", "-g3", "-DC3DBG", "-fdebug-compilation-dir=."],
"//conditions:default": ["-O3"]
"//conditions:default": ["-O3", "-g"]
}) + select({
"//:lto": ['-flto'],
"//:thinlto": ['-flto=thin'],
"//conditions:default": []
}) + select({
"//:debug": [],
"@platforms//os:linux": ["-g"],
"//conditions:default": [],
}),
linkopts = linkopts + ['-g'] + select({
"//:lto": ['-flto'],
Expand Down
6 changes: 6 additions & 0 deletions bazel/third_party/expat/expat.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ configure_make(
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
configure_options = [
] + select({
"@//:linux_aarch64": ["--host=aarch64-linux-musl"],
"@//:linux_x86_64": ["--host=x86_64-linux-musl"],
"//conditions:default": [],
}),
copts = ["-O3"],
lib_source = ":all",
out_static_libs = ["libexpat.a"],
Expand Down
Empty file.
25 changes: 25 additions & 0 deletions bazel/third_party/libbacktrace/libbacktrace.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all",
srcs = glob(["**"]),
)

configure_make(
name = "libbacktrace",
args = [
] + select({
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
configure_options = [
] + select({
"@//:linux_aarch64": ["--host=aarch64-linux-musl"],
"@//:linux_x86_64": ["--host=x86_64-linux-musl"],
"//conditions:default": [],
}),
copts = ["-O3"],
lib_source = ":all",
out_static_libs = ["libbacktrace.a"],
visibility = ["//visibility:public"],
)
Empty file.
25 changes: 25 additions & 0 deletions bazel/third_party/libunwind/libunwind.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all",
srcs = glob(["**"]),
)

configure_make(
name = "libunwind",
args = select({
"@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"],
"//conditions:default": ["--jobs=`nproc`"],
}),
configure_options = [
"--enable-debug-frame",
] + select({
"@//:linux_aarch64": ["--host=aarch64-linux-musl"],
"@//:linux_x86_64": ["--host=x86_64-linux-musl"],
"//conditions:default": [],
}),
copts = ["-O3 -g"],
lib_source = ":all",
out_static_libs = ["libunwind.a"],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion bazel/third_party/urcrypt/urcrypt.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ configure_make(
copts = [
"-Wall",
"-g",
"-O3",
"-O2",
],
deps = [
"@aes_siv",
Expand Down
8 changes: 6 additions & 2 deletions bazel/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ toolchain(
# so introduces a circular dependency during Bazel C/C++ toolchain resolution.

# musl-cross-make builds musl-libc-compatible gcc toolchains from source.
_musl_cross_make_version = "fe915821b652a7fa37b34a596f47d8e20bc72338"
_musl_cross_make_version = "99f2cbc7e230f72bde3394be3ebd50497cb53e89"

_musl_cross_make_archive = "https://github.com/richfelker/musl-cross-make/archive/{}.tar.gz".format(_musl_cross_make_version)
_musl_cross_make_archive = "https://github.com/ripperi/musl-cross-make/archive/{}.tar.gz".format(_musl_cross_make_version)

genrule(
name = "install-aarch64-linux-musl-gcc",
Expand All @@ -349,6 +349,8 @@ genrule(
echo ' tar -xf {}.tar.gz' >> $@
echo ' archive=musl-cross-make-{}' >> $@
echo ' echo OUTPUT=$$aarch64_linux_musl_install > $$archive/config.mak' >> $@
echo ' echo GCC_VER=11.4.0 >> $$archive/config.mak' >> $@
echo ' echo MUSL_VER=1.2.5 >> $$archive/config.mak' >> $@
echo ' TARGET=aarch64-linux-musl make -s -C$$archive -j`nproc`' >> $@
echo ' sudo TARGET=aarch64-linux-musl make -s -C$$archive -j`nproc` install' >> $@
echo ' sudo chown --recursive $$USER $$aarch64_linux_musl_install' >> $@
Expand Down Expand Up @@ -382,6 +384,8 @@ genrule(
echo ' tar -xf {}.tar.gz' >> $@
echo ' archive=musl-cross-make-{}' >> $@
echo ' echo OUTPUT=$$x86_64_linux_musl_install > $$archive/config.mak' >> $@
echo ' echo GCC_VER=11.4.0 >> $$archive/config.mak' >> $@
echo ' echo MUSL_VER=1.2.5 >> $$archive/config.mak' >> $@
echo ' TARGET=x86_64-linux-musl make -s -C$$archive -j`nproc`' >> $@
echo ' sudo TARGET=x86_64-linux-musl make -s -C$$archive -j`nproc` install' >> $@
echo ' sudo chown --recursive $$USER $$x86_64_linux_musl_install' >> $@
Expand Down
7 changes: 6 additions & 1 deletion pkg/noun/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,20 @@ vere_library(
"//pkg/ent",
"//pkg/ur",
"@gmp",
"@libbacktrace",
"@murmur3",
"@openssl",
"@pdjson",
"@sigsegv",
"@softfloat",
"@urcrypt",
"@whereami",
] + select({
"@platforms//os:macos": ["//pkg/noun/platform/darwin"],
"@platforms//os:linux": ["//pkg/noun/platform/linux"],
"@platforms//os:linux": [
"//pkg/noun/platform/linux",
"@libunwind",
],
"//conditions:default": [],
}),
)
Expand Down
Loading
Loading