- 
                Notifications
    You must be signed in to change notification settings 
- Fork 42
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
          
     Open
      
      
            joncinque
  wants to merge
  1
  commit into
  anza-xyz:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
joncinque:nix-build
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    #### 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.
    
    
  joncinque 
      added a commit
        to joncinque/rust
      that referenced
      this pull request
    
      Sep 22, 2025 
    
    
      
  
    
      
    
  
#### 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.
    
  joncinque 
      added a commit
        to joncinque/cargo
      that referenced
      this pull request
    
      Sep 22, 2025 
    
    
      
  
    
      
    
  
#### 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.
    
  joncinque 
      added a commit
        to joncinque/cargo
      that referenced
      this pull request
    
      Oct 15, 2025 
    
    
      
  
    
      
    
  
#### 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.
    
  LucasSte 
      pushed a commit
        to anza-xyz/cargo
      that referenced
      this pull request
    
      Oct 17, 2025 
    
    
      
  
    
      
    
  
#### 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.
    
  LucasSte 
      pushed a commit
        to anza-xyz/rust
      that referenced
      this pull request
    
      Oct 17, 2025 
    
    
      
  
    
      
    
  
* 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
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
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.