mp4096 / indentex

An indentation-based superset of LaTeX
MIT License
9 stars 2 forks source link

Static linking of CRT for Windows #26

Closed mp4096 closed 7 years ago

mp4096 commented 7 years ago

Started in #17


We now have to debug why rustc is failing. See the config.

@syxolk Could you dig into this please? I don't have a Win box at hand.

syxolk commented 7 years ago

It worked like this:

rustup default nightly
set "RUSTFLAGS=-C target-feature=+crt-static"
cargo build --release

Running dumpbin.exe /dependents target\release\indentex.exe leads to this output:

Dump of file target\release\indentex.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    ADVAPI32.dll
    USERENV.dll
    SHELL32.dll

  Summary

        2000 .data
        1000 .gfids
        9000 .pdata
       59000 .rdata
        2000 .reloc
      17B000 .text

Compare to this output without RUSTFLAGS:

Dump of file target\release\indentex.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    KERNEL32.dll
    ADVAPI32.dll
    USERENV.dll
    SHELL32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll

  Summary

        1000 .data
        1000 .gfids
        8000 .pdata
       51000 .rdata
        1000 .reloc
      16F000 .text
syxolk commented 7 years ago

It explicitly didn't work for:

syxolk commented 7 years ago

Using the nightly-x86_64-pc-windows-msvc toolchain:

Build type With RUSTFLAGS Without RUSTFLAGS diff
release 1910 KB 1823 KB +87 KB
debug 6474 KB 6384 KB +90 KB
mp4096 commented 7 years ago

Oh, the quotes in Windows command line... I've got bitten by them several times before and should have known better.

And I'm very surprised that it didn't work for stable Rust, it's really weird. However, I'm ok with using nightly for building Windows installs.

mp4096 commented 7 years ago

Nice! https://ci.appveyor.com/project/mp4096/indentex/build/job/ej1lgmg8l411r6xu

mp4096 commented 7 years ago

@syxolk Could you please refactor your current script to PowerShell and add a compilation command to it? Cf. the AppVeyor config.

mp4096 commented 7 years ago

Continued in #31