public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20)
@ 2022-03-10 19:36 simon at pushface dot org
  2022-06-12 22:23 ` [Bug target/104871] " cvs-commit at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: simon at pushface dot org @ 2022-03-10 19:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

            Bug ID: 104871
           Summary: macosx-version-min wrong for macOS >= Big Sur
                    (darwin20)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
  Target Milestone: ---

Created attachment 52603
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52603&action=edit
Patch, discards minor version

This is the same sort of problem as in PR80204: at present, GCC 11 &
12 assume that if the OS version is >= 20, the compiler should see
--mmacosx-version-min={major - 9}.{minor -1}.0, e.g. for OS version
21.3.0 that would be 12.2.0 (the linker sees -macosx-version-min, same
arguments).

However, the native compiler clang treats 21.3.0 as 12.0.0: the
compiler sees
   -triple x86_64-apple-macosx12.0.0
and the linker sees
   -platform_version macos 12.0.0
the result of which is that linking a main object file built with clang
and one built with gcc results in

  ld: warning: object file (null.o) was built for newer macOS version (12.2)
  than being linked (12.0)

I propose the following patch, which works fine for me (darwin 21.3.0).

diff --git a/gcc/config/darwin-driver.cc b/gcc/config/darwin-driver.cc
index 30e0e64f280..ca2a1ca1a60 100644
--- a/gcc/config/darwin-driver.cc
+++ b/gcc/config/darwin-driver.cc
@@ -164,15 +164,9 @@ darwin_find_version_from_kernel (void)
      version - 1 (at least for the initial releases).  */
   if (major_vers >= 20)
     {
-      int minor_vers = *version_p++ - '0';
-      if (ISDIGIT (*version_p))
-       minor_vers = minor_vers * 10 + (*version_p++ - '0');
-      if (*version_p++ != '.')
-       goto parse_failed;
-      if (minor_vers > 0)
-       minor_vers -= 1; /* Kernel 20.3 => macOS 11.2.  */
-      /* It's not yet clear whether patch level will be considered.  */
-      asprintf (&new_flag, "%d.%02d.00", major_vers - 9, minor_vers);
+      /* clang doesn't include the minor version in the object file,
+         nor does it pass it to ld  */
+      asprintf (&new_flag, "%d.00.00", major_vers - 9);
     }
   else if (major_vers - 4 <= 4)
     /* On 10.4 and earlier, the old linker is used which does not

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/104871] macosx-version-min wrong for macOS >= Big Sur (darwin20)
  2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
@ 2022-06-12 22:23 ` cvs-commit at gcc dot gnu.org
  2022-06-15 19:08 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-12 22:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:add1adaa17a294ea25918ffb4fdd40f115362632

commit r13-1058-gadd1adaa17a294ea25918ffb4fdd40f115362632
Author: Simon Wright <simon@pushface.org>
Date:   Sun Jun 12 17:01:22 2022 +0100

    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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/104871] macosx-version-min wrong for macOS >= Big Sur (darwin20)
  2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
  2022-06-12 22:23 ` [Bug target/104871] " cvs-commit at gcc dot gnu.org
@ 2022-06-15 19:08 ` cvs-commit at gcc dot gnu.org
  2022-06-15 19:17 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-15 19:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:64f5efce03c248af7f51d600b5519f46f64eea48

commit r12-8486-g64f5efce03c248af7f51d600b5519f46f64eea48
Author: Simon Wright <simon@pushface.org>
Date:   Sun Jun 12 17:01:22 2022 +0100

    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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/104871] macosx-version-min wrong for macOS >= Big Sur (darwin20)
  2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
  2022-06-12 22:23 ` [Bug target/104871] " cvs-commit at gcc dot gnu.org
  2022-06-15 19:08 ` cvs-commit at gcc dot gnu.org
@ 2022-06-15 19:17 ` cvs-commit at gcc dot gnu.org
  2023-05-16 19:04 ` cvs-commit at gcc dot gnu.org
  2023-07-16 17:19 ` fxcoudert at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-15 19:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:82b771fd6cab421d92cc074a79f98389ac8569c3

commit r10-10848-g82b771fd6cab421d92cc074a79f98389ac8569c3
Author: Simon Wright <simon@pushface.org>
Date:   Sun Jun 12 17:01:22 2022 +0100

    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.c (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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/104871] macosx-version-min wrong for macOS >= Big Sur (darwin20)
  2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
                   ` (2 preceding siblings ...)
  2022-06-15 19:17 ` cvs-commit at gcc dot gnu.org
@ 2023-05-16 19:04 ` cvs-commit at gcc dot gnu.org
  2023-07-16 17:19 ` fxcoudert at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-16 19:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain D Sandoe
<iains@gcc.gnu.org>:

https://gcc.gnu.org/g:3417f095f149ba09ca9d4f62bfaf661819a04333

commit r11-10782-g3417f095f149ba09ca9d4f62bfaf661819a04333
Author: Simon Wright <simon@pushface.org>
Date:   Sun Jun 12 17:01:22 2022 +0100

    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.c (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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/104871] macosx-version-min wrong for macOS >= Big Sur (darwin20)
  2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
                   ` (3 preceding siblings ...)
  2023-05-16 19:04 ` cvs-commit at gcc dot gnu.org
@ 2023-07-16 17:19 ` fxcoudert at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2023-07-16 17:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104871

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.5
                 CC|                            |fxcoudert at gcc dot gnu.org
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #5 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Fixed on all open branches.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-16 17:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 19:36 [Bug c/104871] New: macosx-version-min wrong for macOS >= Big Sur (darwin20) simon at pushface dot org
2022-06-12 22:23 ` [Bug target/104871] " cvs-commit at gcc dot gnu.org
2022-06-15 19:08 ` cvs-commit at gcc dot gnu.org
2022-06-15 19:17 ` cvs-commit at gcc dot gnu.org
2023-05-16 19:04 ` cvs-commit at gcc dot gnu.org
2023-07-16 17:19 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).