Skip to content

Commit

Permalink
Merge branch 'next/kelvin/411' into yu/stun
Browse files Browse the repository at this point in the history
  • Loading branch information
yosoyubik committed Dec 6, 2023
2 parents 2901a18 + e216586 commit 32843ba
Show file tree
Hide file tree
Showing 60 changed files with 572 additions and 2,227 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/docker-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ jobs:
- name: Install toolchains
if: steps.build-cache.outputs.cache-hit != 'true'
run: bazel run //bazel/toolchain:x86_64-linux-musl-gcc
run: |
bazel run //bazel/toolchain:x86_64-linux-musl-gcc
- name: Install dependencies
run: sudo apt-get install -y autoconf-archive

- name: Set pace
run: echo "${{ inputs.pace }}" > ./PACE
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# runner with BuildJet instead.
- { target: linux-aarch64, runner: buildjet-2vcpu-ubuntu-2204-arm }
- { target: linux-x86_64, runner: ubuntu-22.04 }
# GitHub doesn't provide macOS machines with Apple Silicon, so we
# GitHub doesn't provide macOS machines with Apple Silicon, so we
# self-host a runner with MacStadium instead.
- { target: macos-aarch64, runner: [self-hosted, macos, ARM64] }
- { target: macos-x86_64, runner: macos-12 }
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
/private/var/tmp/_bazel_$(whoami)
# Cache musl libc toolchains.
/usr/local/*-musl
- name: chown /usr/local/*-musl
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
Expand Down Expand Up @@ -113,17 +113,20 @@ jobs:
run: |
case "${{ matrix.target }}" in
"linux-aarch64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:aarch64-linux-musl-gcc
;;
"linux-x86_64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:x86_64-linux-musl-gcc
;;
"macos-aarch64")
brew install pkg-config autoconf-archive
;;
"macos-x86_64")
# Switch Xcode path to match the path specified in our bazel toolchain.
sudo xcode-select --switch /Library/Developer/CommandLineTools
brew install automake libtool llvm@15
brew install automake autoconf-archive libtool llvm@15
;;
*)
echo "Unsupported target: ${{ matrix.target }}"
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This will take a few minutes.

### macOS

After installing `automake` and `libtool`, you're ready to build Vere.
After installing `automake`, `autoconf-archive`, `pkg-config`, and `libtool`, you're ready to build Vere.

## Build Commands

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ defined in its own package:

- [`pkg/c3`](pkg/c3): A set of basic utilities for writing Urbit's style of C.
- [`pkg/ent`](pkg/ent): A cross-platform wrapper for `getentropy(2)`.
- [`pkg/urcrypt`](pkg/urcrypt): A standardized interface for calling various
cryptographic functions used in the Urbit runtime.
- [`pkg/ur`](pkg/ur): An implementation of [jam][jam] and [cue][cue], Urbit's
bitwise noun serialization and deserialization algorithms, respectively.
- [`pkg/noun`](pkg/noun): The Nock virtual machine and snapshotting system.
Expand Down
50 changes: 9 additions & 41 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ versioned_http_archive(
version = "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b",
)

versioned_http_archive(
name = "argon2",
build_file = "//bazel/third_party/argon2:argon2.BUILD",
sha256 = "40850e6e6324be10f14228d17b617ad2074bb926eeddd6fe40ad5df833833949",
strip_prefix = "argon2-{version}",
url = "https://github.com/urbit/argon2/archive/{version}.tar.gz",
version = "a4c1e3f7138c2e577376beb99f964cf71e1c8b1b",
)

versioned_http_archive(
name = "bazel_gazelle",
sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3",
Expand All @@ -154,15 +145,6 @@ versioned_http_archive(
version = "7.85.0",
)

versioned_http_archive(
name = "ed25519",
build_file = "//bazel/third_party/ed25519:ed25519.BUILD",
sha256 = "373923c85f61276e3cad2c0ae7a5d5cd4809ffe46c5abc1dc8276683a55782a0",
strip_prefix = "ed25519-{version}",
url = "https://github.com/orlp/ed25519/archive/{version}.tar.gz",
version = "7fa6712ef5d581a6981ec2b08ee623314cd1d1c4",
)

versioned_http_archive(
name = "gmp",
build_file = "//bazel/third_party/gmp:gmp.BUILD",
Expand Down Expand Up @@ -214,17 +196,6 @@ versioned_http_file(
version = "255fb1ca8206072f1d09425f0db61ecfe7ff5b17",
)

versioned_http_archive(
name = "keccak_tiny",
build_file = "//bazel/third_party/keccak_tiny:keccak_tiny.BUILD",
patch_args = ["-p1"],
patches = ["//bazel/third_party/keccak_tiny:{version}.patch"],
sha256 = "6d4717f96b84805886c74bad89e911076664d992f197634fd7cdfca2ac0f62ef",
strip_prefix = "keccak-tiny-{version}",
url = "https://github.com/coruus/keccak-tiny/archive/{version}.tar.gz",
version = "64b6647514212b76ae7bca0dea9b7b197d1d8186",
)

versioned_http_archive(
name = "lmdb",
build_file = "//bazel/third_party/lmdb:lmdb.BUILD",
Expand Down Expand Up @@ -272,18 +243,6 @@ versioned_http_archive(
version = "67108d883061043e55d0fb13961ac1b6fc8a485c",
)

versioned_http_archive(
name = "scrypt",
build_file = "//bazel/third_party/scrypt:scrypt.BUILD",
sha256 = "df681fb19b653b1a12970ebb6091bb2b58411b9e7baf01143870f6be3f099541",
strip_prefix = "libscrypt-{version}",
url = "https://github.com/technion/libscrypt/archive/{version}.tar.gz",
# When bumping the version, compare `Makefile` in the `scrypt` repo to
# {build_file} and confirm that {build_file} remains an accurate description
# of the scrypt build process.
version = "60e585cdd752262b22ed4113eca41c0461a61608",
)

versioned_http_archive(
name = "secp256k1",
build_file = "//bazel/third_party/secp256k1:secp256k1.BUILD",
Expand Down Expand Up @@ -337,6 +296,15 @@ versioned_http_file(
version = "ea8fee3aa0434d4bdf1bf785e5ec346c7ecba7fd",
)

versioned_http_archive(
name = "urcrypt",
build_file = "//bazel/third_party/urcrypt:urcrypt.BUILD",
sha256 = "afc1182e10eeebaeb2a111c2bd889747792d255e26aba7fdcd6751d0d3c2bb35",
strip_prefix = "urcrypt-{version}",
url = "https://github.com/urbit/urcrypt/archive/{version}.tar.gz",
version = "43479c3262a11e20da5f6218f3b0b3d63931ceea",
)

versioned_http_archive(
name = "uv",
build_file = "//bazel/third_party/uv:uv.BUILD",
Expand Down
3 changes: 1 addition & 2 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ refresh_compile_commands(
"//pkg/ent",
"//pkg/noun",
"//pkg/ur",
"//pkg/urcrypt",
"//pkg/vere:urbit",
],
# No need to add flags already in .bazelrc. They're automatically picked up.
# If you don't need flags, a list of targets is also okay, as is a single target string.
# Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
# As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
# And if you're working on a header-only library, specify a test or binary target that compiles it.
)
)
Empty file.
28 changes: 28 additions & 0 deletions bazel/third_party/urcrypt/urcrypt.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

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

configure_make(
name = "urcrypt",
autogen = True,
configure_in_place = True,
configure_options = [
"--disable-shared",
],
copts = [
"-Wall",
"-g",
"-O3",
],
deps = [
"@aes_siv",
"@openssl",
"@secp256k1"
],
lib_source = ":all",
out_static_libs = ["liburcrypt.a"],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion pkg/noun/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ vere_library(
"//pkg/c3",
"//pkg/ent",
"//pkg/ur",
"//pkg/urcrypt",
"@gmp",
"@murmur3",
"@openssl",
"@pdjson",
"@sigsegv",
"@softfloat",
"@urcrypt",
] + select({
"@platforms//os:macos": ["//pkg/noun/platform/darwin"],
"@platforms//os:linux": ["//pkg/noun/platform/linux"],
Expand Down
25 changes: 25 additions & 0 deletions pkg/noun/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,31 @@ u3h_take(u3p(u3h_root) har_p)
return u3h_take_with(har_p, u3a_take);
}

/* _ch_take_uni_cb(): take a key/value pair, put into [dst_p].
*/
static void
_ch_take_uni_cb(u3_cell kev, void* wit)
{
u3a_cell* kev_u = u3a_to_ptr(kev);
u3_noun key = u3a_take(kev_u->hed);
u3_noun val = u3a_take(kev_u->tel);

{
u3p(u3h_root) dst_p = *(u3p(u3h_root)*)wit;
u3h_put(dst_p, key, val);
}

u3z(key);
}

/* u3h_take_uni(): take entries from [src_p], put into [dst_p].
*/
void
u3h_take_uni(u3p(u3h_root) dst_p, u3p(u3h_root) src_p)
{
u3h_walk_with(src_p, _ch_take_uni_cb, &dst_p);
}

/* _ch_mark_buck(): mark bucket for gc.
*/
c3_w
Expand Down
5 changes: 5 additions & 0 deletions pkg/noun/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@
u3p(u3h_root)
u3h_take(u3p(u3h_root) har_p);

/* u3h_take_uni(): take entries from [src_p], put into [dst_p].
*/
void
u3h_take_uni(u3p(u3h_root) dst_p, u3p(u3h_root) src_p);

/* u3h_wyt(): number of entries
*/
c3_w
Expand Down
Loading

0 comments on commit 32843ba

Please sign in to comment.