macos: add fallback version detection#5125
Conversation
|
Got a reference link for the build number mapping? |
yes added with last push |
|
This looks useful, nice work. Now that there is a macos-specific non-trivial data listing here, would you mind moving the macos implementation of this function into a macos-specific separate file? For example |
722ede0 to
0b4a913
Compare
Fallback to sysctl `kern.osversion` when `kern.osproductversion` is not available (prior to 10.13.4) . The mapping from `sw_vers -buildVersion` to `-productVersion` is formulaic from 10.8 to 10.15 and older is handled with switch. closes ziglang#5119
0b4a913 to
3df0a3a
Compare
|
Dear Apple: just because you can, doesn't mean you should™️ Having finally upgraded to Big Sur and look at what happens to a file.. yes a file! This means we can no longer parse *take note same file being |

Fallback to sysctl
kern.osversionwhenkern.osproductversionis notavailable (prior to 10.13.4) .
The mapping from
sw_vers -buildVersionto-productVersionisformulaic from 10.8 to 10.15 and older is handled with switch.
closes #5119
The reasoning behind using a table is we do not yet have std XML to parse
/System/Library/CoreServices/SystemVersion.plistand writing a non-robust XML parser has unknown risks; old copies ofSystemVersion.plistare hard to come by.That said, at this time I expect this table fallback will suffice until we get XML. At that time I would recommend we switch methods because it's actually via that file at startup that the kernel gets its product version.
Also I'd like to add this table is based on mapping
kern.osversiontokern.osproductversion. To usekern.osrelease(Darwin version) would be difficult -- either the Darwin version tables on wikipedia are incomplete or it does not bump whenkern.osproductversiondoes. For example,Darwin 19.0.0is inferred to be bothmacOS 10.15.0 and 10.15.1. source