Skip to content

Build with static libcurl-gnutls #3

Description

@gleblagov

Hi! We are trying to build HAProxy 3.4.0 with otel-filter while keeping the minimal count of dynamically linked dependencies.

Current build layout:

├── opentelemetry-cpp-install.patch # will be discussed below
├── prefix # statically built dependencies
│   ├── curl
│   ├── lua
│   ├── openssl
│   ├── otel
│   └── zlib
└── src # sources to build from
    ├── curl
    ├── haproxy
    ├── haproxy-opentelemetry
    ├── lua-5.4.6
    ├── openssl-3.5.8
    ├── opentelemetry-c-wrapper
    └── zlib-1.3.2

The wrapper dependencies are built with:

./build-bundle.sh "$DEPS_PREFIX/otel" / static

And the wrapper is built with:

./configure --prefix="$DEPS_PREFIX/otel" --with-opentelemetry="$DEPS_PREFIX/otel" --disable-shared
make -j$(nproc)

We then build HAProxy with (export DEPS_PREFIX="$HOME/haproxy-static/prefix"):

PKG_CONFIG_PATH="$DEPS_PREFIX/otel/lib/pkgconfig" make -j$(nproc) TARGET=linux-glibc \
USE_STATIC_PCRE2=1 \
USE_PCRE2=1 \
USE_PCRE2_JIT=1 \
USE_LUA=1 \
USE_PROMEX=1 \
USE_OPENSSL=1 \
SSL_INC=$DEPS_PREFIX/openssl/include \
SSL_LIB=$DEPS_PREFIX/openssl/lib64 \
LUA_INC=$DEPS_PREFIX/lua/include \
LUA_LIB=$DEPS_PREFIX/lua/lib \
LUA_LIB_NAME=lua \
USE_ZLIB=1 \
ZLIB_INC=$DEPS_PREFIX/zlib/include \
ZLIB_LIB=$DEPS_PREFIX/zlib/lib \
EXTRA_MAKE=../haproxy-opentelemetry \
OTEL_STATIC=1 \
ARCH_FLAGS="-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wdeclaration-after-statement -Wno-address-of-packed-member -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wno-missing-field-initializers -Wno-stringop-overflow -Wno-cast-function-type -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 -Wduplicated-cond -Wnull-dereference"

However, the resulting HAProxy binary still has a dynamic dependency on the system libcurl-gnutls.so

For example, output of lddtree haproxy:

haproxy (interpreter => /lib64/ld-linux-x86-64.so.2)
    libcurl-gnutls.so.4 => /lib/x86_64-linux-gnu/libcurl-gnutls.so.4
        libnghttp3.so.9 => /lib/x86_64-linux-gnu/libnghttp3.so.9
        libngtcp2_crypto_gnutls.so.8 => /lib/x86_64-linux-gnu/libngtcp2_crypto_gnutls.so.8
        libngtcp2.so.16 => /lib/x86_64-linux-gnu/libngtcp2.so.16
        libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14
        libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0
            libunistring.so.5 => /lib/x86_64-linux-gnu/libunistring.so.5
        librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1
            libhogweed.so.6 => /lib/x86_64-linux-gnu/libhogweed.so.6
            libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10
        libssh2.so.1 => /lib/x86_64-linux-gnu/libssh2.so.1
            libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3
        libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5
        libnettle.so.8 => /lib/x86_64-linux-gnu/libnettle.so.8
        libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30
            libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0
                libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8
            libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6
        libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2
            libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3
                libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1
                libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2
            libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3
            libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2
            libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0
        libldap.so.2 => /lib/x86_64-linux-gnu/libldap.so.2
            libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2
            libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3
        liblber.so.2 => /lib/x86_64-linux-gnu/liblber.so.2
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1
        libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1
            libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1
    libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0
        libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
    ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2

We also tried building our own corresponding version of curl and explicitly point opentelemetry-cpp-1.28.0-install.sh at the resulting static archive:

-DCURL_LIBRARY="$HOME/haproxy-static/prefix/curl/lib/libcurl.a" \
-DCURL_INCLUDE_DIR="$HOME/haproxy-static/prefix/curl/include" \
-DCURL_NO_CURL_CMAKE=ON \

But that had no effect.

What would be the correct way to make the OTel SDK / C wrapper use the static curl lib?

Thanks in advance for any help or guidance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions