public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin
@ 2021-09-30  4:15 mhjacobson at me dot com
  2021-09-30 11:49 ` [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin iains at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mhjacobson at me dot com @ 2021-09-30  4:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102537
           Summary: Objective-C: can't use >= USE_FIXUP_BEFORE paths for
                    non-Darwin
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: objc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mhjacobson at me dot com
  Target Milestone: ---

I am working on a NeXTv2-ABI-compatible Objective-C runtime for a non-Darwin
platform (AVR micros).  I'd like my Objective-C code to make use of the most
modern ABI features, namely those guarded in the code by `flag_next_runtime >=
USE_FIXUP_BEFORE`.

However, there appears to be no way to control `flag_next_runtime` (short of
modifying the compiler source).  I can set it to zero with `-fgnu-runtime` or
one with `-fnext-runtime`, but `USE_FIXUP_BEFORE` is an encoded Mac OS X
version (namely 100600, referring to Snow Leopard).

There is Darwin-specific option parsing code (`darwin_override_options()`) that
appears to set `flag_next_runtime` based on `-mmacosx-version-min`, but
obviously that doesn't run for non-Darwin targets.

I could imagine a few approaches to fixing this:

1. Parse `-mmacosx-version-min` even when the target is not Darwin, whenever
we're compiling Objective-C.  On non-Darwin, this would be interpreted as
requesting Objective-C codegen compatible with the Objective-C ABI of the
specified release of Mac OS X.

2. Allow an argument to `-fnext-runtime`, with the meaning approximately the
same as in #1.

3. Instead of using `flag_next_runtime` as a version number, switch it back to
being zero or one, and use a separate flag (perhaps the existing
`-fobjc-abi-version`?) to differentiate ABIs.

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

* [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin
  2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
@ 2021-09-30 11:49 ` iains at gcc dot gnu.org
  2021-10-18 16:48 ` mhjacobson at me dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu.org @ 2021-09-30 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement
   Last reconfirmed|                            |2021-09-30
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Matt Jacobson from comment #0)
> I am working on a NeXTv2-ABI-compatible Objective-C runtime for a non-Darwin
> platform (AVR micros).  I'd like my Objective-C code to make use of the most
> modern ABI features, namely those guarded in the code by `flag_next_runtime
> >= USE_FIXUP_BEFORE`.
> 
> However, there appears to be no way to control `flag_next_runtime` (short of
> modifying the compiler source).  I can set it to zero with `-fgnu-runtime`
> or one with `-fnext-runtime`, but `USE_FIXUP_BEFORE` is an encoded Mac OS X
> version (namely 100600, referring to Snow Leopard).

by current design, there are enough bits in the value so that ne can have N
MSBs representing the platform and N representing the version.

> There is Darwin-specific option parsing code (`darwin_override_options()`)
> that appears to set `flag_next_runtime` based on `-mmacosx-version-min`, but
> obviously that doesn't run for non-Darwin targets.

Most targets have an equivalent "override options" section where they could
make a similar selection.

A simplistic case would be to say any value >990000 is not Darwin (i.e we make
the Darwin platform part of the runtime value == 0 and then any other platform
that wants to take an encoding takes a value higher; this would default to the
next runtime just using "latest and greatest" - but that might not be what you
want in say 2 years time...

... however, it would be better to use bit boundaries rather than arbitrary
decimal.

maybe ...
0xff000000 masks the platform 
0x00ffffff masks the version selector

and Darwin is platform 0 for this purpose.

so as a quick fix you could just say AVR is platform 1 and set it to 
0x01000000 in your platform flags override ...

> I could imagine a few approaches to fixing this:
> 
> 1. Parse `-mmacosx-version-min` even when the target is not Darwin, whenever
> we're compiling Objective-C.  On non-Darwin, this would be interpreted as
> requesting Objective-C codegen compatible with the Objective-C ABI of the
> specified release of Mac OS X.

I do not think that is going to fly ;)

> 2. Allow an argument to `-fnext-runtime`, with the meaning approximately the
> same as in #1.
> 
> 3. Instead of using `flag_next_runtime` as a version number, switch it back
> to being zero or one, and use a separate flag (perhaps the existing
> `-fobjc-abi-version`?) to differentiate ABIs.

These two were both thoughts during the development but I suspect that the
mapping to values is a build-time decision and ought to be done in the flags
override code.

thoughts?

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

* [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin
  2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
  2021-09-30 11:49 ` [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin iains at gcc dot gnu.org
@ 2021-10-18 16:48 ` mhjacobson at me dot com
  2022-05-06  8:31 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mhjacobson at me dot com @ 2021-10-18 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Matt Jacobson <mhjacobson at me dot com> ---
I certainly haven't spent as much time thinking about this as you, but I think
my personal preference would be to add new values to the `flag_objc_abi`
argument.  It's already the case that "objc-next-runtime-abi-01.c" supports
both 0 and 1 values; I think it would be reasonable to have
`objc-next-runtime-abi-02.c` support multiple values too.  I'd imagine
something like:

2 -- "modern" runtime ABI, pre-SnowLeopard (fixup messages, etc.)
3 -- "modern" runtime ABI, SnowLeopard and later (no fixup messages, weak
protocol metadata

Then the Darwin-target code could (absent an explicit override in the
arguments) select the value for `flag_objc_abi` based on
`-mmacosx-version-min`.  And non-Darwin targets could simply default to the
newest ABI (absent an explicit override).

Other versions could be added in the future as support for newer
runtime-ABI-dependent features (e.g., `objc_autoreleasePoolPush()`,
`objc_opt_self()`, `objc_loadWeak()`) is added.

Under this scheme, I think it would make sense to switch `flag_next_runtime` to
being a simple boolean.

===

I think I like this better than using the high byte of `flag_next_runtime`,
which could be cumbersome to build conditionals for.  For example, taking your
example of using 0x01000000 as the "AVR" platform, a check of whether to use
non-fixup messaging might end up look like:

    #define PLATFORM(r) (((r) >> 24) & 0xFF)
    #define VERSION(r)  ((r) & 0xFFFFFF)

    if ((PLATFORM(flag_next_runtime) == DARWIN && VERSION(flag_next_runtime) >=
USE_FIXUP_BEFORE)
        || PLATFORM(flag_next_runtime) == AVR)
      { ... }

Yeah, the existing `flag_next_runtime >= USE_FIXUP_BEFORE` would technically
work, but you could imagine other platforms with ID > 0 that want the
pre-USE_FIXUP_BEFORE behavior.

===

> These two were both thoughts during the development but I suspect that the
> mapping to values is a build-time decision and ought to be done in the flags
> override code.

I'd like to understand better what you mean here.  Is it that, under the
`flag_objc_abi` scheme I described, the x86_64-Darwin target may want different
logic to select `flag_objc_abi` than the AVR target (for example)?  If so then
I agree -- shouldn't that be similar to how the `flag_next_runtime` override is
currently target-dependent?  Apologies if I've completely misread that.

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

* [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin
  2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
  2021-09-30 11:49 ` [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin iains at gcc dot gnu.org
  2021-10-18 16:48 ` mhjacobson at me dot com
@ 2022-05-06  8:31 ` jakub at gcc dot gnu.org
  2022-05-07 13:44 ` egallager at gcc dot gnu.org
  2023-05-08 12:22 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06  8:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.0                        |12.2

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.

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

* [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin
  2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
                   ` (2 preceding siblings ...)
  2022-05-06  8:31 ` jakub at gcc dot gnu.org
@ 2022-05-07 13:44 ` egallager at gcc dot gnu.org
  2023-05-08 12:22 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-05-07 13:44 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=105460

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
This seems like it might be related to bug 105460

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

* [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin
  2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
                   ` (3 preceding siblings ...)
  2022-05-07 13:44 ` egallager at gcc dot gnu.org
@ 2023-05-08 12:22 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.3                        |12.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.

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

end of thread, other threads:[~2023-05-08 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  4:15 [Bug objc/102537] New: Objective-C: can't use >= USE_FIXUP_BEFORE paths for non-Darwin mhjacobson at me dot com
2021-09-30 11:49 ` [Bug objc/102537] Objective-C: can't use >= USE_FIXUP_BEFORE paths on non-Darwin iains at gcc dot gnu.org
2021-10-18 16:48 ` mhjacobson at me dot com
2022-05-06  8:31 ` jakub at gcc dot gnu.org
2022-05-07 13:44 ` egallager at gcc dot gnu.org
2023-05-08 12:22 ` rguenth 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).