moparisthebest / static-curl

fully static builds of curl, runs anywhere
https://code.moparisthebest.com/moparisthebest/static-curl
MIT License
497 stars 30 forks source link

http3 support #2

Closed ghost closed 2 years ago

ghost commented 2 years ago

I suggest you add http3 support, here are the instructions from me:

###You need Rust 1.53+ and maybe Go
###https://forge.rust-lang.org/infra/other-installation-methods.html#standalone
###you can use Rust from repository of your distribution, if it is new enough
###cargo-rust will automatically download also boringssl (Go version of ssl from Google)
###I assume that your home folder is /home/user

###Install Rust (by default in /usr/local):
sudo sh install.sh --help
sudo sh install.sh --list-components
sudo sh install.sh --without=rust-docs --verbose

###quiche build:
git clone --recursive https://github.com/cloudflare/quiche
cd /home/user/quiche
cargo build --examples --release --features ffi,pkg-config-meta,qlog

###files:
/home/user/quiche/target/release/deps/libquiche.a
/home/user/quiche/include/quiche.h
/home/user/quiche/target/release/quiche.pc
/home/user/quiche/target/release/build/quiche-6088af8cd6db4be5/out/build/libssl.a
/home/user/quiche/target/release/build/quiche-6088af8cd6db4be5/out/build/libcrypto.a
/home/user/quiche/deps/boringssl/src/include/openssl

###copy to (if they are not there):
/home/user/quiche/target/release/lib/libquiche.a
/home/user/quiche/target/release/include/quiche.h
/home/user/quiche/target/release/quiche.pc
/home/user/quiche/deps/boringssl/src/lib/libssl.a
/home/user/quiche/deps/boringssl/src/lib/libcrypto.a
/home/user/quiche/deps/boringssl/src/include/openssl

###strip a and so files (optional, parameter --strip-unneeded, not --strip-all)
###rust files are very large before stripping
###remove libquiche.so, otherwise there will be a shared dependency on it
###curl static build requires libquiche.a, not libquiche.so

###in quiche.pc change paths to:
includedir=/home/user/quiche/target/release/include
libdir=/home/user/quiche/target/release/lib
###curl build:
###curl compiles with boringssl instead of openssl, but that's ok
cd /home/user/curl
./configure --help

./configure --prefix=/opt/curl-quiche-custom --disable-shared --enable-static --enable-silent-rules --enable-optimize --disable-debug --disable-curldebug --disable-versioned-symbols --disable-manual --enable-http --enable-ftp --enable-file --enable-rtsp --enable-proxy --enable-pop3 --enable-imap --enable-smtp --disable-ipv6 --enable-threaded-resolver --enable-cookies --enable-http-auth --enable-doh --enable-progress-meter --enable-alt-svc --disable-hsts --disable-gopher --with-zlib --with-brotli --with-zstd --with-random=/dev/urandom --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt --with-ca-path=/etc/ssl/certs --with-ca-fallback --with-librtmp --with-nghttp2 --without-libidn2 --with-ssl=/home/user/quiche/deps/boringssl/src --with-quiche=/home/user/quiche/target/release

make
sudo make install
sudo strip --strip-unneeded /opt/curl-quiche-custom/bin/curl

###cleaning:
rm -rdf /home/user/quiche
rm -rdf /home/user/curl
rm -rdf /home/user/.cargo
###everything else except the curl binary can be deleted
###libquiche.a, libssl.a and libcrypto.a will be embedded in the curl binary
###to build curl you only need 6 items (in /home/user/quiche) listed above
###after building quiche rust compiler can be removed: sudo sh /usr/local/lib/rustlib/uninstall.sh

###check:
curl --http3 -I https://cloudflare-quic.com/

###Instead of quiche, there is an alternative (complicated) method to install http3 support in curl:
###with nghttp3, ngtcp2 and openssl-quic, but this requires c++17, unlike quiche
###I will not describe it

Based on this.

ghost commented 2 years ago

You have to adapt the instructions to be fully static, of course. I don't use it. And other libs.

moparisthebest commented 2 years ago

Unless there is a very good reason to diverge I pretty much plan to keep static-curl's configure options in sync with curl-docker's configure options