Skip to content

Instantly share code, notes, and snippets.

@bagder
Last active January 9, 2024 08:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagder/4d3e326b395f7706e550f68fcfe8ccc7 to your computer and use it in GitHub Desktop.
Save bagder/4d3e326b395f7706e550f68fcfe8ccc7 to your computer and use it in GitHub Desktop.
build a tiny curl (on Linux)
#!/bin/sh
export CFLAGS="-Os -ffunction-sections -fdata-sections -fno-unwind-tables -fno-asynchronous-unwind-tables -flto"
export LDFLAGS="-Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections"
./configure \
--disable-cookies \
--disable-crypto-auth \
--disable-dict \
--disable-file \
--disable-ftp \
--disable-gopher \
--disable-imap \
--disable-ldap \
--disable-mqtt \
--disable-pop3 \
--disable-proxy \
--disable-rtmp \
--disable-rtsp \
--disable-scp \
--disable-sftp \
--disable-smtp \
--disable-telnet \
--disable-tftp \
--disable-unix-sockets \
--disable-verbose \
--disable-versioned-symbols \
--disable-http-auth \
--disable-doh \
--disable-mime \
--disable-dateparse \
--disable-netrc \
--disable-dnsshuffle \
--disable-progress-meter \
--enable-maintainer-mode \
--enable-werror \
--without-brotli \
--without-gssapi \
--without-libidn2 \
--without-libpsl \
--without-librtmp \
--without-libssh2 \
--without-nghttp2 \
--without-ntlm-auth \
--without-ssl \
--without-zlib \
--without-zstd \
--with-wolfssl=[install prefix]
@vrischmann
Copy link

Thank you !

If anyone sees this right now:

  • --without-libmetalink doesn't work anymore (configure: error: --with-libmetalink no longer works!)
  • you might also want to disable zstd with --without-zstd and mqtt with --disable-mqtt

@abitrolly
Copy link

What is the name of resulting binary? Is it possible to package it without conflicting with curl?

@bagder
Copy link
Author

bagder commented Jan 2, 2022

@abitrolly it's a curl build, the output is a libcurl library and a curl executable.

@abitrolly
Copy link

@bagder thanks for the clarification. I thought is a parallel tool with less dependencies and attack surface.

@maggie44
Copy link

maggie44 commented Mar 13, 2022

I ran the build in an Alpine Linux container and the output is 4.9M. That's bigger than I had expected.

Edit: Of the output looks like only the curl file and lib/libcurl.so.4 were required. Brought the size down to 300k.

@slugvision
Copy link

Hi Does tinycurl my target architecture (e.g., ARM Cortex-M0+ for Raspberry Pi Pico)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment