From 0ab82474d449b7f2ea0d43451fd3951ebd49ddc3 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 21 Jul 2021 07:33:35 -0400 Subject: [PATCH] Fix static building for 7.78.0 --- build.sh | 11 +++++++++-- static.patch | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 static.patch diff --git a/build.sh b/build.sh index 10772b0..8fa4357 100755 --- a/build.sh +++ b/build.sh @@ -40,8 +40,14 @@ apk add openssl-libs-static zlib-static || true # gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang export CC=clang +# temp patch so it will build statically https://github.com/curl/curl/pull/7476 +patch -p1 < ../static.patch +apk add autoconf automake libtool +autoreconf -fi +# end temp patch + # set up any required curl options here -#LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-libcurl-option --without-brotli --disable-manual --disable-unix-sockets --disable-dict --disable-file --disable-gopher --disable-imap --disable-smtp --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --without-zlib --disable-threaded-resolver --disable-ipv6 --disable-smb --disable-ntlm-wb --disable-tls-srp --disable-crypto-auth --with-ssl +#LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-libcurl-option --without-brotli --disable-manual --disable-unix-sockets --disable-dict --disable-file --disable-gopher --disable-imap --disable-smtp --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --without-zlib --disable-threaded-resolver --disable-ipv6 --disable-smb --disable-ntlm-wb --disable-tls-srp --disable-crypto-auth --without-ngtcp2 --without-nghttp2 --disable-ftp --disable-mqtt --disable-alt-svc --without-ssl LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-ldap --enable-ipv6 --enable-unix-sockets --with-ssl --with-libssh2 @@ -53,7 +59,8 @@ strip src/curl # print out some info about this, size, and to ensure it's actually fully static ls -lah src/curl file src/curl -ldd src/curl || true +# exit with error code 1 if the executable is dynamic, not static +ldd src/curl && exit 1 || true ./src/curl -V diff --git a/static.patch b/static.patch new file mode 100644 index 0000000..d191bd9 --- /dev/null +++ b/static.patch @@ -0,0 +1,14 @@ +diff --git a/src/Makefile.am b/src/Makefile.am +index 734373187..37e3a1564 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -66,6 +66,9 @@ else + curl_LDADD = $(top_builddir)/lib/libcurl.la @NSS_LIBS@ @SSL_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@ + endif + ++curl_LDFLAGS = $(curl_LDFLAGS) ++curl_CPPFLAGS = $(AM_CPPFLAGS) ++ + # if unit tests are enabled, build a static library to link them with + if BUILD_UNITTESTS + noinst_LTLIBRARIES = libcurltool.la