From 20f61faaed3b335d792e38892d826054d2ac9f15 Mon Sep 17 00:00:00 2001
From: Saagar Jha <saagar@saagarjha.com>
Date: Tue, 15 Jun 2021 04:08:23 -0700
Subject: [PATCH] Darwin, config: Amend for Darwin 21 / macOS 12.
It seems that the OS major version is now tracking the kernel
major version - 9. Minor version tracking is unknown.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Signed-off-by: Saagar Jha <saagar@saagarjha.com>
gcc/ChangeLog:
* config.gcc: Adjust for Darwin21.
* config/darwin-c.c (macosx_version_as_macro): Likewise.
* config/darwin-driver.c (validate_macosx_version_min):
Likewise.
(darwin_find_version_from_kernel): Likewise.
---
gcc/config.gcc | 6 +++---
gcc/config/darwin-c.c | 2 +-
gcc/config/darwin-driver.c | 10 +++++-----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git gcc/config.gcc.orig gcc/config.gcc
index 498c51e619de772aecac0ad9303fdb72c4db930b..d430c24e4749c66d510f503e9389362a93e6da97 100644
old
|
new
|
case ${target} in |
679 | 679 | *-*-darwin[4-9]* | *-*-darwin1[0-9]*) |
680 | 680 | macos_min=`expr $darwin_maj - 4` |
681 | 681 | ;; |
682 | | *-*-darwin20*) |
683 | | # Darwin 20 corresponds to macOS 11. |
684 | | macos_maj=11 |
| 682 | *-*-darwin2*) |
| 683 | # Darwin 20 corresponds to macOS 11, Darwin 21 to macOS 12. |
| 684 | macos_maj=`expr $darwin_maj - 9` |
685 | 685 | def_ld64=609.0 |
686 | 686 | ;; |
687 | 687 | *-*-darwin) |
diff --git gcc/config/darwin-c.c.orig gcc/config/darwin-c.c
index 951a998775f83e16ed6c11963e6e9eb1286c51a7..62d28fcea501bbcb9eb403c74793af45eb91ca7f 100644
old
|
new
|
macosx_version_as_macro (void) |
691 | 691 | if (!version_array) |
692 | 692 | goto fail; |
693 | 693 | |
694 | | if (version_array[MAJOR] < 10 || version_array[MAJOR] > 11) |
| 694 | if (version_array[MAJOR] < 10 || version_array[MAJOR] > 12) |
695 | 695 | goto fail; |
696 | 696 | |
697 | 697 | if (version_array[MAJOR] == 10 && version_array[MINOR] < 10) |
diff --git gcc/config/darwin-driver.c.orig gcc/config/darwin-driver.c
index 0b86bb6faf7ca246afd23d43f716242f3d802123..3e02d003cd19dabc9518e21655586768feae6756 100644
old
|
new
|
validate_macosx_version_min (const char *version_str) |
64 | 64 | |
65 | 65 | major = strtoul (version_str, &end, 10); |
66 | 66 | |
67 | | if (major < 10 || major > 11 ) /* MacOS 10 and 11 are known. */ |
| 67 | if (major < 10 || major > 12 ) /* macOS 10, 11, and 12 are known. */ |
68 | 68 | return NULL; |
69 | 69 | |
70 | 70 | /* Skip a separating period, if there's one. */ |
71 | 71 | version_str = end + ((*end == '.') ? 1 : 0); |
72 | 72 | |
73 | | if (major == 11 && *end != '\0' && !ISDIGIT (version_str[0])) |
74 | | /* For MacOS 11, we allow just the major number, but if the minor is |
| 73 | if (major > 10 && *end != '\0' && !ISDIGIT (version_str[0])) |
| 74 | /* For macOS 11+, we allow just the major number, but if the minor is |
75 | 75 | there it must be numeric. */ |
76 | 76 | return NULL; |
77 | | else if (major == 11 && *end == '\0') |
| 77 | else if (major > 10 && *end == '\0') |
78 | 78 | /* We will rewrite 11 => 11.0.0. */ |
79 | 79 | need_rewrite = true; |
80 | 80 | else if (major == 10 && (*end == '\0' || !ISDIGIT (version_str[0]))) |
… |
… |
darwin_find_version_from_kernel (void) |
172 | 172 | if (minor_vers > 0) |
173 | 173 | minor_vers -= 1; /* Kernel 20.3 => macOS 11.2. */ |
174 | 174 | /* It's not yet clear whether patch level will be considered. */ |
175 | | asprintf (&new_flag, "11.%02d.00", minor_vers); |
| 175 | asprintf (&new_flag, "%d.%02d.00", major_vers - 9, minor_vers); |
176 | 176 | } |
177 | 177 | else if (major_vers - 4 <= 4) |
178 | 178 | /* On 10.4 and earlier, the old linker is used which does not |