diff mbox series

[3/5] xfsprogs: LDFLAGS comes from configure, not environment

Message ID 20200324001928.17894-4-david@fromorbit.com (mailing list archive)
State Accepted
Headers show
Series xfsprogs: miscellenaous patches | expand

Commit Message

Dave Chinner March 24, 2020, 12:19 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

When doing:

$ LDFLAGS=foo make

bad things happen because we don't initialise LDFLAGS to an empty
string in include/builddefs.in and hence make takes wahtever is in
the environment and runs with it. This causes problems with linker
options specified correctly through configure.

We don't support overriding build flags (like CFLAGS) though the
make environment, so it was an oversight 13 years ago to allow
LDFLAGS to be overridden when adding support to custom LDFLAGS being
passed from the the configure script. This ensures we only ever use
linker flags from configure, not the make environment.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 include/builddefs.in | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Christoph Hellwig March 24, 2020, 8:44 a.m. UTC | #1
On Tue, Mar 24, 2020 at 11:19:26AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When doing:
> 
> $ LDFLAGS=foo make
> 
> bad things happen because we don't initialise LDFLAGS to an empty
> string in include/builddefs.in and hence make takes wahtever is in
> the environment and runs with it. This causes problems with linker
> options specified correctly through configure.
> 
> We don't support overriding build flags (like CFLAGS) though the
> make environment, so it was an oversight 13 years ago to allow
> LDFLAGS to be overridden when adding support to custom LDFLAGS being
> passed from the the configure script. This ensures we only ever use
> linker flags from configure, not the make environment.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/include/builddefs.in b/include/builddefs.in
index 891bf93d7aa3..6ed9d2951412 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -16,6 +16,10 @@  LTLDFLAGS = @LDFLAGS@
 CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
 BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
 
+# make sure we don't pick up whacky LDFLAGS from the make environment and
+# only use what we calculate from the configured options above.
+LDFLAGS =
+
 LIBRT = @librt@
 LIBUUID = @libuuid@
 LIBPTHREAD = @libpthread@