Re: git: 415a0ce02c9e - main - Revert Make newly POSIX functions visible

From: <shurd_at_FreeBSD.org>
Date: Thu, 20 Mar 2025 11:14:31 UTC
On 2025-03-20 05:55, Warner Losh wrote:
>
>
> On Thu, Mar 20, 2025, 1:42 AM Stephen Hurd <shurd@freebsd.org> wrote:
>
>     The branch main has been updated by shurd:
>
>     URL:
>     https://cgit.FreeBSD.org/src/commit/?id=415a0ce02c9ee2c15c7973b2dfbddda71f6344a2
>     <https://cgit.FreeBSD.org/src/commit/?id=415a0ce02c9ee2c15c7973b2dfbddda71f6344a2>
>
>     commit 415a0ce02c9ee2c15c7973b2dfbddda71f6344a2
>     Author:     Stephen Hurd <shurd@FreeBSD.org>
>     AuthorDate: 2025-03-20 07:15:15 +0000
>     Commit:     Stephen Hurd <shurd@FreeBSD.org>
>     CommitDate: 2025-03-20 07:41:27 +0000
>
>         Revert Make newly POSIX functions visible
>
>         Summary:
>         This reverts commit d7efac1be1441c122f7fb9de51a409172f21326c.
>         This reverts commit 9d0eea9422d075c8a6924b33161d2d5abfb4072a.
>
>         Some ports (specifically Python) define __BSD_VISIBLE
>     themselves, so
>         the change from __BSD_VISIBLE to __POSIX_VISIBLE >= 202405
>     makes them
>         fail.
>
>
> That's not legal. Defining __BSD_VISIBLE directly is illegal and won't 
> work right. Can't work right and should likely be a compile time 
> error. With am exp run to fix.

The Python commit that added it for the curious:

https://github.com/python/cpython/commit/abccf41a7d616cc950510ad4a3526b11e012ee24

22 years ago for 5.x

The root of their usage appears to be the use of _XOPEN_SOURCE 700 with 
the following comment:

# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
# disable features if it is defined, without any means to access these
# features as extensions. For these systems, we skip the definition of
# _XOPEN_SOURCE. Before adding a system to the list to gain access to
# some feature, make sure there is no alternative way to access this
# feature. Also, when using wildcards, make sure you have verified the
# need for not defining _XOPEN_SOURCE on all systems matching the
# wildcard, and that the wildcard does not include future systems
# (which may remove their limitations).

They mention _GNU_SOURCE to "re-enable" Linux extensions, so apparently 
went looking for the same thing on BSDs and found _NETBSD_SOURCE for 
NetBSD, _DARWIN_C_SOURCE for macOS... and __BSD_VISIBLE for FreeBSD

I assume they started using _XOPEN_SOURCE for the wchar.h stuff and just 
followed the path of least resistance.

I do note that the (new for 15?) cdefs(9) makes it clear that 
_BSD_SOURCE is the correct way to explicitly ask for everything now, 
though there doesn't seem to be any explicit support for that yet 
(basically, it's assumed unless one of the other mutually exclusive 
macros are defined).