]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
make embedded quic lib work
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 27 Jan 2026 10:48:15 +0000 (11:48 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 29 Jan 2026 10:58:14 +0000 (11:58 +0100)
This should also fix -Dquic=disabled
I'm now lazy to go fix it on the commits introducing it, too.

QUIC by default sizing (default nixos.org builds as reference):
 - with embedded ngtcp2* we grow the kresd binary by 344 KiB
 - with external ngtcp2* we grow the kresd binary by 40 KiB
   (while the external ngtcp2 package takes 472 KiB,
    libknot already depends on it, so it's not new)

contrib/libngtcp2/meson.build [new file with mode: 0644]
contrib/meson.build
meson.build
meson_options.txt

diff --git a/contrib/libngtcp2/meson.build b/contrib/libngtcp2/meson.build
new file mode 100644 (file)
index 0000000..571957d
--- /dev/null
@@ -0,0 +1,122 @@
+# The files in here get synced from
+# https://gitlab.nic.cz/knot/knot-dns/-/tree/master/src/contrib/libngtcp2
+# except for this ./meson.build itself.
+
+libembngtcp2_src = files([
+       'ngtcp2/crypto/gnutls.c',
+       'ngtcp2/crypto/shared.c',
+       'ngtcp2/lib/ngtcp2_acktr.c',
+       'ngtcp2/lib/ngtcp2_addr.c',
+       'ngtcp2/lib/ngtcp2_balloc.c',
+       'ngtcp2/lib/ngtcp2_bbr.c',
+       'ngtcp2/lib/ngtcp2_buf.c',
+       'ngtcp2/lib/ngtcp2_cc.c',
+       'ngtcp2/lib/ngtcp2_cid.c',
+       'ngtcp2/lib/ngtcp2_conn.c',
+       'ngtcp2/lib/ngtcp2_conn_info.c',
+       'ngtcp2/lib/ngtcp2_conv.c',
+       'ngtcp2/lib/ngtcp2_crypto.c',
+       'ngtcp2/lib/ngtcp2_err.c',
+       'ngtcp2/lib/ngtcp2_frame_chain.c',
+       'ngtcp2/lib/ngtcp2_gaptr.c',
+       'ngtcp2/lib/ngtcp2_idtr.c',
+       'ngtcp2/lib/ngtcp2_ksl.c',
+       'ngtcp2/lib/ngtcp2_log.c',
+       'ngtcp2/lib/ngtcp2_map.c',
+       'ngtcp2/lib/ngtcp2_mem.c',
+       'ngtcp2/lib/ngtcp2_objalloc.c',
+       'ngtcp2/lib/ngtcp2_opl.c',
+       'ngtcp2/lib/ngtcp2_path.c',
+       'ngtcp2/lib/ngtcp2_pcg.c',
+       'ngtcp2/lib/ngtcp2_pkt.c',
+       'ngtcp2/lib/ngtcp2_pmtud.c',
+       'ngtcp2/lib/ngtcp2_ppe.c',
+       'ngtcp2/lib/ngtcp2_pq.c',
+       'ngtcp2/lib/ngtcp2_pv.c',
+       'ngtcp2/lib/ngtcp2_qlog.c',
+       'ngtcp2/lib/ngtcp2_range.c',
+       'ngtcp2/lib/ngtcp2_ratelim.c',
+       'ngtcp2/lib/ngtcp2_ringbuf.c',
+       'ngtcp2/lib/ngtcp2_rob.c',
+       'ngtcp2/lib/ngtcp2_rst.c',
+       'ngtcp2/lib/ngtcp2_rtb.c',
+       'ngtcp2/lib/ngtcp2_settings.c',
+       'ngtcp2/lib/ngtcp2_str.c',
+       'ngtcp2/lib/ngtcp2_strm.c',
+       'ngtcp2/lib/ngtcp2_transport_params.c',
+       'ngtcp2/lib/ngtcp2_unreachable.c',
+       'ngtcp2/lib/ngtcp2_vec.c',
+       'ngtcp2/lib/ngtcp2_version.c',
+       'ngtcp2/lib/ngtcp2_window_filter.c',
+       'ngtcp2/lib/ngtcp2_dcidtr.c',
+       'ngtcp2/lib/ngtcp2_callbacks.c',
+])
+
+libembngtcp2_headers = files([
+       'ngtcp2/crypto/shared.h',
+       'ngtcp2/lib/ngtcp2_acktr.h',
+       'ngtcp2/lib/ngtcp2_addr.h',
+       'ngtcp2/lib/ngtcp2_balloc.h',
+       'ngtcp2/lib/ngtcp2_bbr.h',
+       'ngtcp2/lib/ngtcp2_buf.h',
+       'ngtcp2/lib/ngtcp2_cc.h',
+       'ngtcp2/lib/ngtcp2_cid.h',
+       'ngtcp2/lib/ngtcp2_conn.h',
+       'ngtcp2/lib/ngtcp2_conn_info.h',
+       'ngtcp2/lib/ngtcp2_conn_stat.h',
+       'ngtcp2/lib/ngtcp2_conv.h',
+       'ngtcp2/lib/ngtcp2_crypto.h',
+       'ngtcp2/lib/ngtcp2_err.h',
+       'ngtcp2/lib/ngtcp2_frame_chain.h',
+       'ngtcp2/lib/ngtcp2_gaptr.h',
+       'ngtcp2/lib/ngtcp2_idtr.h',
+       'ngtcp2/lib/ngtcp2_ksl.h',
+       'ngtcp2/lib/ngtcp2_log.h',
+       'ngtcp2/lib/ngtcp2_macro.h',
+       'ngtcp2/lib/ngtcp2_map.h',
+       'ngtcp2/lib/ngtcp2_mem.h',
+       'ngtcp2/lib/ngtcp2_net.h',
+       'ngtcp2/lib/ngtcp2_objalloc.h',
+       'ngtcp2/lib/ngtcp2_opl.h',
+       'ngtcp2/lib/ngtcp2_path.h',
+       'ngtcp2/lib/ngtcp2_pcg.h',
+       'ngtcp2/lib/ngtcp2_pkt.h',
+       'ngtcp2/lib/ngtcp2_pktns_id.h',
+       'ngtcp2/lib/ngtcp2_pmtud.h',
+       'ngtcp2/lib/ngtcp2_ppe.h',
+       'ngtcp2/lib/ngtcp2_pq.h',
+       'ngtcp2/lib/ngtcp2_pv.h',
+       'ngtcp2/lib/ngtcp2_qlog.h',
+       'ngtcp2/lib/ngtcp2_range.h',
+       'ngtcp2/lib/ngtcp2_ratelim.h',
+       'ngtcp2/lib/ngtcp2_rcvry.h',
+       'ngtcp2/lib/ngtcp2_ringbuf.h',
+       'ngtcp2/lib/ngtcp2_rob.h',
+       'ngtcp2/lib/ngtcp2_rst.h',
+       'ngtcp2/lib/ngtcp2_rtb.h',
+       'ngtcp2/lib/ngtcp2_settings.h',
+       'ngtcp2/lib/ngtcp2_str.h',
+       'ngtcp2/lib/ngtcp2_strm.h',
+       'ngtcp2/lib/ngtcp2_transport_params.h',
+       'ngtcp2/lib/ngtcp2_tstamp.h',
+       'ngtcp2/lib/ngtcp2_unreachable.h',
+       'ngtcp2/lib/ngtcp2_vec.h',
+       'ngtcp2/lib/ngtcp2_window_filter.h',
+       'ngtcp2/lib/ngtcp2_dcidtr.h',
+       'ngtcp2/lib/ngtcp2_callbacks.h',
+       'ngtcp2/ngtcp2.h',
+       'ngtcp2/ngtcp2_crypto.h',
+       'ngtcp2/ngtcp2_crypto_gnutls.h',
+       'ngtcp2/version.h',
+])
+
+libembngtcp2_lib = static_library(
+  'embngtcp2',
+  libembngtcp2_src,
+  include_directories: include_directories('./ngtcp2/lib'),
+)
+
+libngtcp2_deps = [declare_dependency(
+  link_with: [libembngtcp2_lib],
+  include_directories: include_directories('.'),
+)]
index 18cd26f11548a0cd124727bbaf578256694eb0aa..6eacda4cf0c89508d07b1dc444c23652f8b663c3 100644 (file)
@@ -1,6 +1,10 @@
 # contrib
 # SPDX-License-Identifier: GPL-3.0-or-later
 
+if embed_ngtcp2 
+  subdir('./libngtcp2')
+endif
+
 contrib_src = files([
   'ccan/asprintf/asprintf.c',
   'ccan/json/json.c',
index e3608c1bb3d754f259c578d72833c096486d2c42..81ae293542d1d2ea46b5fe47f2611278afbf1820 100644 (file)
@@ -137,13 +137,31 @@ message('--- optional dependencies ---')
 nghttp2 = dependency('libnghttp2', required: false)
 openssl = dependency('openssl', required: false)
 
-libngtcp2 = dependency('libngtcp2', version: '>=1.11.0', required: get_option('quic') == 'external')
-libngtcp2_crypto = dependency('libngtcp2_crypto_gnutls', required: get_option('quic') == 'external')
-enable_quic = libngtcp2.found() and libngtcp2_crypto.found()
-if enable_quic
-  libngtcp2_deps = [libngtcp2, libngtcp2_crypto]
+embed_ngtcp2 = false
+if get_option('quic') == 'disabled'
+  quic_sumstr = 'disabled explicitly'
+  enable_quic = false
+  libngtcp2_deps = []
+else
+  libngtcp2 = dependency('libngtcp2', version: '>=1.11.0', required: get_option('quic') == 'external')
+  libngtcp2_crypto = dependency('libngtcp2_crypto_gnutls', required: get_option('quic') == 'external')
+  if libngtcp2.found() and libngtcp2_crypto.found()
+    quic_sumstr = 'with external libngtcp2*'
+    enable_quic = true
+    libngtcp2_deps = [libngtcp2, libngtcp2_crypto]
+  elif gnutls.version() >= '3.7.5' # https://github.com/ngtcp2/ngtcp2?tab=readme-ov-file#requirements
+    quic_sumstr = 'with embedded libngtcp2*'
+    enable_quic = true
+    embed_ngtcp2 = true
+    #libngtcp2_deps gets set later, as it's not possible at this point yet
+  elif get_option('quic') == 'auto'
+    quic_sumstr = 'disabled because missing dependencies'
+    enable_quic = false
+    libngtcp2_deps = []
+  else
+    error('failed to satisfy -Dquic=embedded')
+  endif
 endif
-quic_summary = [enable_quic, 'with external libngtcp2*']
 
 have_asprintf = meson.get_compiler('c').has_function('asprintf',
   prefix: '#define _GNU_SOURCE\n#include <stdio.h>')
@@ -185,7 +203,7 @@ malloc = meson.get_compiler('c').find_library(
 summary({'sendmmsg': sendmmsg,
          'XDP (in libknot)': xdp,
          'doh2 (serving)': nghttp2.found(),
-         'DoQ': quic_summary,
+         'DoQ': [enable_quic, quic_sumstr],
          'capabilities': capng.found(),
          'malloc': malloc.found() ? malloc_name : 'libc default',
         }, section: 'Features', bool_yn: true)
index 58c9e76f4bd0a5c3d3f1331f6a48979dff70e634..b7c290d0c697a8272b7022a447d6d2721dd9236a 100644 (file)
@@ -167,10 +167,11 @@ option(
   choices: [
     'auto',
     'external',
+    'embedded',
     'disabled',
   ],
   value: 'auto',
-  description: 'build DNS-over-QUIC support, requiring compatible libngtcp2',
+  description: 'build DNS-over-QUIC support',
 )
 
 option(