Re: [PATCH] build: fix FreeBSD build when sysinfo compat library installed

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

 



On Fri, Jul 4, 2025 at 6:26 PM Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> wrote:
> Commit 50dec7c566 ("config.mak.uname: add sysinfo() configuration for
> cygwin", 2025-04-17) and later commit 187ce0222f ("configure.ac: upgrade
> to a compilation check for sysinfo", 2025-05-19) added a 'sysinfo()'
> check to the autoconf build.
>
> The FreeBSD system has an optional sysinfo compatibility library, used
> to assist in porting software, which causes the build to fail when it
> is installed. The reason for the failure is the lack of '-lsysinfo'
> during the linking step.
>
> Several solutions were considered:
>
>   - add an 'linking' check to configure.ac in order to determine the

s/an/a/

(not worth a reroll)

>     need to link a separate library (-lsysinfo). (This would require
>     a similar change to meson.build).
>
>   - change the order of the preprocessor conditionals in the total_ram()
>     function in 'builtin/gc.c', so that the *BSD sysctl() function
>     (in the HAVE_BSD_SYSCTL block) takes priority over the sysinfo()
>     function (in the HAVE_SYSINFO block).
>
>   - suppress the setting of HAVE_SYSINFO when HAVE_BSD_SYSCTL has been
>     defined (in both configure.ac and meson.build).
>
> The first solution above, while simple, adds unnecessary code (the
> sysinfo compat function is likely implemented using sysctl() anyway)
> when git is happy to use sysctl() on *BSD systems.
>
> The second solution would only be required by the autoconf and meson
> build systems, the Makefile already sets the build variables to the
> required values (since they are not 'auto-detected').
>
> Here we opt for the final solution above, since it only requires that
> we prioritise the 'auto-detected' build variables in the autoconf and
> meson builds.

The final solution is almost certainly good enough (and is definitely
simple), although the second solution has the benefit that it "fixes"
the problem once and for all even if someone defines both
HAVE_BSD_SYSCTL and HAVE_SYSINFO (say, in config.mak), assuming I'm
understanding correctly.

> In order to fix the FreeBSD build, move the sysinfo() check after the
> determination of the HAVE_BSD_SYSCTL build variable, suppressing the
> setting of HAVE_SYSINFO if HAVE_BSD_SYSCTL is defined. Apply this logic
> to both the configure.ac and meson.build file.

Nicely described. I wasn't really following along with the discussion,
but this commit message summarizes the situation well, so I can
understand the reason for the change and (I hope) the implications.

> Tested-by: Renato Botelho <garga@xxxxxxxxxxx>
> Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>





[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