Repository: mesos Updated Branches: refs/heads/master 24d640e2d -> 64b12f50e
Used LDADD to add unbundled libraries to all command line programs. When building with unbundled libraries, every program needs to link against the libraries, and can't assume it will be linked against because the program links with a program which links against the libraries. This comes up on Debian and Ubuntu[1] which set the flag `-Wl,--no-copy-dt-needed-entries` which forcibly disables the binaries from getting automatically the dependencies of the shared libraries they link against. Also adds -Wl,--as-needed to AM_LDFLAGS to silence warnings in Fedora packaging since we link against more libraries than things actually use at the command line. Debian and Ubuntu default to this option. OS X doesn't have `-Wl,--as-needed` or `--no-copy-dt-needed-entries` so only enable it on Linux. [1] https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--no-copy-dt-needed-entries Review: https://reviews.apache.org/r/32008 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/64b12f50 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/64b12f50 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/64b12f50 Branch: refs/heads/master Commit: 64b12f50e1151bd2e389889fc46de0c97cec9951 Parents: 24d640e Author: Cody Maloney <[email protected]> Authored: Mon Mar 16 12:17:06 2015 -0700 Committer: Niklas Q. Nielsen <[email protected]> Committed: Mon Mar 16 13:19:07 2015 -0700 ---------------------------------------------------------------------- src/Makefile.am | 67 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/64b12f50/src/Makefile.am ---------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index 3059818..7a06c70 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,6 +74,15 @@ BUILT_SOURCES = CLEANFILES = EXTRA_DIST = PHONY_TARGETS = +LDADD = + +# Use -Wl,--as-needed to AM_LDFLAGS since we link against all the +# libraries programs may depend upon, not the exact one. --as-needed +# causes the linker to only link to the ones a program actually uses, +# not the full list on the command line. +if OS_LINUX +AM_LDFLAGS=-Wl,--as-needed +endif # Add compiler and linker flags for pthreads. AM_CXXFLAGS = $(PTHREAD_CFLAGS) @@ -707,6 +716,7 @@ if WITH_BUNDLED_GLOG libmesos_la_LIBADD += ../$(GLOG)/libglog.la else libmesos_la_LIBADD += -lglog + LDADD += -lglog endif if WITH_BUNDLED_LEVELDB @@ -717,18 +727,21 @@ if WITH_BUNDLED_LEVELDB libmesos_la_LIBADD += ../$(LEVELDB)/libleveldb.a else libmesos_la_LIBADD += -lleveldb + LDADD += -lleveldb endif if WITH_BUNDLED_ZOOKEEPER libmesos_la_LIBADD += ../$(ZOOKEEPER)/libzookeeper_mt.la else libmesos_la_LIBADD += -lzookeeper_mt + LDADD += -lzookeeper_mt endif if WITH_BUNDLED_PROTOBUF libmesos_la_LIBADD += ../$(PROTOBUF)/src/libprotobuf.la else libmesos_la_LIBADD += -lprotobuf + LDADD += -lprotobuf endif @@ -736,69 +749,69 @@ endif sbin_PROGRAMS += mesos-master mesos_master_SOURCES = master/main.cpp mesos_master_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_master_LDADD = libmesos.la +mesos_master_LDADD = libmesos.la $(LDADD) sbin_PROGRAMS += mesos-slave mesos_slave_SOURCES = slave/main.cpp mesos_slave_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_slave_LDADD = libmesos.la +mesos_slave_LDADD = libmesos.la $(LDADD) bin_PROGRAMS += mesos-local mesos_local_SOURCES = local/main.cpp mesos_local_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_local_LDADD = libmesos.la +mesos_local_LDADD = libmesos.la $(LDADD) pkglibexec_PROGRAMS += mesos-fetcher mesos_fetcher_SOURCES = launcher/fetcher.cpp mesos_fetcher_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_fetcher_LDADD = libmesos.la +mesos_fetcher_LDADD = libmesos.la $(LDADD) pkglibexec_PROGRAMS += mesos-executor mesos_executor_SOURCES = launcher/executor.cpp mesos_executor_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_executor_LDADD = libmesos.la +mesos_executor_LDADD = libmesos.la $(LDADD) pkglibexec_PROGRAMS += mesos-containerizer mesos_containerizer_SOURCES = slave/containerizer/mesos/main.cpp mesos_containerizer_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_containerizer_LDADD = libmesos.la +mesos_containerizer_LDADD = libmesos.la $(LDADD) if WITH_NETWORK_ISOLATOR pkglibexec_PROGRAMS += mesos-network-helper mesos_network_helper_SOURCES = slave/containerizer/isolators/network/helper.cpp mesos_network_helper_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_network_helper_LDADD = libmesos.la +mesos_network_helper_LDADD = libmesos.la $(LDADD) endif pkglibexec_PROGRAMS += mesos-health-check mesos_health_check_SOURCES = health-check/main.cpp mesos_health_check_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_health_check_LDADD = libmesos.la +mesos_health_check_LDADD = libmesos.la $(LDADD) pkglibexec_PROGRAMS += mesos-usage mesos_usage_SOURCES = usage/main.cpp mesos_usage_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_usage_LDADD = libmesos.la +mesos_usage_LDADD = libmesos.la $(LDADD) bin_PROGRAMS += mesos-log mesos_log_SOURCES = log/main.cpp mesos_log_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_log_LDADD = libmesos.la +mesos_log_LDADD = libmesos.la $(LDADD) bin_PROGRAMS += mesos mesos_SOURCES = cli/mesos.cpp mesos_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_LDADD = libmesos.la +mesos_LDADD = libmesos.la $(LDADD) bin_PROGRAMS += mesos-execute mesos_execute_SOURCES = cli/execute.cpp mesos_execute_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_execute_LDADD = libmesos.la +mesos_execute_LDADD = libmesos.la $(LDADD) bin_PROGRAMS += mesos-resolve mesos_resolve_SOURCES = cli/resolve.cpp mesos_resolve_CPPFLAGS = $(MESOS_CPPFLAGS) -mesos_resolve_LDADD = libmesos.la +mesos_resolve_LDADD = libmesos.la $(LDADD) # Need to distribute and install mesos-*. dist_bin_SCRIPTS += \ @@ -1205,57 +1218,57 @@ PHONY_TARGETS += clean-python check_PROGRAMS += low-level-scheduler-libprocess low_level_scheduler_libprocess_SOURCES = examples/low_level_scheduler_libprocess.cpp low_level_scheduler_libprocess_CPPFLAGS = $(MESOS_CPPFLAGS) -low_level_scheduler_libprocess_LDADD = libmesos.la +low_level_scheduler_libprocess_LDADD = libmesos.la $(LDADD) check_PROGRAMS += low-level-scheduler-pthread low_level_scheduler_pthread_SOURCES = examples/low_level_scheduler_pthread.cpp low_level_scheduler_pthread_CPPFLAGS = $(MESOS_CPPFLAGS) -low_level_scheduler_pthread_LDADD = libmesos.la +low_level_scheduler_pthread_LDADD = libmesos.la $(LDADD) check_PROGRAMS += test-framework test_framework_SOURCES = examples/test_framework.cpp test_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -test_framework_LDADD = libmesos.la +test_framework_LDADD = libmesos.la $(LDADD) check_PROGRAMS += test-executor test_executor_SOURCES = examples/test_executor.cpp test_executor_CPPFLAGS = $(MESOS_CPPFLAGS) -test_executor_LDADD = libmesos.la +test_executor_LDADD = libmesos.la $(LDADD) check_PROGRAMS += long-lived-framework long_lived_framework_SOURCES = examples/long_lived_framework.cpp long_lived_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -long_lived_framework_LDADD = libmesos.la +long_lived_framework_LDADD = libmesos.la $(LDADD) check_PROGRAMS += long-lived-executor long_lived_executor_SOURCES = examples/long_lived_executor.cpp long_lived_executor_CPPFLAGS = $(MESOS_CPPFLAGS) -long_lived_executor_LDADD = libmesos.la +long_lived_executor_LDADD = libmesos.la $(LDADD) check_PROGRAMS += no-executor-framework no_executor_framework_SOURCES = examples/no_executor_framework.cpp no_executor_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -no_executor_framework_LDADD = libmesos.la +no_executor_framework_LDADD = libmesos.la $(LDADD) check_PROGRAMS += docker-no-executor-framework docker_no_executor_framework_SOURCES = examples/docker_no_executor_framework.cpp docker_no_executor_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -docker_no_executor_framework_LDADD = libmesos.la +docker_no_executor_framework_LDADD = libmesos.la $(LDADD) check_PROGRAMS += balloon-framework balloon_framework_SOURCES = examples/balloon_framework.cpp balloon_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -balloon_framework_LDADD = libmesos.la +balloon_framework_LDADD = libmesos.la $(LDADD) check_PROGRAMS += balloon-executor balloon_executor_SOURCES = examples/balloon_executor.cpp balloon_executor_CPPFLAGS = $(MESOS_CPPFLAGS) -balloon_executor_LDADD = libmesos.la +balloon_executor_LDADD = libmesos.la $(LDADD) check_PROGRAMS += load-generator-framework load_generator_framework_SOURCES = examples/load_generator_framework.cpp load_generator_framework_CPPFLAGS = $(MESOS_CPPFLAGS) -load_generator_framework_LDADD = libmesos.la +load_generator_framework_LDADD = libmesos.la $(LDADD) if OS_LINUX check_PROGRAMS += setns-test-helper @@ -1263,13 +1276,13 @@ if OS_LINUX tests/setns_test_helper_main.cpp \ tests/setns_test_helper.cpp setns_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS) - setns_test_helper_LDADD = libmesos.la + setns_test_helper_LDADD = libmesos.la $(LDADD) endif check_PROGRAMS += active-user-test-helper active_user_test_helper_SOURCES = tests/active_user_test_helper.cpp active_user_test_helper_CPPFLAGS = $(MESOS_CPPFLAGS) -active_user_test_helper_LDADD = libmesos.la +active_user_test_helper_LDADD = libmesos.la $(LDADD) check_PROGRAMS += mesos-tests @@ -1383,7 +1396,7 @@ mesos_tests_CPPFLAGS += -DBUILD_DIR=\"$(abs_top_builddir)\" mesos_tests_CPPFLAGS += -I../$(GTEST)/include mesos_tests_CPPFLAGS += -I../$(GMOCK)/include -mesos_tests_LDADD = ../$(LIBPROCESS)/3rdparty/libgmock.la libmesos.la -ldl +mesos_tests_LDADD = ../$(LIBPROCESS)/3rdparty/libgmock.la libmesos.la -ldl $(LDADD) mesos_tests_DEPENDENCIES = # Initialized to allow += below.
