rpm-ostree/Makefile.am

118 lines
4.0 KiB
Makefile
Raw Normal View History

2013-12-22 04:41:30 +04:00
# Copyright (C) 2011,2013 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
include Makefile-decls.am
include Makefile-extra.inc
primaryname = rpm-ostree
2015-04-09 00:20:50 +03:00
SUBDIRS += .
if ENABLE_GTK_DOC
SUBDIRS += api-doc
2015-04-09 00:20:50 +03:00
endif
RPM_OSTREE_GITREV=$(shell if command -v git >/dev/null 2>&1 && test -e $(srcdir)/.git; then git describe --abbrev=42 --tags --always HEAD; fi)
ACLOCAL_AMFLAGS += -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS += -DDATADIR='"$(datadir)"' \
2013-12-22 04:41:30 +04:00
-DLIBEXECDIR='"$(libexecdir)"' \
-DLOCALEDIR=\"$(datadir)/locale\" \
-DSYSCONFDIR='"$(sysconfdir)"' \
-DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \
-DRPM_OSTREE_GITREV='"$(RPM_OSTREE_GITREV)"' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_56
# We make some C warnings always a hard error; these should never happen in our code.
# These flags are not valid for C++.
warn_only_c_flags = -Werror=strict-prototypes \
-Werror=missing-prototypes \
-Werror=implicit-function-declaration \
-Werror=int-conversion \
-Werror=incompatible-pointer-types \
-Werror=int-conversion \
$(NULL)
# Keep this in sync with the AM_CFLAGS in libostree; see
# that project for more information about e.g. -fno-strict-aliasing
AM_CFLAGS += -std=gnu11 -fno-strict-aliasing $(WARN_CFLAGS) $(warn_only_c_flags)
# Our default CXX flags
AM_CXXFLAGS += -std=c++17 -fno-strict-aliasing $(WARN_CFLAGS)
Makefile.am: Link with --enable-new-dtags When g-ir-scanner runs, it uses a stub binary to help introspect the target rpm-ostree library. That binary needs to link to the library, and of course, transitively, to our bundled libdnf. Since we run the scanner uninstalled, we use `LD_LIBRARY_PATH` to point the stub at the libdnf from the build directory. When we compile rpm-ostree, we use `-rpath` to point it at our libdnf, which emits a `DT_RPATH` attribute. However, during dynamic linking at runtime, it turns out that `LD_LIBRARY_PATH` has *lower* precedence than `DT_RPATH`. This means that if there is already a libdnf at `/usr/lib64/rpm-ostree`, it takes precedence. This subtlety is mostly fine to ignore usually, because the stub doesn't actually run any rpm-ostree business logic, so it doesn't really matter that it runs against the "technically wrong" `libdnf.so.2`. Where it becomes obvious something is off however is if we've just built a new libdnf, and we have new code which references symbols from the new libdnf that aren't in the stale libdnf at `$libdir/rpm-ostree`. And this is exactly what was happening in CI (though it's of course possible to reproduce this locally as well): we were using a new symbol, `hy_goal_favor`, and building inside the cosa buildroot image, which already has rpm-ostree installed, and so `ld.so` chose the bundled libdnf of the installed rpm-ostree when loading the `g-ir-scanner` stub. Thus why it failed with: ``` ./tmp-introspectzh0n2cga/.libs/lt-RpmOstree-1.0: symbol lookup error: .libs/librpmostree-1.so.1: undefined symbol: hy_goal_favor ``` And of course, the root cause here has nothing to do with the stub in itself. It's actually trivially easy to see the behaviour difference wrt `LD_LIBRARY_PATH` on installed binaries. Using a shared object from `python3-libdnf` which links to libdnf without using rpath, we can see that `LD_LIBRARY_PATH` has an effect: ``` $ ldd /usr/lib64/python3.7/site-packages/libdnf/_transaction.so | grep libdnf libdnf.so.2 => /lib64/libdnf.so.2 (0x00007fdde789e000) $ LD_LIBRARY_PATH=./libdnf-build/libdnf ldd /usr/lib64/python3.7/site-packages/libdnf/_transaction.so | grep libdnf libdnf.so.2 => ./libdnf-build/libdnf/libdnf.so.2 (0x00007fa615048000) ``` Whereas with rpm-ostree: ``` $ ldd /usr/bin/rpm-ostree | grep libdnf libdnf.so.2 => /usr/lib64/rpm-ostree/libdnf.so.2 (0x00007f7da5271000) $ LD_LIBRARY_PATH=./libdnf-build/libdnf ldd /usr/bin/rpm-ostree | grep libdnf libdnf.so.2 => /usr/lib64/rpm-ostree/libdnf.so.2 (0x00007fc905dbd000) ``` And going further down the rabbit hole, `DT_RPATH` is in fact considered deprecated for this reason; it makes it harder to run with uninstalled libraries or whatever reason one has to want to override a library (one can still use `LD_PRELOAD`, though the semantics are different, and it's less commonly used than `LD_LIBRARY_PATH`). Instead, we should use `DT_RUNPATH`, which does have lower precedence than `LD_LIBRARY_PATH`, matching the usual behaviour. To make the linker emit `DT_RUNPATH` attributes, we have to use the `--enable-new-dtags` flag. This also then fixes the g-ir-scanner issue described above.
2020-05-11 21:08:45 +03:00
# bundled libdnf; --enable-new-dtags emits DT_RUNPATH instead of deprecated DT_RPATH, which
# can't be overridden by LD_LIBRARY_PATH; which is useful for uninstalled runs/tests
AM_LDFLAGS += "-Wl,-rpath=$(libdir)/rpm-ostree,--enable-new-dtags"
2013-12-22 04:41:30 +04:00
EXTRA_DIST += autogen.sh COPYING
GITIGNOREFILES += build-aux/ gtk-doc.make config.h.in aclocal.m4 insttree/ rpm-ostreed
2015-04-28 04:22:58 +03:00
SED_SUBST = sed \
-e 's,[@]libexecdir[@],$(libexecdir),g' \
-e 's,[@]primaryname[@],$(primaryname),g' \
-e 's,[@]bindir[@],$(bindir),g' \
2015-04-28 04:22:58 +03:00
$(NULL)
libglnx_srcpath := $(srcdir)/libglnx
libglnx_cflags := $(PKGDEP_GIO_UNIX_CFLAGS) -I$(libglnx_srcpath) -fvisibility=hidden
2015-04-28 04:22:58 +03:00
libglnx_ldflags :=
libglnx_libs := $(PKGDEP_GIO_UNIX_LIBS)
include $(INTROSPECTION_MAKEFILE)
GIRS =
TYPELIBS = $(GIRS:.gir=.typelib)
# These bits were originally based on gnome:librsvg/Makefile.am
# but have been adapted to non-recursive Automake, and additionally
# the "cargo vendor" bits for us live in packaging/Makefile.dist-packaging.
.PHONY: check-local-cargo clean-local-cargo use-git-not-dist-hook
if RUST_DEBUG
CARGO_RELEASE_ARGS=
else
CARGO_RELEASE_ARGS=--release
endif
check-local-cargo:
cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo test
CHECK_LOCAL_HOOKS += check-local-cargo
clean-local-cargo:
cd $(srcdir)/rust && CARGO_TARGET_DIR=$(abs_top_builddir)/target cargo clean
CLEAN_LOCAL_HOOKS += clean-local-cargo
use-git-not-dist-hook:
@echo
@echo 'ERROR: rpm-ostree does not use/support "make dist"; see packaging/Makefile.dist-packaging' 1>&2
@echo
@exit 1
DIST_HOOKS += use-git-not-dist-hook
GITIGNOREFILES += target/
# From coreos-assembler
GITIGNOREFILES += "fastbuild*.qcow2" _kola_temp/
include libglnx/Makefile-libglnx.am.inc
noinst_LTLIBRARIES += libglnx.la
include Makefile-libpriv.am
include Makefile-libdnf.am
include Makefile-lib.am
2015-04-28 04:22:58 +03:00
include Makefile-daemon.am
2013-12-22 04:41:30 +04:00
include Makefile-rpm-ostree.am
include Makefile-tests.am
2014-03-25 16:24:19 +04:00
include Makefile-man.am
include Makefile-bash.am
-include $(top_srcdir)/git.mk