diff options
-rw-r--r-- | .gitlab-ci.yml | 10 | ||||
-rw-r--r-- | daemon/meson.build | 1 | ||||
-rw-r--r-- | meson.build | 14 | ||||
-rw-r--r-- | meson_options.txt | 12 | ||||
-rw-r--r-- | utils/cache_gc/meson.build | 1 | ||||
-rw-r--r-- | utils/client/meson.build | 1 |
6 files changed, 35 insertions, 4 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cc1f9da..475cf3c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -106,7 +106,7 @@ archive: build: <<: *build script: - - meson build_ci --default-library=static --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled + - meson build_ci --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled - ninja -C build_ci - ninja -C build_ci install >/dev/null - ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite snowflake @@ -115,7 +115,7 @@ build-knot32: <<: *build image: $CI_REGISTRY/knot/knot-resolver/ci/debian-11:knot-3.2 script: - - meson build_ci_knot32 --default-library=static --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled + - meson build_ci_knot32 --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled - ninja -C build_ci_knot32 - ninja -C build_ci_knot32 install >/dev/null - ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite snowflake @@ -123,7 +123,9 @@ build-knot32: build-asan: <<: *build script: - # "undefined" sanitizer causes C++ issues when loading ahocorasick.so in CI + # issues with UBSan and ASan in CI: + # - `ahocorasick.so` causes C++ problems + # - `--default-library=shared` causes link problems - CC=clang CXX=clang++ CFLAGS=-fno-sanitize-recover=all CXXFLAGS=-fno-sanitize=undefined meson build_ci_asan --default-library=static --prefix=$PREFIX -Dmalloc=jemalloc -Db_sanitize=address,undefined -Dextra_tests=enabled - ninja -C build_ci_asan - ninja -C build_ci_asan install >/dev/null @@ -170,7 +172,7 @@ sonarcloud: - tags - master@knot/knot-resolver script: - - meson build_sonarcloud --default-library=static --prefix=$PREFIX -Dmalloc=disabled + - meson build_sonarcloud --prefix=$PREFIX -Dmalloc=disabled - build-wrapper-linux-x86-64 --out-dir bw-output ninja -C build_sonarcloud - > sonar-scanner diff --git a/daemon/meson.build b/daemon/meson.build index 68a26466..8446b829 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -65,4 +65,5 @@ kresd = executable( export_dynamic: true, install: true, install_dir: get_option('sbindir'), + install_rpath: rpath, ) diff --git a/meson.build b/meson.build index 8e22e17b..d6f9be38 100644 --- a/meson.build +++ b/meson.build @@ -59,6 +59,20 @@ systemd_unit_dir = prefix / 'lib' / 'systemd' / 'system' systemd_tmpfiles_dir = prefix / 'lib' / 'tmpfiles.d' systemd_sysusers_dir = prefix / 'lib' / 'sysusers.d' +## RPath +# When installing from sources into a non-standard prefix and the library is +# shared/dynamic, we need to set the executables' RPATH so that they can find +# `libkresd`, otherwise running them will fail with dynamic linkage errors +auto_prefixes = ['/', '/usr', '/usr/local'] +rpath_opt = get_option('install_rpath') +if (get_option('default_library') == 'static' or + rpath_opt == 'disabled' or + (rpath_opt == 'auto' and prefix in auto_prefixes)) + rpath = '' +else + rpath = prefix / get_option('libdir') +endif + ## Trust anchors managed_ta = get_option('managed_ta') == 'enabled' keyfile_default = etc_dir / get_option('keyfile_default') diff --git a/meson_options.txt b/meson_options.txt index 576d385a..f09f46d4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -217,3 +217,15 @@ option( value: 'auto', description: 'cmocka unit tests', ) + +option( + 'install_rpath', + type: 'combo', + choices: [ + 'auto', + 'enabled', + 'disabled', + ], + value: 'auto', + description: 'add rpath to the knot resolver executables', +) diff --git a/utils/cache_gc/meson.build b/utils/cache_gc/meson.build index 40e127d2..4c82b8da 100644 --- a/utils/cache_gc/meson.build +++ b/utils/cache_gc/meson.build @@ -21,6 +21,7 @@ if build_utils ], install: true, install_dir: get_option('sbindir'), + install_rpath: rpath, ) integr_tests += [ diff --git a/utils/client/meson.build b/utils/client/meson.build index 761c2cdd..795cca32 100644 --- a/utils/client/meson.build +++ b/utils/client/meson.build @@ -33,5 +33,6 @@ if build_client ], install: true, install_dir: get_option('sbindir'), + install_rpath: rpath, ) endif |