Re: RISC-V: GCC crti.S vs. Newlib __libc_init_array()

Jim Wilson <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAFyWVaZv0ypkopVcsEmfxpYLKh_LOHwiV6e-u9HcoRyVv__8LA@mail.gmail.com>
On Fri, Jul 27, 2018 at 12:51 AM, Sebastian Huber
<[email protected]> wrote:
> glibc has a more sophisticated configuration machinery than Newlib. I think
> in Newlib there exists currently no generic mechanism for machines
> (architectures) to define options for the generic code. They can only
> overwrite/replace files via the build system. Since machine defines are
> already used throughout the Newlib code base, I will prepare a patch using
> this approach. I think a configuration script detection is less obvious and
> harder to understand.

I already briefly pointed out how to fix it.  If you look at
newlib/configure.host, you will see that there are a bunch of shell
variables that can be set in a target dependent fashion.  We just need
one more to indicate whether _init/_fini are supported.  This is on by
default, and turned off for RISC-V.  Then in configure this shell
variable is used to define a macro that can be tested in
newlib/libc/misc/init.c and fini.c.  Or if that is too complicated, we
could just define a macro in newlib_cflags for RISC-V.

There should be no explicit test for RISC-V in the init.c and fini.c
files.  This is not a RISC-V specific feature.  _init and _fini are
deprecated for all targets.  Most targets just haven't explicitly
dropped support for them yet.

Jim
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.