deprecate "libbsd," strongly recommend using "libbsd-overlay"
Would you consider deprecating libbsd on non-overlay mode? By that, I mean giving a compile-time warning if libbsd is used without the overlay mode, and only documenting using libbsd through libbsd-overlay.pc. I'm willing to do the (little) work it would require, I'm just asking before doing it.
The issue with not using the overlay mode is that it creates programs that use BSD functions, but don't actually compile on BSD. It's a simple header inclusion issue: the BSDs don't have headers inside <bsd/*>
. Fixing it (without the overlay mode) means using an #ifdef
and/or more build system trickery, when it could be done with less work, less conditional compilation, and without touching the C code by using libbsd-overlay.
I suggest this scrot configure.ac tidbit should be the only official (autotools) way to use libbsd.
This is a real issue, many programmers use libbsd by passing "-lbsd" to the linker manually and don't seem to realize their use case could benefit from the pkg-config and the overlay mode. libbsd isn't used only to port BSD programs, it's also used as "that library with strlcpy() and setproctitle()," so we have a few Linux-centric programs that paradoxically have to be ported to BSD because they use BSD functions. Not using pkg-config creates another issue: OpenBSD, NetBSD, and FreeBSD don't include packages in the default linker path. This isn't currently an issue for libbsd because it only runs on Linux, but the BSDs are not 100% compatible, so this library makes sense even within the BSD ecosystem.
The only downside I'm aware of is that libbsd-overlay breaks compilers without an #include_next
directive.
A "Hello, world!" program that uses #include_next
shows the extension is widely supported outside GCC/Clang:
#include_next <stdio.h>
int
main(void)
{
puts("Hello, world!");
}
Successfully builds with cparser, tcc, and CompCert. Doesn't build with MSVC, although it does build with clang-cl (clang with a MSVC command-line interface).
My interest in this is that I'm writing my own libbsd-like library which only provides an overlay mode at https://github.com/guijan/libobsd. I've already ported it to a large amount of platforms: Windows (including MSVC), MacOS, FreeBSD, dietlibc, Haiku, and more. I provide a libbsd-overlay.pc file for libbsd compatibility and I've already been bitten by the portability issues that not using the overlay mode creates. I'd like to make it easy on myself and on users to write portable programs and use either libbsd or libobsd to reduce the amount of porting work and fallback code out there, and I believe leaving the non-overlay mode undocumented and deprecated to keep current code working but strongly direct people towards libbsd-overlay would be the way to do it.