diff options
author | Dan Williams <dcbw@redhat.com> | 2014-09-08 15:12:48 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-09-11 12:48:17 -0500 |
commit | 38b076de8fc0e531ff80e9c9237960e0b2126467 (patch) | |
tree | 1ade49d320e4d25c0bc08f428ffb13a8dbd88332 | |
parent | 706b9d2056362b2ec7a84f1d952fcbf00f357b0f (diff) | |
download | NetworkManager-38b076de8fc0e531ff80e9c9237960e0b2126467.tar.gz |
build: ensure device source file constructors can be linked and called
gcc's linker does not add constructors from object files to the main
executable if they are built into a convenience library and then the
library is linked to the executable, unless something outside of the
object file with the constructor references a symbol from the object
file.
http://osdir.com/ml/libtool-gnu/2011-06/msg00003.html
"Yes, when convenience libraries are used to create a shared library, all the
objects are included in the output, when the output is an application they are
used like a normal archive library.
Either use them to create a shared library or, if creating an application,
don't use them, use the objects instead."
Further patches will remove all references to the NMDevice subclasses
from nm-manager.c, and have each NMDevice subclass register itself
with a factory through a constructor. But due to the above issue,
we need to somehow ensure the constructor in each nm-device-*.c file
gets added to the executable. This is accomplished by explicitly
linking each NMDevice subclass' object file into the main executable.
(Note that we cannot use -Wl,-whole-archive here because libtool only
supports this option for linking a convenience library to a shared
library, but not to an executable, and will actively prevent using
-whole-archive in LDFLAGS)
-rw-r--r-- | src/Makefile.am | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 494bc8ef3a..f0b22d2e29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,21 +55,35 @@ AM_CPPFLAGS += $(foreach d,$(sort $(dir $(libNetworkManager_la_SOURCES))),-I$(to sbin_PROGRAMS = NetworkManager NetworkManager_SOURCES = \ + $(nm_device_sources) $(nm_device_headers) \ main.c NetworkManager_LDADD = libNetworkManager.la noinst_LTLIBRARIES = libNetworkManager.la +nm_device_sources = \ + $(NULL) + +nm_device_headers = \ + devices/nm-device-bond.h \ + devices/nm-device-bridge.h \ + devices/nm-device-ethernet.h \ + devices/nm-device-gre.h \ + devices/nm-device-infiniband.h \ + devices/nm-device-macvlan.h \ + devices/nm-device-tun.h \ + devices/nm-device-veth.h \ + devices/nm-device-vlan.h \ + devices/nm-device-vxlan.h + nm_sources = \ + $(nm_device_headers) \ devices/nm-device.c \ devices/nm-device.h \ devices/nm-device-bond.c \ - devices/nm-device-bond.h \ devices/nm-device-bridge.c \ - devices/nm-device-bridge.h \ devices/nm-device-ethernet.c \ - devices/nm-device-ethernet.h \ devices/nm-device-ethernet-utils.c \ devices/nm-device-ethernet-utils.h \ devices/nm-device-factory.c \ @@ -77,21 +91,14 @@ nm_sources = \ devices/nm-device-generic.c \ devices/nm-device-generic.h \ devices/nm-device-gre.c \ - devices/nm-device-gre.h \ devices/nm-device-infiniband.c \ - devices/nm-device-infiniband.h \ devices/nm-device-logging.h \ devices/nm-device-macvlan.c \ - devices/nm-device-macvlan.h \ devices/nm-device-private.h \ devices/nm-device-tun.c \ - devices/nm-device-tun.h \ devices/nm-device-veth.c \ - devices/nm-device-veth.h \ devices/nm-device-vlan.c \ - devices/nm-device-vlan.h \ devices/nm-device-vxlan.c \ - devices/nm-device-vxlan.h \ \ dhcp-manager/nm-dhcp-client.c \ dhcp-manager/nm-dhcp-client.h \ |