Skip to content

feat: statically link cpp redist for MSVC target#91

Closed
vytautas-astrauskas-sensmetry wants to merge 1 commit intomainfrom
feat/statically-link-windows-cpp-redist
Closed

feat: statically link cpp redist for MSVC target#91
vytautas-astrauskas-sensmetry wants to merge 1 commit intomainfrom
feat/statically-link-windows-cpp-redist

Conversation

@vytautas-astrauskas-sensmetry
Copy link
Copy Markdown
Collaborator

No description provided.

@andrius-puksta-sensmetry
Copy link
Copy Markdown
Collaborator

Why is this a draft? It passes CI, so presumably works well enough.

Signed-off-by: Vytautas Astrauskas <vytautas.astrauskas@sensmetry.com>
@consideRatio consideRatio force-pushed the feat/statically-link-windows-cpp-redist branch from 9460cce to a741f49 Compare March 10, 2026 10:56
@consideRatio
Copy link
Copy Markdown
Collaborator

For repo hygine - could you provide an update here @vytautas-astrauskas-sensmetry? I'm thinking we want to have this be ready-for-review, or updated PR description on why its stale, or close?

@vytautas-astrauskas-sensmetry
Copy link
Copy Markdown
Collaborator Author

For repo hygine - could you provide an update here @vytautas-astrauskas-sensmetry? I'm thinking we want to have this be ready-for-review, or updated PR description on why its stale, or close?

The current main build needs to be tested on Windows without redist to determine whether changes in this PR are needed.

@consideRatio
Copy link
Copy Markdown
Collaborator

consideRatio commented Mar 18, 2026

@vytautas-astrauskas-sensmetry I ran our CI build for windows, and used the tool dumpbin to inspect things, and chatted with Opus 4.6 about it. I think this won't be needed based on that.


❯ Look at #91, then also consider this output from dumpbin

Will we need to compile statically?

>>> dumpbin /dependents target\release\sysand.exe                                                                                                                         
                                                                                                                                                                          
Dump of file target\release\sysand.exe                                                                                                                                    
                                                                                                                                                                          
File Type: EXECUTABLE IMAGE                                                                                                                                               
                                                                                                                                                                          
  Image has the following dependencies:                                                                                                                                   
                                                                                                                                                                          
    kernel32.dll                                                                                                                                                          
    bcryptprimitives.dll                                                                                                                                                  
    advapi32.dll                                                                                                                                                          
    api-ms-win-core-synch-l1-2-0.dll                                                                                                                                      
    ws2_32.dll                                                                                                                                                            
    ntdll.dll                                                                                                                                                             
    KERNEL32.dll                                                                                                                                                          
    WS2_32.dll                                                                                                                                                            
    shell32.dll                                                                                                                                                           
    ole32.dll                                                                                                                                                             
    crypt32.dll                                                                                                                                                           
    userenv.dll                                                                                                                                                           
                                                                                                                                                                          
  Summary                                                                                                                                                                 
                                                                                                                                                                          
        8000 .data                                                                                                                                                        
        1000 .eh_fram                                                                                                                                                     
        1000 .fptable                                                                                                                                                     
       53000 .pdata                                                                                                                                                       
      417000 .rdata                                                                                                                                                       
       13000 .reloc                                                                                                                                                       
        1000 .rodata                                                                                                                                                      
      A22000 .text                                                                                                                                                        

● Based on the dumpbin output, no, you don't need PR #91's changes — the C++ runtime is already statically linked.

The key evidence: VCRUNTIME140.dll is absent from the dependency list. That's exactly the DLL that PR #91 aims to statically link. If it were dynamically linked, you'd
also typically see ucrtbase.dll and possibly MSVCP140.dll.

All the listed dependencies are standard Windows system DLLs that ship with every Windows installation:

┌──────────────────────────────┬──────────────────────┐
│ DLL │ Ships with │
├──────────────────────────────┼──────────────────────┤
│ kernel32, ntdll │ Windows core │
├──────────────────────────────┼──────────────────────┤
│ advapi32, userenv │ Windows core │
├──────────────────────────────┼──────────────────────┤
│ ws2_32 │ Windows networking │
├──────────────────────────────┼──────────────────────┤
│ shell32, ole32 │ Windows shell/COM │
├──────────────────────────────┼──────────────────────┤
│ crypt32, bcryptprimitives │ Windows crypto │
├──────────────────────────────┼──────────────────────┤
│ api-ms-win-core-synch-l1-2-0 │ API set (Windows 8+) │
└──────────────────────────────┴──────────────────────┘

No Visual C++ Redistributable is required to run this binary. This answers the question Vytautas raised in the PR comment — the current main build doesn't need the
redist, so PR #91 can likely be closed.

❯ Can I see if it is actually statically linked?

● Searched for 3 patterns, read 1 file (ctrl+o to expand)

● Yes — .cargo/config.toml:2 already sets +crt-static for all Windows targets:

[target.'cfg(windows)']
rustflags = ["-Ctarget-feature=+crt-static"]

This is the Rust-level flag that statically links the C runtime. It's why VCRUNTIME140.dll doesn't appear in your dumpbin output. PR #91's linker-level
NODEFAULTLIB/DEFAULTLIB approach is redundant — the same thing is already handled here.

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.

3 participants