runestubbe / Crinkler

Crinkler is an executable file compressor (or rather, a compressing linker) for compressing small 32-bit Windows demoscene executables. As of 2020, it is the most widely used tool for compressing 1k/4k/8k intros.
http://crinkler.net/
Other
1.05k stars 53 forks source link

Crinkler crashes #13

Closed ottozumkeller closed 2 years ago

ottozumkeller commented 2 years ago

I was trying to compress a application using the following commands:

cl /c /O1 /GS- main.c crinkler /nodefaultlib /entry:main /subsystem:console /out:tiktak.exe main.obj kernel32.lib user32.lib ucrt.lib libcmt.lib libucrt.lib libvcruntime.lib

Crinkler tries to link the libraries but crashes. Here are the dump + obj files. dump-files.zip Hope that helps finding the issue.

askeksa commented 2 years ago

Hi Otto

The last four library files you are linking to contain the statically linked C/C++ runtime, which is a very big piece of code. Crinkler is not designed to work for such big executables.

Leaving out the runtime libraries and removing the /NODEFAULTLIB option (to implicitly link to msvcrt.dll) shows that your code is close to being able to get all of its necessary runtime support functions from msvcrt.dll. Just three missing:

MAIN.OBJ: _main: error LNK: Cannot find symbol '___acrt_iob_func'
MAIN.OBJ: _printf: error LNK: Cannot find symbol '___acrt_iob_func'
MAIN.OBJ: _scanf_s: error LNK: Cannot find symbol '___acrt_iob_func'
MAIN.OBJ: __vfprintf_l: error LNK: Cannot find symbol '___stdio_common_vfprintf'
MAIN.OBJ: __vfscanf_s_l: error LNK: Cannot find symbol '___stdio_common_vfscanf'

You might be able to get rid of those dependencies by tweaking your code and experimenting with MSVC options.

arizvisa commented 2 years ago

perhaps something like https://github.com/Chuyu-Team/VC-LTL or https://github.com/Chuyu-Team/VC-LTL5 if you still need some of that runtime.

ottozumkeller commented 2 years ago

In fact, I have found a solution myself: Probably my mistake was that I used VS 2022, so I installed VS 2019. And then everything worked perfectly. Maybe Visual Studio is just too new or uses some overloaded library. Many thanks for your help, Crinkler is a really cool tool.

askeksa commented 2 years ago

Good to hear that switching to 2019 fixed the problem.

And thanks @arizvisa for the link. Very interesting.