<div dir="ltr"><div dir="ltr" class="gmail_attr">On Sun, Jul 5, 2020 at 12:08 AM Fred Wright <<a href="mailto:fw@fwright.net" target="_blank">fw@fwright.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On Wed, 3 Jun 2020, Jason Liu wrote:<br>
<br>
[...]<br>
> A solution I found which some projects (e.g. Qemu) have implemented<br>
> basically replaces the new AppKit constants with the old AppKit ones using<br>
> *#define* directives if the OS version is below 10.12. I've created a<br>
> separate header file that gathers together a list of the constants I've<br>
> been able to find, which is modeled on information from this message:<br>
[...]<br>
<br>
It's interesting that you cite Qemu as an example of this, when the Qemu <br>
port is currently failing to build on 10.9 for reasons that look very <br>
similar to this issue. <br></blockquote><div><br></div><div>The reason why the Qemu port is probably failing is because the code in the link that I referenced was added to Qemu in 2017. It looks like Qemu has since removed those #defines, probably due to what you said at the end:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>In general, direct upstream support seems preferable when possible, but some upstream developers refuse to support old OS versions, sometimes using "security" as a lame justification.</div></blockquote><div><br></div><div>My guess, however, that the more likely reason upstream projects don't typically keep these sorts of fixes around is because they don't want it dirtying up their code for any longer than necessary. Even if you strip out the comment lines, the #defines in my file add up to over 100 lines of code that upstream projects probably don't want lingering around just for the sake of legacy support.<br></div><div><br></div><div><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div>-- </div><div>Jason Liu<br></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 5, 2020 at 12:08 AM Fred Wright <<a href="mailto:fw@fwright.net" target="_blank">fw@fwright.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On Wed, 3 Jun 2020, Jason Liu wrote:<br>
<br>
[...]<br>
> A solution I found which some projects (e.g. Qemu) have implemented<br>
> basically replaces the new AppKit constants with the old AppKit ones using<br>
> *#define* directives if the OS version is below 10.12. I've created a<br>
> separate header file that gathers together a list of the constants I've<br>
> been able to find, which is modeled on information from this message:<br>
[...]<br>
<br>
It's interesting that you cite Qemu as an example of this, when the Qemu <br>
port is currently failing to build on 10.9 for reasons that look very <br>
similar to this issue.<br>
<br>
On Sat, 4 Jul 2020, Ken Cunningham wrote:<br>
>> Some questions regarding MacPorts legacy support package<br>
>><br>
>> Jason Liu jasonliu at <a href="http://umich.edu" rel="noreferrer" target="_blank">umich.edu</a> <mailto:<a href="mailto:macports-dev%2540lists.macports.org" target="_blank">macports-dev%40lists.macports.org</a>?Subject=Re%3A%20Some%20questions%20regarding%20MacPorts%20legacy%20support%20package&In-Reply-To=%3CCAHUrRf4a%2BvaF8YLE5eAh2Fo5g2ZaZTK%2BW6ecg%3DTj7tXtgx5vvg%<a href="http://40mail.gmail.com" rel="noreferrer" target="_blank">40mail.gmail.com</a>%3E><br>
>> Sat Jul 4 20:44:59 UTC 2020<br>
[...]<br>
>> Question 1:<br>
>><br>
>> I've noticed that in MacportsLegacySupport.h and other wrapper files,<br>
>> __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is used for macOS version<br>
>> detection. I also noticed this line in MacportsLegacySupport.h:<br>
>><br>
>> /* Not needed -- #include "AvailabilityMacros.h" */<br>
>><br>
>> Would it be considered kosher to use any of the other version detection<br>
>> constants from AvailabilityMacros.h, such as MAC_OS_X_VERSION_MAX_ALLOWED?<br>
>> Or would that be considered risky/dangerous/undesirable for some reason?<br>
><br>
> We have tried to make this (so far) such that this was not needed, and <br>
> just go with the compiler default <br>
> “__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__” which is set to a number <br>
> by every compiler on Apple/Darwin systems that matches the deployment <br>
> target the compiler sees.<br>
<br>
I'm not sure where this "__ENVIRONMENT" prefix is coming from. Is that a <br>
version of the definitions created by legacy-support?<br>
<br>
Normally, there are four macros of this form available:<br>
<br>
__MAC_OS_X_VERSION_MIN_REQUIRED<br>
__MAC_OS_X_VERSION_MAX_ALLOWED<br>
MAC_OS_X_VERSION_MIN_REQUIRED<br>
MAC_OS_X_VERSION_MAX_ALLOWED<br>
<br>
The general idea is that MIN_REQUIRED is for features that weren't<br>
available before a certain OS version, and MAX_ALLOWED is for features <br>
that were *removed* after a certain OS version. Since OS versions mostly <br>
try to be backward compatible with older versions, the first one is useful <br>
far more often than the second. As a general rule, if you're not sure <br>
which one you want, then you almost certainly want MIN_REQUIRED.<br>
<br>
Since having those defined differently would only be expected in cases <br>
where the build target is a range of OS versions, and since MacPorts has <br>
no concept of "OS version universality" and hence always targets one <br>
specific OS version, once would expect the two definitions to be the same <br>
in the MacPorts environment. But aside from it being cleaner to use the <br>
correct macro for the context, there's at least one case where they're <br>
*not* the same. From the default compiler on 10.5.8:<br>
<br>
MacMini:OSX fw$ ./conftest<br>
__APPLE__ = 1<br>
__MAC_OS_X_VERSION_MIN_REQUIRED = 1058<br>
__MAC_OS_X_VERSION_MAX_ALLOWED = 1060<br>
_POSIX_VERSION = 200112<br>
<br>
Thus, using MAX_ALLOWED to distinguish 10.5 from 10.6 doesn't work. There <br>
are several ports that don't build on 10.5 for precisely this reason.<br>
<br>
As far as the double-undersore versus non-double-underscore aspect is <br>
concerned, the double-underscore versions are usually defined by the <br>
compiler itself (with no includes), but sometimes not, in which case it's <br>
necessary to include Availability.h (but *not* necessarily <br>
AvailabilityMacros.h). The non-double-underscore versions are defined in <br>
AvailabilityMacros.h. Hence, any use of those demands including <br>
AvailabilityMacros.h.<br>
<br>
If anyone can explain why there's ever a reason to use the <br>
non-double-underscore versions, I'd like to hear it. Otherwise, doing so <br>
is simply adding a dependency on an include that might not otherwise be <br>
needed, and the double-underscore versions are preferable.<br>
<br>
This is also something which some ports get wrong and have broken builds <br>
or missing features as a consequence.<br>
<br>
>> Question 2:<br>
>><br>
>> A related question is that in MacportsLegacySupport.h, you guys use version<br>
>> numbers such as 101300, 1070, etc. instead of the constants that are<br>
>> defined in AvailabilityMacros.h, such as MAC_OS_X_VERSION_10_13,<br>
>> MAC_OS_X_VERSION_10_7, etc. Is there any particular reason for not using<br>
>> the constants and going with the actual integer numbers? It looks like not<br>
>> even Apple's own source code is consistent with this. In<br>
>> AvailabilityMacros.h, they use the version number constants<br>
>> MAC_OS_X_VERSION_10_*, but in other header files like assert.h, pthread.h,<br>
>> etc., they use the raw integers, i.e. 1070.<br>
>><br>
><br>
> We are sticking with the numbers. See this <br>
> <<a href="https://trac.macports.org/wiki/LeopardSDKFixes#Incorrect__MAC_OS_X_VERSION_MAX_ALLOWED" rel="noreferrer" target="_blank">https://trac.macports.org/wiki/LeopardSDKFixes#Incorrect__MAC_OS_X_VERSION_MAX_ALLOWED</a>> <br>
> for the initial inspiration for that, but it just avoids a lot of <br>
> confusion about which constants are available in which files and when.<br>
<br>
Yes, the basic problem is that older includes don't have the newer <br>
definitions. So in general, if you want to support a wide range of OS <br>
versions, it's best to stick to the numeric constants.<br>
<br>
>> Question 3:<br>
>><br>
>> As you can see from the attached file, I am currently creating a wrapper<br>
>> for AppKit.h. However, in the projects that I'm trying to package for<br>
>> MacPorts, their code usually uses '#include <Cocoa/Cocoa.h>'; and the<br>
>> system Cocoa.h, in turn, has a '#import <AppKit/AppKit.h>'. Is this going<br>
>> to be a problem? Is the MacPorts legacy support package able to intervene<br>
>> and insert its wrapper files even if a project's source code doesn't<br>
>> directly #include/#import that specific header file, but instead, the<br>
>> header to be patched is nested somewhere inside a tree/chain of header<br>
>> #includes?<br>
>><br>
><br>
> This will be — something new. Nobody actually knows how well this will work.<br>
<br>
It's also worth noting that this particular kind of fix probably only <br>
needs include additions and no library additions, which is something the <br>
PortGroup may not be set up to handle. Of course some ports may need the <br>
added library for *other* reasons, and that needs to be handled correctly.<br>
<br>
> It probably might best be something optionally used rather than a <br>
> default in legacysupport, as the opportunity for unexpected wreckage <br>
> seems high. On the other hand, after year or so, if it helps but doesn’t <br>
> break things, it might be defaultable.<br>
><br>
> If a year or so sounds long, don’t worry. I wrote up the first version <br>
> of legacysupport as “SnowLeopardFixes” in 2016, and it did not get <br>
> really adopted until several years later, after a great deal of <br>
> discussion.<br>
><br>
> There are still many opinions that it should not be used, and the issues <br>
> / fixes sent upstream instead, but I think we’re all coming to realize <br>
> that something like legacysupprt is the only way forward if we’re going <br>
> to support older systems.<br>
<br>
In general, direct upstream support seems preferable when possible, but <br>
some upstream developers refuse to support old OS versions, sometimes <br>
using "security" as a lame justification.<br>
<br>
Fred Wright</blockquote></div>