• DEFAULT_PCC_STRUCT_RETURN on NetBSD vs Linux

    From John Paul Adrian Glaubitz@21:1/5 to All on Wed May 28 09:30:01 2025
    Hi,

    while looking into building GCC with 4 bytes alignment by default on
    m68k, I ran into the following definition in gcc/config/m68k/linux.h:

    /* For m68k SVR4, structures are returned using the reentrant
    technique. */
    #undef PCC_STATIC_STRUCT_RETURN
    #define DEFAULT_PCC_STRUCT_RETURN 0

    For NetBSD (gcc/config/m68k/netbsd-elf.h), we have:

    /* The svr4 ABI for the m68k says that records and unions are returned
    in memory. */

    #undef DEFAULT_PCC_STRUCT_RETURN
    #define DEFAULT_PCC_STRUCT_RETURN 1

    Two questions:

    Shouldn't the #undef in linux.h undefine DEFAULT_PCC_STRUCT_RETURN and not PCC_STATIC_STRUCT_RETURN? And, secondly, shouldn't the comment in linux.h
    be corrected since apparently linux.h and netbsd-elf.h disagree on what
    the SVR4 ABI specifies how structs and unions are returned?

    In particular, it seems that DEFAULT_PCC_STRUCT_RETURN is always 0 on Linux
    and always 1 on NetBSD according to a brief "git grep DEFAULT_PCC_STRUCT_RETURN".

    Thanks,
    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schwab@21:1/5 to John Paul Adrian Glaubitz on Wed May 28 18:40:01 2025
    On Mai 28 2025, John Paul Adrian Glaubitz wrote:

    Shouldn't the #undef in linux.h undefine DEFAULT_PCC_STRUCT_RETURN and not PCC_STATIC_STRUCT_RETURN?

    No, they are separate target options. PCC_STATIC_STRUCT_RETURN is no
    longer defined by default, so this is redundant now.

    And, secondly, shouldn't the comment in linux.h be corrected since
    apparently linux.h and netbsd-elf.h disagree on what the SVR4 ABI
    specifies how structs and unions are returned?

    This is controlled by TARGET_RETURN_IN_MEMORY if
    DEFAULT_PCC_STRUCT_RETURN is 0.

    --
    Andreas Schwab, schwab@linux-m68k.org
    GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
    "And now for something completely different."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Andreas Schwab on Sun Jun 1 16:30:01 2025
    On Wed, 2025-05-28 at 18:10 +0200, Andreas Schwab wrote:
    On Mai 28 2025, John Paul Adrian Glaubitz wrote:

    Shouldn't the #undef in linux.h undefine DEFAULT_PCC_STRUCT_RETURN and not PCC_STATIC_STRUCT_RETURN?

    No, they are separate target options. PCC_STATIC_STRUCT_RETURN is no
    longer defined by default, so this is redundant now.

    OK, guess someone can drop that line then.

    And, secondly, shouldn't the comment in linux.h be corrected since apparently linux.h and netbsd-elf.h disagree on what the SVR4 ABI
    specifies how structs and unions are returned?

    This is controlled by TARGET_RETURN_IN_MEMORY if
    DEFAULT_PCC_STRUCT_RETURN is 0.

    I was talking about the comments, not the code since NetBSD and Linux
    disagree on what the SVR4 ABI claims.

    Btw, shouldn't EMPTY_FIELD_BOUNDARY not changed by -malign-int to 32
    similar to BIGGEST_ALIGNMENT (see netbsd-elf.h)?

    And what about the value for STACK_BOUNDARY? It seems to be 16 for many
    Linux targets while it's 32 for NetBSD. Is there a reason why it's 16-bit- aligned on Linux?

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Jeff Law on Mon Jun 2 08:10:01 2025
    On Sun, 2025-06-01 at 19:44 -0600, Jeff Law wrote:

    On 6/1/25 8:21 AM, John Paul Adrian Glaubitz wrote:


    And what about the value for STACK_BOUNDARY? It seems to be 16 for many Linux targets while it's 32 for NetBSD. Is there a reason why it's 16-bit- aligned on Linux?

    Regardless of differences in the values, I don't see changing them at
    this point as that would be an ABI change.

    Both Gentoo and Debian are going to switch m68k downstream to 4 bytes alignment as just too many packages are failing to build these days with 2 bytes alignment.

    See the (incomplete) discussion here: https://wiki.debian.org/M68k/Alignment

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schwab@21:1/5 to John Paul Adrian Glaubitz on Mon Jun 2 18:00:01 2025
    On Jun 01 2025, John Paul Adrian Glaubitz wrote:

    I was talking about the comments, not the code since NetBSD and Linux disagree on what the SVR4 ABI claims.

    In which way?

    --
    Andreas Schwab, schwab@linux-m68k.org
    GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
    "And now for something completely different."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Andreas Schwab on Mon Jun 2 19:40:01 2025
    On Mon, 2025-06-02 at 17:34 +0200, Andreas Schwab wrote:
    On Jun 01 2025, John Paul Adrian Glaubitz wrote:

    I was talking about the comments, not the code since NetBSD and Linux disagree on what the SVR4 ABI claims.

    In which way?

    Both NetBSD and Linux return structs differently, yet the comments in the source code claim their way is according to the m68k SVR4 specification.

    This seems contradictory to me unless I am missing something.

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schwab@21:1/5 to John Paul Adrian Glaubitz on Mon Jun 2 20:10:01 2025
    On Jun 02 2025, John Paul Adrian Glaubitz wrote:

    Both NetBSD and Linux return structs differently, yet the comments in the source code claim their way is according to the m68k SVR4 specification.

    Where does it claim that?

    --
    Andreas Schwab, schwab@linux-m68k.org
    GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
    "And now for something completely different."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Andreas Schwab on Mon Jun 2 20:00:02 2025
    On Mon, 2025-06-02 at 19:44 +0200, Andreas Schwab wrote:
    On Jun 02 2025, John Paul Adrian Glaubitz wrote:

    Both NetBSD and Linux return structs differently, yet the comments in the source code claim their way is according to the m68k SVR4 specification.

    Where does it claim that?

    linux.h has:

    /* For m68k SVR4, structures are returned using the reentrant
    technique. */
    #undef PCC_STATIC_STRUCT_RETURN
    #define DEFAULT_PCC_STRUCT_RETURN 0

    while netbsd-elf.h has:

    /* The svr4 ABI for the m68k says that records and unions are returned
    in memory. */

    #undef DEFAULT_PCC_STRUCT_RETURN
    #define DEFAULT_PCC_STRUCT_RETURN 1

    To me both statements seem to contradict each other.

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Paul Adrian Glaubitz@21:1/5 to Andreas Schwab on Mon Jun 2 22:00:01 2025
    On Mon, 2025-06-02 at 21:41 +0200, Andreas Schwab wrote:
    On Jun 02 2025, John Paul Adrian Glaubitz wrote:

    To me both statements seem to contradict each other.

    How? They comment two different things.

    But it's DEFAULT_PCC_STRUCT_RETURN in both cases, no?

    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer
    `. `' Physicist
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)