diff mbox

[11/11] Makefile: Specify as-needed when building executables

Message ID 20130702193143.48202.38726.stgit@manray.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever July 2, 2013, 7:31 p.m. UTC
The "--as-needed" linker flag reduces the number of unused objects
and dependencies in an executable, making it smaller and faster to
load.

Some distributions implicitly specify "--as-needed" when linking
their package builds.  Building on Fedora appears not to.

So that building on any platform can catch build problems before
they are committed, explicitly specify --as-needed for executables.

References:

  http://www.gentoo.org/proj/en/qa/asneeded.xml#doc_chap1

  https://sigquit.wordpress.com/tag/gnu-libtool/

Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 src/fedfsc/Makefile.am     |    1 +
 src/fedfsd/Makefile.am     |    1 +
 src/mount/Makefile.am      |    1 +
 src/nfsref/Makefile.am     |    1 +
 src/nsdbc/Makefile.am      |    1 +
 src/nsdbparams/Makefile.am |    1 +
 6 files changed, 6 insertions(+)
diff mbox

Patch

diff --git a/src/fedfsc/Makefile.am b/src/fedfsc/Makefile.am
index 808c886..df204d3 100644
--- a/src/fedfsc/Makefile.am
+++ b/src/fedfsc/Makefile.am
@@ -45,3 +45,4 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
+AM_LDFLAGS		= -Wl,--as-needed
diff --git a/src/fedfsd/Makefile.am b/src/fedfsd/Makefile.am
index 583a49a..8ff35b9 100644
--- a/src/fedfsd/Makefile.am
+++ b/src/fedfsd/Makefile.am
@@ -42,6 +42,7 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
+AM_LDFLAGS		= -Wl,--as-needed
 
 #######################################################################
 # The following allows the current practice of having
diff --git a/src/mount/Makefile.am b/src/mount/Makefile.am
index b48d842..6aaaaa4 100644
--- a/src/mount/Makefile.am
+++ b/src/mount/Makefile.am
@@ -41,3 +41,4 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
+AM_LDFLAGS		= -Wl,--as-needed
diff --git a/src/nfsref/Makefile.am b/src/nfsref/Makefile.am
index 71e9242..6574db7 100644
--- a/src/nfsref/Makefile.am
+++ b/src/nfsref/Makefile.am
@@ -40,3 +40,4 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
+AM_LDFLAGS		= -Wl,--as-needed
diff --git a/src/nsdbc/Makefile.am b/src/nsdbc/Makefile.am
index 0b32082..5c4f865 100644
--- a/src/nsdbc/Makefile.am
+++ b/src/nsdbc/Makefile.am
@@ -42,3 +42,4 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I$(top_srcdir)/src/include -I/usr/include/tirpc
+AM_LDFLAGS		= -Wl,--as-needed
diff --git a/src/nsdbparams/Makefile.am b/src/nsdbparams/Makefile.am
index 0da4d0c..e18011a 100644
--- a/src/nsdbparams/Makefile.am
+++ b/src/nsdbparams/Makefile.am
@@ -40,3 +40,4 @@  AM_CFLAGS		= -ggdb -fstrict-aliasing \
 			  -Wall -Wextra -pedantic -Wformat=2 \
 			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
+AM_LDFLAGS		= -Wl,--as-needed