Re: Update: Minimal libcurl compile for Windows; Missing flags?
Date: Fri, 8 May 2020 01:16:05 -0400
On Fri, May 8, 2020 at 1:14 AM Jeffrey Walton <noloader_at_gmail.com> wrote:
>
> On Thu, May 7, 2020 at 6:46 PM Testing WunTuTri via curl-library
> <curl-library_at_cool.haxx.se> wrote:
> >
> > old thread: https://curl.haxx.se/mail/lib-2020-05/0021.html
> >
> > Hey folks,
> >
> > So I decided to fully commit to the Microsoft compiler, and figure out the flags on the go which disable features I don't need. (99% of them basically)
> >
> > My steps so far:
> > (inside the x64 native tools console on windows)
> > winbuild dir:
> > 1.
> > SET CC=cl /DHTTP_ONLY /DCURL_DISABLE_COOKIES /DCURL_DISABLE_CRYPTO_AUTH /DCURL_DISABLE_VERBOSE_STRINGS /DCURL_DISABLE_DICT /DCURL_DISABLE_FILE /DCURL_DISABLE_MIME /DCURL_DISABLE_HTTP_AUTH /DCURL_DISABLE_PARSEDATE /DCURL_DISABLE_DOH /DCURL_DISABLE_SHUFFLE_DNS /DCURL_DISABLE_PROGRESS_METER /DCURL_DISABLE_LIBCURL_OPTION /DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG /DCURL_DISABLE_NETRC
> >
> > 2.
> > nmake /f Makefile.vc mode=static ENABLE_SSPI=no ENABLE_IPV6=no ENABLE_IDN=no ENABLE_WINSSL=no GEN_PDB=no DEBUG=no MACHINE=x64
> >
> > This yields libcurl_a.lib which is 718kb in size(2x smaller than the default compile), WHICH ALSO WORKS for my project!! Thanks to Ray Satiro
> >
> > I've tried grep searches on the root curl-7.70.0 folder;
> >
> > grep -r -i "CURL_DISABLE_" .
> >
> > But I haven't found anything that I already haven't used. Since documentation says I can make my lib as small as 90kb I guess I'm still missing something.
> > This can also be seen by comparing MINGW additional .configure flags to the MSVC flags, which I haven't found
> >
> > ./configure --disable-ares --disable-ipv6 --disable-manual --disable-verbose --disable-versioned-symbols --enable-symbol-hiding --without-libidn --without-librtmp --without-ssl --without-zlib --without-libidn2 --disable-pthreads --without-libmetalink --disable-unix-sockets --without-strerror --disable-warnings
> >
> > So my question would be, do you fine folks know if there are any more MSVC flags I could use to make the static library even smaller?
>
> Typically you don't worry about the static library size. It can be as
> big or as small as it needs to be.
>
> If you are worried about the final executable size after linking, then
> you allow the linker to discard unused symbols. Below are the options
> to do it.
>
> Using GCC on Linux:
>
> CFLAGS= -ffunction-sections -fdata-sections
> LDFLAGS= -Wl,--gc-sections -Wl,--exclude-libs,ALL
>
> Using Clang on OS X:
>
> CFLAGS= -ffunction-sections -fdata-sections
> LDFLAGS= -Wl,-dead_strip
>
> Using MSVC:
>
> CFLAGS= /Gy
> LDFLAGS=/OPT:REF
This might also help:
https://devblogs.microsoft.com/cppblog/optimizing-c-code-dead-code-elimination/
Jeff
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-05-08