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

Deprecate zigbuild and glibc in favor of static musl binaries for Linux builds. #541

Merged
merged 76 commits into from
Sep 5, 2024

Conversation

starkbamse
Copy link
Collaborator

@starkbamse starkbamse commented Sep 3, 2024

What is this
This PR replaces current ways to build linux binaries (zigbuild) with a musl build using custom built OpenSSL and CTNG musl toolchains.

How
We utilize ctng to generate a musl toolchain using a configuration which includes libstdc++, a requirement by RocksDB. This allows us to compile OpenSSL and rusty-kaspa against musl.

Tests performed
Ran by two testers in #qa for two days.

Why do we need it
We need it because on certain machines (Ubuntu 22.04.1 LTS) when running TN10 we get a segmentation fault with the following backtrace snippet:

Core was generated by `./kaspad17800141 --testnet --utxoindex --disable-upnp --ram-scale=0.8 --appdir'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  rocksdb::CoreLocalArray<rocksdb::ConcurrentArena::Shard>::AccessElementAndIndex (this=0x48) at rocksdb/util/core_local.h:73
73  rocksdb/util/core_local.h: No such file or directory.
[Current thread is 1 (LWP 710665)]
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/starkbamse/coredump-old-rust/kaspad1780.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) bt
#0  rocksdb::CoreLocalArray<rocksdb::ConcurrentArena::Shard>::AccessElementAndIndex (this=0x48) at rocksdb/util/core_local.h:73
#1  rocksdb::ConcurrentArena::Repick (this=0x0) at rocksdb/memory/concurrent_arena.cc:38
#2  0x00005c0fbe499273 in rocksdb::ConcurrentArena::AllocateImpl<rocksdb::ConcurrentArena::AllocateAligned(unsigned long, unsigned long, rocksdb::Logger*)::{lambda()#1}>(unsigned long, bool, rocksdb::ConcurrentArena::AllocateAligned(unsigned long, unsigned long, rocksdb::Logger*)::{lambda()#1} const&) (this=0x471e51638a0, bytes=56, force_arena=<optimized out>, func=...)

Cache updates
You can trigger a cache update by updating the preset.sh. Both Actions, and the build.sh script keep track of the latest hash and rebuild in the case of a mismatch.

Considerations:
Performance, could be worse if areas where performance is crucial utilize C memory allocators. It is planned to maybe replace the allocator with mimalloc to solve this problem.

@starkbamse starkbamse changed the title Goodbye zigbuild hello musl Deprecate zigbuild and glibc in favor of static musl binaries for Linux builds. Sep 4, 2024
@starkbamse starkbamse marked this pull request as draft September 4, 2024 09:10
@starkbamse starkbamse assigned starkbamse and unassigned starkbamse Sep 5, 2024
musl-toolchain/build.sh Outdated Show resolved Hide resolved
musl-toolchain/build.sh Outdated Show resolved Hide resolved
musl-toolchain/build.sh Outdated Show resolved Hide resolved
Copy link
Member

@elichai elichai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! THis looks great now :)

@michaelsutton michaelsutton merged commit 06a874f into kaspanet:dev Sep 5, 2024
6 checks passed
michaelsutton added a commit to michaelsutton/rusty-kaspa that referenced this pull request Sep 6, 2024
commit afbcf9e
Author: starkbamse <139136798+starkbamse@users.noreply.github.com>
Date:   Fri Sep 6 05:40:53 2024 +0200

    Change directory back to repo root & Fix Rust v1.81 lints (kaspanet#545)

    * Change directory back to repodir

    Change directory back to repodir after building toolchain

    * Clippy

    * Update crypto/txscript/src/caches.rs

    Co-authored-by: Maxim <59533214+biryukovmaxim@users.noreply.github.com>

    * Update crypto/txscript/src/caches.rs

    * rename `is_none_or` -> `is_none_or_ex` to avoid conflict with future std

    * remove `use std::mem::size_of` wherever possible (added to std prelude recently)

    ---------

    Co-authored-by: Maxim <59533214+biryukovmaxim@users.noreply.github.com>
    Co-authored-by: Michael Sutton <msutton@cs.huji.ac.il>

commit 06a874f
Author: starkbamse <139136798+starkbamse@users.noreply.github.com>
Date:   Thu Sep 5 18:51:04 2024 +0200

    Deprecate zigbuild and glibc in favor of static musl binaries for Linux builds. (kaspanet#541)

    * CTNG Config file, Musl build instructions

    - Crosstools-ng configuration file for quick reproducable builds on musl.
    - Instructions for how to build RK on musl.

    * Test

    * Update ci.yaml

    * Test crosstools install

    * Cache ct-ng build

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Fix error in command

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Comments, naming

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Merge new musl build with old CI, Release builds

    - Merges the old CI script with the new musl build.
    - Update deploy.yaml to use updated musl toolchain to build musl target for linux.

    * Move to workspace

    * Delete musl-build.md

    * Lock to ctng version 1.26

    * Checkout fix

    * Revert master change

    * Indentation

    * Revert "Indentation"

    This reverts commit 6a7e6c0.

    * Revert "Revert master change"

    This reverts commit 1a047e4.

    * Update ci.yaml

    * Force mimalloc

    * Compress into script

    * Fix typo

    * Update build.sh

    * Replace bloaded config file

    * Update build.sh

    * Update build.sh

    * Source script

    * Revert vendor

    * Update defconfig

    * Update defconfig

    * Update defconfig

    * Update build.sh

    * Update build.sh

    * Update build.sh

    * Update build.sh

    * Update defconfig

    * Delete defconfig

    * Create defconfig

    * Update build.sh

    * Deprecate config, use default preset

    * Update build.sh

    * Add preset hash logic in script

    * Move preset hash update

    Move preset hash update after openssl build

    * Use openssl crate

    * Update exports, cache config

    * Remove spaces in export command

    * Update names

    Should not trigger cache

    * Move source preset

    * CD before preset

    * Add comment

    Adds comment and should invalidate cache.

commit b04092e
Author: aspect <anton.yemelyanov@gmail.com>
Date:   Thu Sep 5 18:00:24 2024 +0300

    add proxy limit field to sysinfo (kaspanet#544)

commit f866dfa
Author: Michael Sutton <msutton@cs.huji.ac.il>
Date:   Thu Sep 5 14:04:16 2024 +0300

    Various miscellaneous changes towards 0.15.1 RC2 (kaspanet#543)

    * infrequent logs should be debug

    * cleanup some todos

    * when a network starts, genesis has a body, so there's no need for a special exception

    * remove unneeded method and add an error just in case it is added in the future

    * count and log chain disqualified blocks

    * count and log mempool evictions

    * bump version to 0.14.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants