Re: xfsprogs-5.2.0 FTBFS: ../libxfs/.libs/libxfs.so: undefined reference to `xfs_ag_geom_health'

Dave Chinner
2019-08-12T21:46:01Z

On Mon, Aug 12, 2019 at 12:57:32PM +0200, Thomas Deutschmann wrote:
> Hi,
>
> On 2019-08-12 06:30, Dave Chinner wrote:
> >>> In a clear environment, do:
> >>>
> >>>> tar -xaf xfsprogs-5.2.0.tar.xz
> >>>> cd xfsprogs-5.2.0
> >>>> export CFLAGS="-O2 -pipe -march=ivybridge -mtune=ivybridge -mno-xsaveopt"
> >>>> export LDFLAGS="-Wl,-O1 -Wl,--as-needed"
> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >> Don't do this.
> >>
> >> "--as-needed" is the default linker behaviour since gcc 4.x. You do
> >> not need this. As for passing "-O1" to the linker, that's not going
> >> to do anything measurable for you. Use --enable-lto to turn on link
> >> time optimisations if they are supported by the compiler.
> >
> > Ok, I could reproduce your link time failure for a while with
> > --enable-lto, but I ran 'make distclean' and the problem went away
> > completely. And I can build with your options successfully, too:
> >
> > $ make realclean
> > $ make configure
> > <builds new configure script>
> > $ LDFLAGS="-Wl,-O1 -Wl,--as-needed" ./configure
>
> That's not the correct way to reproduce. It's really important to
> _export_ the variable to trigger the problem and _this_ is a problem in
> xfsprogs' build system.

Which means you are overriding the LDFLAGS set by configure when
you _run make_, not just telling configure to use those LDFLAGS.

That's why _make_ is getting screwed up - it is doing exactly what
you are telling it to do, and that is to overrides every occurrence
of LDFLAGS with your exported options rather than using the correct
set configure calculated and specified.

Exporting your CFLAGS and LDFLAGS is the wrong thing to doing
- they should only ever be passed to the configure invocation and
not remain to pollute the build environment after you've run
configure.

> But keep in mind that 3x "-Wl,-O1 -Wl,--as-needed" don't cause a failure
> without "--disable-static" for me... that's just the answer for your
> question where this is coming from.

As I've already explained, --disable-static should never have worked
in the first place, because the internal XFS libraries are
statically linked and need to be build statically, which
--disable-static turns off.

Indeed:

$ git reset --hard v5.1.0; make realclean; make configure ; ./configure --disable-static ; make -j 32
......
[LD] xfs_estimate
[LD] xfs_mdrestore
[LD] xfs_rtcp
[LD] libhandle.la
[LD] libxcmd.la
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_new_probe_from_filename'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_topology_get_alignment_offset'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_probe_get_topology'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_do_fullprobe'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_topology_get_logical_sector_size'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_topology_get_optimal_io_size'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_probe_lookup_value'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_free_probe'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_topology_get_physical_sector_size'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_probe_enable_partitions'
/usr/bin/ld: ../libfrog/.libs/libfrog.so: undefined reference to `blkid_topology_get_minimum_io_size'
$

Yup, --disable-static is broken in v5.1.0, too. I'm guessing it
hasn't worked for a long time....

So, please remove --disable-static from your build, and everything
will be fine. I'll write up a patch to remove --disable-static from
the configure script so this broken option can't be specified any
more.

Cheers,

Dave.