diff mbox series

[2/2] xfsprogs: Fix --disable-static option build

Message ID 20190813051421.21137-3-david@fromorbit.com (mailing list archive)
State Superseded
Headers show
Series xfsprogs: "Fix" --disable-static option | expand

Commit Message

Dave Chinner Aug. 13, 2019, 5:14 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

Internal xfsprogs libraries are linked statically to binaries as
they are not shipped libraries. Using --disable-static prevents the
internal static libraries from being built and this breaks dead code
elimination and results in linker failures from link dependencies
introduced by dead code.

We can't remove the --disable-static option that causes this as it
is part of the libtool/autoconf generated infrastructure. We can,
however, reliably detect whether static library building has been
disabled after the libtool infrastructure has been configured.
Therefore, add a check to determine the static build status and
abort the configure script with an error if we have been configured
not to build static libraries.

This build command now succeeds:

$ make realclean; make configure; ./configure --disable-static ; make

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 libfrog/Makefile | 2 ++
 libxcmd/Makefile | 2 ++
 libxfs/Makefile  | 2 ++
 libxlog/Makefile | 2 ++
 4 files changed, 8 insertions(+)

Comments

Darrick J. Wong Aug. 13, 2019, 2:28 p.m. UTC | #1
On Tue, Aug 13, 2019 at 03:14:20PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> Internal xfsprogs libraries are linked statically to binaries as
> they are not shipped libraries. Using --disable-static prevents the
> internal static libraries from being built and this breaks dead code
> elimination and results in linker failures from link dependencies
> introduced by dead code.
> 
> We can't remove the --disable-static option that causes this as it
> is part of the libtool/autoconf generated infrastructure. We can,
> however, reliably detect whether static library building has been
> disabled after the libtool infrastructure has been configured.
> Therefore, add a check to determine the static build status and
> abort the configure script with an error if we have been configured
> not to build static libraries.

Uh... is this missing from the patch?  I don't see anything that aborts
configure.  Though I sense this might be your v2 solution that works
around --disable-static via the ld command line and leaves configure
alone...? :)

--D

> This build command now succeeds:
> 
> $ make realclean; make configure; ./configure --disable-static ; make
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  libfrog/Makefile | 2 ++
>  libxcmd/Makefile | 2 ++
>  libxfs/Makefile  | 2 ++
>  libxlog/Makefile | 2 ++
>  4 files changed, 8 insertions(+)
> 
> diff --git a/libfrog/Makefile b/libfrog/Makefile
> index f5a0539b3f03..4d79983eb910 100644
> --- a/libfrog/Makefile
> +++ b/libfrog/Makefile
> @@ -9,6 +9,8 @@ LTLIBRARY = libfrog.la
>  LT_CURRENT = 0
>  LT_REVISION = 0
>  LT_AGE = 0
> +# we need a static build even if --disable-static is specified
> +LTLDFLAGS += -static
>  
>  CFILES = \
>  avl64.c \
> diff --git a/libxcmd/Makefile b/libxcmd/Makefile
> index 914bec024c46..f9bc1c5c483a 100644
> --- a/libxcmd/Makefile
> +++ b/libxcmd/Makefile
> @@ -9,6 +9,8 @@ LTLIBRARY = libxcmd.la
>  LT_CURRENT = 0
>  LT_REVISION = 0
>  LT_AGE = 0
> +# we need a static build even if --disable-static is specified
> +LTLDFLAGS += -static
>  
>  CFILES = command.c input.c help.c quit.c
>  
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index 8c681e0b9083..d1688dc3853a 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -9,6 +9,8 @@ LTLIBRARY = libxfs.la
>  LT_CURRENT = 0
>  LT_REVISION = 0
>  LT_AGE = 0
> +# we need a static build even if --disable-static is specified
> +LTLDFLAGS += -static
>  
>  # headers to install in include/xfs
>  PKGHFILES = xfs_fs.h \
> diff --git a/libxlog/Makefile b/libxlog/Makefile
> index bdea6abacea4..b0f5ef154133 100644
> --- a/libxlog/Makefile
> +++ b/libxlog/Makefile
> @@ -9,6 +9,8 @@ LTLIBRARY = libxlog.la
>  LT_CURRENT = 0
>  LT_REVISION = 0
>  LT_AGE = 0
> +# we need a static build even if --disable-static is specified
> +LTLDFLAGS += -static
>  
>  CFILES = xfs_log_recover.c util.c
>  
> -- 
> 2.23.0.rc1
>
Dave Chinner Aug. 13, 2019, 9:33 p.m. UTC | #2
On Tue, Aug 13, 2019 at 07:28:01AM -0700, Darrick J. Wong wrote:
> On Tue, Aug 13, 2019 at 03:14:20PM +1000, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> > 
> > Internal xfsprogs libraries are linked statically to binaries as
> > they are not shipped libraries. Using --disable-static prevents the
> > internal static libraries from being built and this breaks dead code
> > elimination and results in linker failures from link dependencies
> > introduced by dead code.
> > 
> > We can't remove the --disable-static option that causes this as it
> > is part of the libtool/autoconf generated infrastructure. We can,
> > however, reliably detect whether static library building has been
> > disabled after the libtool infrastructure has been configured.
> > Therefore, add a check to determine the static build status and
> > abort the configure script with an error if we have been configured
> > not to build static libraries.
> 
> Uh... is this missing from the patch?  I don't see anything that aborts
> configure.  Though I sense this might be your v2 solution that works
> around --disable-static via the ld command line and leaves configure
> alone...? :)

Ugh, forgot to refresh the patch after updating the comment. That
paragraph should read:

	We can't remove the --disable-static option that causes this as it
	is part of the libtool/autoconf generated infrastructure. We can,
	however, override --disable-static on a per-library basis inside the
	build by passing -static to the libtool link command. Therefore, add
	-static to all the internal libraries we build and link statically
	to the shipping binaries.

Cheers,

Dave.
diff mbox series

Patch

diff --git a/libfrog/Makefile b/libfrog/Makefile
index f5a0539b3f03..4d79983eb910 100644
--- a/libfrog/Makefile
+++ b/libfrog/Makefile
@@ -9,6 +9,8 @@  LTLIBRARY = libfrog.la
 LT_CURRENT = 0
 LT_REVISION = 0
 LT_AGE = 0
+# we need a static build even if --disable-static is specified
+LTLDFLAGS += -static
 
 CFILES = \
 avl64.c \
diff --git a/libxcmd/Makefile b/libxcmd/Makefile
index 914bec024c46..f9bc1c5c483a 100644
--- a/libxcmd/Makefile
+++ b/libxcmd/Makefile
@@ -9,6 +9,8 @@  LTLIBRARY = libxcmd.la
 LT_CURRENT = 0
 LT_REVISION = 0
 LT_AGE = 0
+# we need a static build even if --disable-static is specified
+LTLDFLAGS += -static
 
 CFILES = command.c input.c help.c quit.c
 
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 8c681e0b9083..d1688dc3853a 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -9,6 +9,8 @@  LTLIBRARY = libxfs.la
 LT_CURRENT = 0
 LT_REVISION = 0
 LT_AGE = 0
+# we need a static build even if --disable-static is specified
+LTLDFLAGS += -static
 
 # headers to install in include/xfs
 PKGHFILES = xfs_fs.h \
diff --git a/libxlog/Makefile b/libxlog/Makefile
index bdea6abacea4..b0f5ef154133 100644
--- a/libxlog/Makefile
+++ b/libxlog/Makefile
@@ -9,6 +9,8 @@  LTLIBRARY = libxlog.la
 LT_CURRENT = 0
 LT_REVISION = 0
 LT_AGE = 0
+# we need a static build even if --disable-static is specified
+LTLDFLAGS += -static
 
 CFILES = xfs_log_recover.c util.c