Need Help to Further Reduce bsp_specs

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Dec 21 06:47:08 UTC 2017


Hello,

we should try to understand better why the things are how they are 
currently. In Newlib we have this ctr0.c:

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/sys/rtems/crt0.c;h=9778b985a180ba68990b40b6e4423aa970ca5ec7;hb=HEAD

This is the default start file for the RTEMS GCC:

https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/rtems.h?view=markup

	/*
	 * Dummy start/end specification to let linker work as
	 * needed by autoconf scripts using this compiler.
	 */
	#undef STARTFILE_SPEC
	#define STARTFILE_SPEC "crt0.o%s"

We use the bsp_specs to override this (we could also use -nostartfiles 
at the command line):

             %rename startfile old_startfile

             *startfile:
             %{!qrtems: %(old_startfile)} \
             %{!nostdlib: %{qrtems: crti.o%s crtbegin.o%s}}

Why do we define a STARTFILE_SPEC in GCC which we don't use for real 
applications?

The purpose of the ctr0.o seems to be to make the Autoconf stuff happy 
during GCC build, e.g. for libstdc++.

One option would be to do this:

1. Change STARTFILE_SPEC:

#undef STARTFILE_SPEC
#define STARTFILE_SPEC "start.o%s crti.o%s crtbegin.o"

2. Rename Newlib ctr0.o into start.o and do NOT install it. This way it 
is used only during GCC build to make the GCC Autoconf happy.

3. Provide start.o in all BSPs.

How do we deal with other Autoconf (or other link-time feature 
detection) stuff? This change could break all the third party library 
build scripts.

We could install the Newlib crt0.o as fakestart.o and add a -qfakestart 
option, e.g. to use LDFLAGS += "-qfakestart"?

Bonus work:

What this this for a stuff?

	/*
	 * Some targets do not set up LIB_SPECS, override it, here.
	 */
	#define STD_LIB_SPEC "%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"

The libg.a and libc.a are identical:

sha512sum /opt/rtems/5/sparc-rtems5/lib/lib[cg].a
6e19f30fde6fbd23e5af9060e8a76d7294b5f23677561770a26ae04c44c4fd920b45d4f42f3cde2ede1962bfbb0429b5d7ced89fe448340a5b4936fb716c7e6b  /opt/rtems/5/sparc-rtems5/lib/libc.a
6e19f30fde6fbd23e5af9060e8a76d7294b5f23677561770a26ae04c44c4fd920b45d4f42f3cde2ede1962bfbb0429b5d7ced89fe448340a5b4936fb716c7e6b  /opt/rtems/5/sparc-rtems5/lib/libg.a

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list