Skip to content

Commit 556ab51

Browse files
committed
Darwin: Darwin 20 is to be macOS 11 (Big Sur).
As per Nigel Tufnel's assertion "... this one goes to 11". The various parts of the code that deal with mapping Darwin versions to macOS (X) versions need updating to deal with a major version of 11. So now we have, for example: Darwin 4 => macOS (X) 10.0 … Darwin 14 => macOS (X) 10.10 ... Darwin 19 => macOS (X) 10.15 Darwin 20 => macOS 11.0 Because of the historical duplication of the "10" in macOSX 10.xx and the number of tools that expect this, it is likely that system tools will allow macos11.0 and/or macosx11.0 (despite that the latter makes little sense). Update the link test to cover Catalina (Darwin19/10.15) and Big Sur (Darwin20/11.0). gcc/ChangeLog: * config/darwin-c.c: Allow for Darwin20 to correspond to macOS 11. * config/darwin-driver.c: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/darwin-minversion-link.c: Allow for Darwin19 (macOS 10.15) and Darwin20 (macOS 11.0).
1 parent 600be7f commit 556ab51

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

gcc/config/darwin-c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ macosx_version_as_macro (void)
692692
if (!version_array)
693693
goto fail;
694694

695-
if (version_array[MAJOR] != 10)
695+
if (version_array[MAJOR] < 10 || version_array[MAJOR] > 11)
696696
goto fail;
697697

698-
if (version_array[MINOR] < 10)
698+
if (version_array[MAJOR] == 10 && version_array[MINOR] < 10)
699699
version_macro = version_as_legacy_macro (version_array);
700700
else
701701
version_macro = version_as_modern_macro (version_array);

gcc/config/darwin-driver.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ validate_macosx_version_min (const char *version_str)
6565
major = strtoul (version_str, &end, 10);
6666
version_str = end + ((*end == '.') ? 1 : 0);
6767

68-
if (major != 10) /* So far .. all MacOS 10 ... */
68+
if (major < 10 || major > 11 ) /* MacOS 10 and 11 are known. */
6969
return NULL;
7070

7171
/* Version string components must be present and numeric. */
@@ -104,7 +104,7 @@ validate_macosx_version_min (const char *version_str)
104104
if (need_rewrite)
105105
{
106106
char *new_version;
107-
asprintf (&new_version, "10.%lu.%lu", minor, tiny);
107+
asprintf (&new_version, "%2lu.%lu.%lu", major, minor, tiny);
108108
return new_version;
109109
}
110110

@@ -115,6 +115,12 @@ validate_macosx_version_min (const char *version_str)
115115
#include <sys/sysctl.h>
116116
#include "xregex.h"
117117

118+
/* Determine the version of the running OS.
119+
We only look at the first two components (ignoring the patch one) and
120+
report NN.MM.0 where NN is currently either 10 or 11 and MM is the OS
121+
minor release number.
122+
If we can't parse what the kernel gives us, warn the user, and do nothing. */
123+
118124
static char *
119125
darwin_find_version_from_kernel (void)
120126
{
@@ -125,8 +131,6 @@ darwin_find_version_from_kernel (void)
125131
char * version_p;
126132
char * new_flag;
127133

128-
/* Determine the version of the running OS. If we can't, warn user,
129-
and do nothing. */
130134
if (sysctl (osversion_name, ARRAY_SIZE (osversion_name), osversion,
131135
&osversion_len, NULL, 0) == -1)
132136
{
@@ -144,10 +148,11 @@ darwin_find_version_from_kernel (void)
144148
major_vers = major_vers * 10 + (*version_p++ - '0');
145149
if (*version_p++ != '.')
146150
goto parse_failed;
147-
148-
/* The major kernel version number is 4 plus the second OS version
149-
component. */
150-
if (major_vers - 4 <= 4)
151+
152+
/* Darwin20 sees a transition to macOS 11. */
153+
if (major_vers >= 20)
154+
asprintf (&new_flag, "11.%02d.00", major_vers - 20);
155+
else if (major_vers - 4 <= 4)
151156
/* On 10.4 and earlier, the old linker is used which does not
152157
support three-component system versions.
153158
FIXME: we should not assume this - a newer linker could be used. */

gcc/testsuite/gcc.dg/darwin-minversion-link.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
/* { dg-additional-options "-mmacosx-version-min=010.011.06 -DCHECK=101106" { target *-*-darwin15* } } */
1414
/* { dg-additional-options "-mmacosx-version-min=010.012.06 -DCHECK=101206" { target *-*-darwin16* } } */
1515
/* { dg-additional-options "-mmacosx-version-min=010.013.06 -DCHECK=101306" { target *-*-darwin17* } } */
16-
/* This next test covers 10.18 and (currently unreleased) 10.19 for now. */
17-
/* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin1[89]* } } */
16+
/* { dg-additional-options "-mmacosx-version-min=010.014.05 -DCHECK=101405" { target *-*-darwin18* } } */
17+
/* { dg-additional-options "-mmacosx-version-min=010.015.06 -DCHECK=101506" { target *-*-darwin19* } } */
18+
/* { dg-additional-options "-mmacosx-version-min=011.000.00 -DCHECK=110000" { target *-*-darwin20 } } */
1819

1920
int
2021
main ()

0 commit comments

Comments
 (0)