RISC-V: GCC crti.S vs. Newlib __libc_init_array()
Jim Wilson
jimw@sifive.com
Fri Jul 27 16:18:00 GMT 2018
On Fri, Jul 27, 2018 at 12:51 AM, Sebastian Huber
<sebastian.huber@embedded-brains.de> 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
More information about the Newlib
mailing list