public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Edelsohn <dje.gcc@gmail.com>
To: "CHIGOT, CLEMENT" <clement.chigot@atos.net>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] gcc: implement AIX-style constructors
Date: Tue, 19 Oct 2021 16:14:40 -0400	[thread overview]
Message-ID: <CAGWvnynrU3p4kdk+syVs5f2+5OXz3G0axAmapOFi6ZXegtu5Ag@mail.gmail.com> (raw)
In-Reply-To: <PA4PR02MB6686D2D6132441155E4B0CF9EABC9@PA4PR02MB6686.eurprd02.prod.outlook.com>

Clement,

+      /* Use __C_runtime_pstartup to run ctors and register dtors.
+ This whole part should normally be in libgcc but as
+ AIX cdtors format is currently not the default, managed
+ that in collect2.  */

Why are you emitting the special startup function call in collect2.c
instead of placing it in libgcc.  The comment mentions that the
special startup function should be defined in libgcc.

Yes, the AIX ld bcdtors mechanism is not the default, but what is the
harm? The symbol will be defined and exported by libgcc. If the AIX
linker -bcdtors functionality is not invoked, the symbol is not used.
And if a user does invoke the AIX linker with -bcdtors, the behavior
will be the same (either the program was compiled to use AIX cdtors or
not, which is the same if the startup function is emitted by
collect2.c.

Also, the patch should include documentation of the option.  The
documentation should mention that this is for interoperability with
IBM XL Compiler, and the option will not operate correctly unless the
application and the GCC runtime are built with the option.

Thanks, David

On Mon, Oct 18, 2021 at 3:55 AM CHIGOT, CLEMENT <clement.chigot@atos.net> wrote:
>
> AIX linker now supports constructors and destructors detection. For such
> functions to be detected, their name must starts with __sinit or __sterm.
> and -bcdtors must be passed to linker calls. It will create "_cdtors"
> symbol which can be used to launch the initialization.
>
> This patch creates a new RS6000 flag "-mcdtors=".
> With "-mcdtors=aix", gcc will generate these new constructors/destructors.
> With "-mcdtors=gcc", which is currently the default, gcc will continue
> to generate "gcc" format for constructors (ie _GLOBAL__I and _GLOBAL__D
> symbols).
> Ideally, it would have been better to enable the AIX format by default
> instead of using collect2. However, the compatibility between the
> previously-built binaries and the new ones is too complex to be done.
>
> gcc/ChangeLog:
> 2021-10-04  Clément Chigot  <clement.chigot@atos.net>
>
>         * collect2.c (aixbcdtors_flags): New variable.
>         (main): Use it to detect -bcdtors and remove -binitfini flag.
>         (write_c_file_stat): Adapt to new AIX format.
>         * config/rs6000/aix.h (FILE_SINIT_FORMAT): New define.
>         (FILE_STERM_FORMAT): New define.
>         (TARGET_FILE_FUNCTION_FORMAT): New define.
>         * config/rs6000/aix64.opt: Add -mcdtors flag.
>         * config/rs6000/aix71.h (LINK_SPEC_COMMON): Pass -bcdtors when
>           -mcdtors=aix is passed.
>         * config/rs6000/aix72.h (LINK_SPEC_COMMON): Likewise.
>         * config/rs6000/aix73.h (LINK_SPEC_COMMON): Likewise.
>         * config/rs6000/rs6000-opts.h (enum rs6000_cdtors): New enum.
>         * tree.c (get_file_function_name): Add
>           TARGET_FILE_FUNCTION_FORMAT support.
>
> gcc/testsuite/ChangeLog:
> 2021-10-04  Clément Chigot  <clement.chigot@atos.net>
>
>         * gcc.target/powerpc/constructor-aix.c: New test.
>
>

  reply	other threads:[~2021-10-19 20:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18  7:55 CHIGOT, CLEMENT
2021-10-19 20:14 ` David Edelsohn [this message]
2021-10-21 12:39   ` CHIGOT, CLEMENT
2021-10-21 13:59     ` David Edelsohn
2021-11-02 13:28       ` CHIGOT, CLEMENT
2021-11-16  8:42         ` CHIGOT, CLEMENT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGWvnynrU3p4kdk+syVs5f2+5OXz3G0axAmapOFi6ZXegtu5Ag@mail.gmail.com \
    --to=dje.gcc@gmail.com \
    --cc=clement.chigot@atos.net \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).