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

Merge develop to next/kelvin/410 #721

Merged
merged 45 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 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
2e9a5d6
Add debugging instructions
sigilante Jul 26, 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
8c63859
aor jet registration causes segfault
Quodss Jul 31, 2024
76d8326
aor jet
Quodss Jul 31, 2024
1a66d26
aor don't copy
Quodss Jul 31, 2024
3f862f8
len_w
Quodss Jul 31, 2024
2638bc3
inline lth
Quodss Jul 31, 2024
f7fc53c
rollback to copy
Quodss Jul 31, 2024
2be5296
jet fix no copy
Quodss Jul 31, 2024
0c9d768
restore common settings
Quodss Jul 31, 2024
663a54a
optimizations
Quodss Jul 31, 2024
cb13d69
remove helping function
Quodss Jul 31, 2024
f54e671
refactor to follow hoon flow
Quodss Jul 31, 2024
f04a8bc
little endian optimization
Quodss Jul 31, 2024
3ddba6a
length fix, remove dead code
Quodss Aug 5, 2024
d242217
naming conventions
Quodss Aug 5, 2024
5fcf117
Add debugging instructions (#685)
pkova Sep 13, 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
3761ed0
Add stacktrace (#674)
pkova Sep 16, 2024
ded901f
Aor jet (#690)
pkova Sep 25, 2024
736cb64
Merge branch 'next/kelvin/410' into pkova/merge
pkova Sep 27, 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 CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,21 @@ jump to definition, cross-references, hovering, symbol renaming, etc.):
```console
bazel run //bazel:refresh_compile_commands
```

### Debugging

Prefer GDB for interactive debugging. You need to compile with the symbol table:

```bash
bazel build :urbit --compilation_mode=dbg
gdb --args ./bazel-bin/pkg/vere/urbit zod
```

In GDB, set the following, and any breakpoints (e.g. `break u3m_bail`):

```gdb
set follow-fork-mode child
handle SIGSEGV nostop noprint
```

Then run the Urbit program as usual with `r`.
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,17 +34,22 @@ vere_library(
"//pkg/ent",
"//pkg/ur",
"@gmp",
"@libbacktrace",
"@murmur3",
"@openssl",
"@pdjson",
"@sigsegv",
"@softblas",
"@softfloat",
"@urcrypt",
"@whereami",
"@zlib",
] + 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
69 changes: 69 additions & 0 deletions pkg/noun/jets/c/aor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/// @file

#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"

u3_noun
u3qc_aor(u3_noun a,
u3_noun b)
{
while ( 1 ) {
if ( c3y == u3r_sing(a, b) ) return c3y;
if ( c3n == u3ud(a) ) {
if ( c3y == u3ud(b) ) return c3n;
if ( c3y == u3r_sing(u3h(a), u3h(b)) ) {
a = u3t(a);
b = u3t(b);
}
else {
a = u3h(a);
b = u3h(b);
}
}
else {
if ( c3n == u3ud(b) ) return c3y;
{
c3_w len_a_w = u3r_met(3, a);
c3_w len_b_w = u3r_met(3, b);;
c3_y *buf_a_y, *buf_b_y;
c3_y cut_a_y, cut_b_y;
if ( c3y == u3a_is_cat(a) ) {
buf_a_y = (c3_y*)&a;
}
else {
u3a_atom* a_u = u3a_to_ptr(a);
buf_a_y = (c3_y*)(a_u->buf_w);
}
if ( c3y == u3a_is_cat(b) ) {
buf_b_y = (c3_y*)&b;
}
else {
u3a_atom* b_u = u3a_to_ptr(b);
buf_b_y = (c3_y*)(b_u->buf_w);
}
c3_w len_min_w = c3_min(len_a_w, len_b_w);
for (c3_w i_w = 0; i_w < len_min_w; i_w++) {
cut_a_y = buf_a_y[i_w];
cut_b_y = buf_b_y[i_w];
if ( cut_a_y != cut_b_y ) return __(cut_a_y < cut_b_y);
}
return __(len_a_w < len_b_w);
}
}
}
}

u3_noun
u3wc_aor(u3_noun cor)
{
u3_noun a, b;

if ( c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0) ) {
return u3m_bail(c3__exit);
} else {
return u3qc_aor(a, b);
}
}

1 change: 1 addition & 0 deletions pkg/noun/jets/q.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

/** Tier 3.
**/
u3_noun u3qc_aor(u3_atom, u3_atom);
u3_noun u3qc_bex(u3_atom);
u3_noun u3qc_xeb(u3_atom);
u3_noun u3qc_can(u3_atom, u3_noun);
Expand Down
3 changes: 3 additions & 0 deletions pkg/noun/jets/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,8 @@ static u3j_core _138_two__by_d[] =

static u3j_harm _138_two_mate_a[] = {{".2", u3wb_mate, c3y}, {}};

static u3j_harm _138_two_aor_a[] = {{".2", u3wc_aor, c3y}, {}};

static u3j_core _138_two_d[] =
{ { "tri", 3, 0, _138_tri_d, no_hashes, _140_tri_ho },

Expand All @@ -2567,6 +2569,7 @@ static u3j_core _138_two_d[] =
{ "welp", 7, _140_two_welp_a, 0, no_hashes },
{ "zing", 7, _140_two_zing_a, 0, no_hashes },

{ "aor", 7, _138_two_aor_a, 0, no_hashes },
{ "bex", 7, _140_two_bex_a, 0, no_hashes },
{ "cat", 7, _140_two_cat_a, 0, no_hashes },
{ "can", 7, _140_two_can_a, 0, no_hashes },
Expand Down
1 change: 1 addition & 0 deletions pkg/noun/jets/w.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

/** Tier 3.
**/
u3_noun u3wc_aor(u3_noun);
u3_noun u3wc_bex(u3_noun);
u3_noun u3wc_xeb(u3_noun);
u3_noun u3wc_can(u3_noun);
Expand Down
Loading
Loading