-
Notifications
You must be signed in to change notification settings - Fork 43
build: Use nix for building rust and cargo #109
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
base: master
Are you sure you want to change the base?
Conversation
#### Problem
The current build scripts run as normal commands in CI machines, which
means that certain shared libraries are linked into binaries. For the
most part, this is fine, but some binaries, such as `solana-lldb`, have
a few extra shared libs:
```
~/.c/s/v/p/l/bin> ldd lldb
linux-vdso.so.1 (0x00007fea34cba000)
liblldb.so.19.1-rust-dev => /home/jon/.cache/solana/v1.51/platform-tools/llvm/bin/../lib/liblldb.so.19.1-rust-dev (0x00007fea2dc00000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fea2d800000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fea2daf2000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fea2dac5000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fea2d400000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fea34cbc000)
libpython3.10.so.1.0 => not found
libpanel.so.6 => not found
libncurses.so.6 => not found
libtinfo.so.6 => /usr/lib/libtinfo.so.6 (0x00007fea2d791000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007fea2d643000)
libedit.so.2 => not found
liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007fea2d3cc000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007fea2daac000)
libicuuc.so.76 => /usr/lib/libicuuc.so.76 (0x00007fea2d000000)
libicudata.so.76 => /usr/lib/libicudata.so.76 (0x00007fea2b000000)
```
On my local machine, you'll see that a few of these libraries aren't
found. This isn't a good experience for users.
Also, when packaging the platform tools for nix, we have to do a lot of
extra patching:
https://github.com/arijoon/solana-nix/blob/65a7cc4a9fff662fc6077b8b49bca6d3c96883c8/solana-platform-tools.nix#L92
#### Summary of changes
Build rust and cargo using nix, which ensures static linking of
executables. This mostly impacts llvm bins, and the size for all bins is
roughly the same. Some are slightly bigger or smaller, within 1% of the
size.
This will also make it much easier to package the bins in nix.
#### Problem More information at anza-xyz/platform-tools#109, but Rust is currently built with a few additional shared libraries. #### Summary of changes Add a `--nix` flag to build.sh to optionally build with nix-shell.
#### Problem More information at anza-xyz/platform-tools#109, but cargo is currently built with a few shared libraries. #### Summary of changes Add a shell.nix file for creating a nix-shell environment.
#### Problem More information at anza-xyz/platform-tools#109, but cargo is currently built with a few shared libraries. #### Summary of changes Add a shell.nix file for creating a nix-shell environment.
#### Problem More information at anza-xyz/platform-tools#109, but cargo is currently built with a few shared libraries. #### Summary of changes Add a shell.nix file for creating a nix-shell environment.
* build: Add `--nix` flag to build rust in nix-shell #### Problem Recreation of #139. More information at anza-xyz/platform-tools#109, but Rust is currently built with a few additional shared libraries. #### Summary of changes Add a `--nix` flag to build.sh to optionally build with nix-shell. * Wrap arg parsing in while loop
LucasSte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase your branch so that we can test with v1.52?
| - uses: cachix/install-nix-action@v31 | ||
| with: | ||
| toolchain: 1.84.1 | ||
| nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/3250c94d987c5ebcf24a5bfcd3c7de5ec43e3e84.tar.gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for all build targets?
| toolchain: 1.84.1 | ||
| nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/3250c94d987c5ebcf24a5bfcd3c7de5ec43e3e84.tar.gz | ||
| - name: Build | ||
| run: ./build.sh ${{ matrix.out_dir }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are not passing the --nix flag here. Is you idea to build the release binaries using nix?
Problem
The current build scripts run as normal commands in CI machines, which means that certain shared libraries are linked into binaries. For the most part, this is fine, but some binaries, such as
solana-lldb, have a few extra shared libs:On my local machine, you'll see that a few of these libraries aren't found. This isn't a good experience for users.
Also, when packaging the platform tools for nix, we have to do a lot of extra patching:
https://github.com/arijoon/solana-nix/blob/65a7cc4a9fff662fc6077b8b49bca6d3c96883c8/solana-platform-tools.nix#L92
Summary of changes
Build rust and cargo using nix, which ensures static linking of executables. This mostly impacts llvm bins, and the size for all bins is roughly the same. Some are slightly bigger or smaller, within 1% of the size.
This will also make it much easier to package the bins in nix.