From: Remi Gacogne Date: Mon, 20 Jan 2025 11:33:17 +0000 (+0100) Subject: dnsdist: Wild shot at building our packages with clang++ X-Git-Tag: dnsdist-2.0.0-alpha1~129^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5f033e6e39e5ee3b3ec51122206bc5d8e3f7fb2;p=thirdparty%2Fpdns.git dnsdist: Wild shot at building our packages with clang++ --- diff --git a/builder-support/debian/dnsdist/debian-bookworm/control b/builder-support/debian/dnsdist/debian-bookworm/control index 2521d8c70d..4796af9690 100644 --- a/builder-support/debian/dnsdist/debian-bookworm/control +++ b/builder-support/debian/dnsdist/debian-bookworm/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: PowerDNS.COM BV Uploaders: PowerDNS.COM BV Build-Depends: debhelper (>= 10), + clang, libboost-all-dev, libbpf-dev [linux-any], libcap-dev, @@ -22,6 +23,7 @@ Build-Depends: debhelper (>= 10), libsystemd-dev [linux-any], libwslay-dev, libxdp-dev [linux-any], + lld, pkg-config, python3-yaml, ragel, diff --git a/builder-support/debian/dnsdist/debian-bookworm/rules b/builder-support/debian/dnsdist/debian-bookworm/rules index 5291c3bcb2..4fcc760301 100755 --- a/builder-support/debian/dnsdist/debian-bookworm/rules +++ b/builder-support/debian/dnsdist/debian-bookworm/rules @@ -10,6 +10,12 @@ include /usr/share/dpkg/default.mk # for atomic support on powerpc (automatic on mipsel) LDFLAGS += -latomic +# We need clang (LLVM) to link the Rust static library and the C++ code with LTO enabled +# build-id SHA1 prevents an issue with the debug symbols +# and the --no-as-needed -ldl an issue with the dlsym not being found +LDFLAGS += -fuse-ld=lld -Wl,--build-id=sha1 -Wl,--no-as-needed -ldl +CC=clang +CXX=clang++ # Only enable systemd integration on Linux operating systems ifeq ($(DEB_HOST_ARCH_OS),linux) diff --git a/builder-support/debian/dnsdist/debian-buster/control b/builder-support/debian/dnsdist/debian-buster/control index 4259f478b1..d9cb1f5d26 100644 --- a/builder-support/debian/dnsdist/debian-buster/control +++ b/builder-support/debian/dnsdist/debian-buster/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: PowerDNS.COM BV Uploaders: PowerDNS.COM BV Build-Depends: debhelper (>= 10), + clang, libboost-all-dev, libcap-dev, libcdb-dev, @@ -20,6 +21,7 @@ Build-Depends: debhelper (>= 10), libssl-dev, libsystemd-dev [linux-any], libwslay-dev, + lld, pkg-config, python3-yaml, ragel, diff --git a/builder-support/debian/dnsdist/debian-buster/rules b/builder-support/debian/dnsdist/debian-buster/rules index 3b732061a7..ce9621d127 100755 --- a/builder-support/debian/dnsdist/debian-buster/rules +++ b/builder-support/debian/dnsdist/debian-buster/rules @@ -10,6 +10,12 @@ include /usr/share/dpkg/default.mk # for atomic support on powerpc (automatic on mipsel) LDFLAGS += -latomic +# We need clang (LLVM) to link the Rust static library and the C++ code with LTO enabled +# build-id SHA1 prevents an issue with the debug symbols +# and the --no-as-needed -ldl an issue with the dlsym not being found +LDFLAGS += -fuse-ld=lld -Wl,--build-id=sha1 -Wl,--no-as-needed -ldl +CC=clang +CXX=clang++ # Only enable systemd integration on Linux operating systems ifeq ($(DEB_HOST_ARCH_OS),linux) diff --git a/builder-support/dockerfiles/Dockerfile.dnsdist b/builder-support/dockerfiles/Dockerfile.dnsdist index ffea154e97..b1f096b04e 100644 --- a/builder-support/dockerfiles/Dockerfile.dnsdist +++ b/builder-support/dockerfiles/Dockerfile.dnsdist @@ -19,4 +19,3 @@ RUN /dnsdist/builder/helpers/set-configure-ac-version.sh && \ ./configure --disable-dependency-tracking && \ make dist RUN cp dnsdist-${BUILDER_VERSION}.tar.bz2 /sdist/ - diff --git a/builder-support/specs/dnsdist.spec b/builder-support/specs/dnsdist.spec index 428e1ddfc3..476b279c88 100644 --- a/builder-support/specs/dnsdist.spec +++ b/builder-support/specs/dnsdist.spec @@ -9,7 +9,6 @@ Source: %{name}-%{getenv:BUILDER_VERSION}.tar.bz2 BuildRequires: readline-devel BuildRequires: libedit-devel BuildRequires: openssl-devel -BuildRequires: python3-pyyaml %if 0%{?suse_version} BuildRequires: lua-devel @@ -22,6 +21,12 @@ BuildRequires: systemd-devel BuildRequires: boost169-devel %else BuildRequires: boost-devel +BuildRequires: python3-pyyaml +%endif + +%if 0%{?rhel} >= 8 +BuildRequires: clang +BuildRequires: lld %endif %if 0%{?rhel} >= 7 || 0%{?amzn} == 2023 @@ -72,6 +77,14 @@ dnsdist is a high-performance DNS loadbalancer that is scriptable in Lua. export CPPFLAGS=-I/usr/include/boost169 export LDFLAGS=-L/usr/lib64/boost169 %endif +%if 0%{?rhel} >= 8 +# We need to build with LLVM/clang to be able to use LTO, since we are linking against a static Rust library built with LLVM +export CC=clang +export CXX=clang++ +# build-id SHA1 prevents an issue with the debug symbols +# and the --no-as-needed -ldl an issue with the dlsym not being found +export LDFLAGS="-fuse-ld=lld -Wl,--build-id=sha1 -Wl,--no-as-needed -ldl" +%endif export AR=gcc-ar export RANLIB=gcc-ranlib @@ -110,6 +123,8 @@ export RANLIB=gcc-ranlib --enable-dns-over-quic \ --enable-dns-over-http3 \ --with-quiche \ +%endif +%if 0%{?rhel} >= 8 --enable-yaml \ %endif PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/lib64/pkgconfig