summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wright <simon@pushface.org>2022-06-12 17:01:22 +0100
committerIain Sandoe <iain@sandoe.co.uk>2022-06-15 20:08:00 +0100
commit64f5efce03c248af7f51d600b5519f46f64eea48 (patch)
tree36044bdae1fe233911b6469c82d79d3d882e09cf
parentDarwin: Future-proof -mmacosx-version-min (diff)
downloadgcc-64f5efce03c248af7f51d600b5519f46f64eea48.tar.gz
gcc-64f5efce03c248af7f51d600b5519f46f64eea48.tar.bz2
gcc-64f5efce03c248af7f51d600b5519f46f64eea48.tar.xz
Darwin: Truncate kernel-provided version to OS major for Darwin >= 20.
In common with system tools, GCC uses a version obtained from the kernel as the prevailing macOS target, when that is not overridden by command line or environment versions (i.e. mmacosx-version-min=, MACOSX_DEPLOYMENT_TARGET). Presently, GCC assumes that if the OS version is >= 20, the value used should include both major and minium version identifiers. However the system tools (for those versions) truncate the value to the major version - this leads to link errors when combining objects built with clang and GCC for example: ld: warning: object file (null.o) was built for newer macOS version (12.2) than being linked (12.0) The change here truncates the values GCC uses to the major version. gcc/ChangeLog: PR target/104871 * config/darwin-driver.cc (darwin_find_version_from_kernel): If the OS version is darwin20 (macOS 11) or greater, truncate the version to the major number. (cherry picked from commit add1adaa17a294ea25918ffb4fdd40f115362632)
-rw-r--r--gcc/config/darwin-driver.cc16
1 files changed, 5 insertions, 11 deletions
diff --git a/gcc/config/darwin-driver.cc b/gcc/config/darwin-driver.cc
index 30e0e64f280..00287f3d5ec 100644
--- a/gcc/config/darwin-driver.cc
+++ b/gcc/config/darwin-driver.cc
@@ -160,19 +160,13 @@ darwin_find_version_from_kernel (void)
160 goto parse_failed; 160 goto parse_failed;
161 161
162 /* Darwin20 sees a transition to macOS 11. In this, it seems that the 162 /* Darwin20 sees a transition to macOS 11. In this, it seems that the
163 mapping to macOS minor version is now shifted to the kernel minor 163 mapping to macOS minor version and patch level is now always 0, 0
164 version - 1 (at least for the initial releases). */ 164 (at least for macOS 11 and 12). */
165 if (major_vers >= 20) 165 if (major_vers >= 20)
166 { 166 {
167 int minor_vers = *version_p++ - '0'; 167 /* Apple clang doesn't include the minor version or the patch level
168 if (ISDIGIT (*version_p)) 168 in the object file, nor does it pass it to ld */
169 minor_vers = minor_vers * 10 + (*version_p++ - '0'); 169 asprintf (&new_flag, "%d.00.00", major_vers - 9);
170 if (*version_p++ != '.')
171 goto parse_failed;
172 if (minor_vers > 0)
173 minor_vers -= 1; /* Kernel 20.3 => macOS 11.2. */
174 /* It's not yet clear whether patch level will be considered. */
175 asprintf (&new_flag, "%d.%02d.00", major_vers - 9, minor_vers);
176 } 170 }
177 else if (major_vers - 4 <= 4) 171 else if (major_vers - 4 <= 4)
178 /* On 10.4 and earlier, the old linker is used which does not 172 /* On 10.4 and earlier, the old linker is used which does not