Re: Bug: build is broken on FreeBSD if libsysinfo is installed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 1, 2025 at 12:09 PM Renato Botelho <garga@xxxxxxxxxxx> wrote:
> On 23/06/25 11:09, Renato Botelho wrote:
> > FreeBSD has a libsysinfo package which contains GNU libc's sysinfo port.
> >   Some users reported git 2.50.0 was failing to build when this port is
> > installed and it happened because configure script detected libsysinfo
> > but -lsysinfo was not added to LDFLAGS, ending up with following error:
> >
> > scalar.o common-main.o libgit.a xdiff/lib.a reftable/libreftable.a
> > libgit.a -lz -pthread
> > ld: error: undefined symbol: sysinfo
> >
> > This patch [1] was added to git port adding a user option to enable/
> > disable libsysinfo dependency and fix LDFLAGS when it's enabled.
> >
> > I'm not sure about what is best approach for git project in this case.
> >
> > [1] https://github.com/freebsd/freebsd-ports/blob/main/devel/git/files/
> > patch-configure.ac
>
> If someone let me know what would be the desired approach here I can
> work on a patch.  Would you like to make that option conditional as the
> patch did?  Or detect if OS is FreeBSD and do something different?

It depends upon how much effort you want to put into the patch. If the
primary goal is to just get FreeBSD building again, then the least
amount of work probably would be to use AC_LINK_IFELSE (with whatever
tweaking that requires) instead of AC_COMPILE_IFELSE in configure.ac
for the sysinfo check. With that change, HAVE_SYSINFO would not get
defined if the link fails due to the missing `-lsysinfo`.

If you do want sysinfo functionality to be used by Git on FreeBSD,
then probably the most correct approach would be as follows:

(1) Add a NEEDS_LIBSYSINFO to Makefile (patterned after existing
"NEEDS_" definitions in that file). This would involve documenting it
alongside HAVE_SYSINFO, and adding something along the lines of:

    ifdef NEEDS_LIBSYSINFO
        EXTLIBS += -lsysinfo
    endif

(2) For people who build the project directly without utilizing the
"configure" script, optionally update the FreeBSD section of
config.make.uname to define HAVE_SYSINFO and NEEDS_LIBSYSINFO as
appropriate. Those definitions probably ought to be conditional based
upon some criteria that you determine so that compilation doesn't
break on older versions of FreeBSD (if they were lacking the sysinfo()
call or "libsysinfo").

(3) Update configure.ac to check whether `-lsysinfo` is needed, and
define NEEDS_LIBSYSINFO appropriately. This may mean employing both
AC_COMPILE_IFELSE and AC_LINK_IFELSE for determining HAVE_SYSINFO and
NEEDS_LIBSYSINFO, respectively, though there might be a cleaner way to
do so (I haven't put much thought into it).





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux