Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active April 28, 2023 22:44
Show Gist options
  • Save pojntfx/47e24bc7135b320ec81b46383baa698d to your computer and use it in GitHub Desktop.
Save pojntfx/47e24bc7135b320ec81b46383baa698d to your computer and use it in GitHub Desktop.
Build static cURL binary with HTTP/3 support
# Setup build environment
mkdir -p ~/Projects/curl-http3/prefix
cd ~/Projects/curl-http3
# Build OpenSSL with QUIC support
sudo dnf builddep -y openssl
rm -rf openssl
git clone https://github.com/quictls/openssl
cd openssl
git checkout openssl-3.0.0+quic
./config enable-tls1_3 --prefix=${PWD}/../prefix
make -j$(nproc)
make install
# Build nghttp3
cd ..
rm -rf nghttp3
git clone https://github.com/ngtcp2/nghttp3
cd nghttp3
autoreconf -fi
./configure --prefix=${PWD}/../prefix --enable-lib-only
make -j$(nproc)
make install
# Build ngtcp2
cd ..
rm -rf ngtcp2
git clone https://github.com/ngtcp2/ngtcp2
cd ngtcp2
autoreconf -fi
./configure LDFLAGS="-Wl,-rpath,${PWD}/../prefix/lib64" PKG_CONFIG_PATH=${PWD}/../prefix/lib/pkgconfig:${PWD}/../prefix/lib64/pkgconfig --prefix=${PWD}/../prefix --enable-lib-only
make -j$(nproc)
make install
# Build cURL
sudo dnf builddep -y curl
cd ..
rm -rf curl
git clone https://github.com/curl/curl
cd curl
autoreconf -fi
./configure LDFLAGS="-Wl,-rpath,${PWD}/../prefix/lib64" PKG_CONFIG_PATH=${PWD}/../prefix/lib/pkgconfig:${PWD}/../prefix/lib64/pkgconfig --with-openssl=${PWD}/../prefix --with-nghttp3=${PWD}/../prefix/lib --with-ngtcp2=${PWD}/../prefix/lib --prefix=${PWD}/../prefix
make -j$(nproc)
make install
# Try the dynamically linked version
../prefix/bin/curl --http3 https://cloudflare-quic.com/
# Create and try static binary
sudo dnf install -y binutils patchelf
pip3 install staticx
staticx ../prefix/bin/curl ../prefix/bin/curl.static
../prefix/bin/curl.static --http3 https://cloudflare-quic.com/
# Test the static binary in Alpine for cross-glibc testing
podman run -v ${PWD}/../prefix/bin/:/app/bin:z -it alpine:edge /app/bin/curl.static --http3 https://cloudflare-quic.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment