Re: Making a bare-metal cross Binutils package

Wookey <[email protected]> Sun, 24 Jan 2021 01:44:51 +0000
Newsgroups gmane.linux.debian.devel.toolchain
Organization Wookware
Message-ID <[email protected]>
--Ymggz7j3n/7S8TXn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2021-01-23 18:24 -0500, John Scott wrote:
> Hi,
>=20
> I'm looking into the most painless way to make cross Binutils for sh-elf,=
 but
> it seems like most documentation and tools are oriented towards Linux
> crossbuilds. I see there is some code in the Binutils package for recogni=
zing
> GNU triplets, but setting TARGET=3Dsh-elf and building fails with
> x86_64-linux-gnu-gcc   stamps/build..o   -o stamps/build.
> /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/S=
crt1.o: in function `_start':
> (.text+0x20): undefined reference to `main'
> collect2: error: ld returned 1 exit status
> make: *** [<builtin>: stamps/build.] Error 1
>=20
> The Electronics Team seems to use various ugly hacks for their
> cross-compilers. What would be the most effective strategy for tackling t=
his?

If I understand what you are trying to do it is to make a bare-metal
toolchain for use in a non-OS/low-level environment?

I suggest you look how this has been done for the arm-none toolchain which =
solves the same problem.
the source packages are:
binutils-arm-none-eabi
gcc-arm-none-eabi
libnewlib-nano
libstdc++-arm-none-eabi

It is possible in theory to produce arm-none binaries from the
standard binutils and gcc packages, but as you say there is a lot of
linux-based machinery in there and it would be intrusive to do
bare-metal builds in that packaging, so the maintainers decided it
made more sense to do as separate sources. The binutils packaging uses
the existing binutils source but adds new packaging and thus build-runes.

Just changing the target in binutils-arm-none-eabi to sh-elf appears
to build the tools correctly (but calls them all the wrong
things). Making a binutils-sh-unknown-elf package looks like it would
be straightforward. You could paramaterise things so that it can build
both flavours of bare-metal compiler. That would be more maintable
in the long run.

HTH

Wookey
--=20
Principal hats:  Linaro, Debian, Wookware, ARM
http://wookware.org/

--Ymggz7j3n/7S8TXn
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEER4nvI8Pe/wVWh5yq+4YyUahvnkcFAmAM0Q0ACgkQ+4YyUahv
nkcGxBAArKdbEu6r+DnilqHoSlBiq4pPk6sZqbBZOFp6HoGNXvoatTHErfvNChhb
E/3Qj8MxC1CZRcOv3oUHO9y/VchW645ohq3iQF6ooKR/UzHmo4W48XNhAzlm2Bt7
FgTMpzRDR9EeGIjnFDompZAJL/gNWJ37vOMbKWcb24GLZ3irgQ4VfYiBNbjjOIFz
KlW1hGTsk0d2tK0Kr/D/aQ3z1eeVCRZXR4FDuW212SFMomMlp24CYWt5dbIHW24+
4ll90CK/mF4ov1s5zVwKJH50V5+bYIADNyH4eFzzYhjQxnpBp2wiLeFLhuMjPf0j
zPl3cwUrk8L2wGyJpnglHZOKSNLnBuBnwrNM5FJgNQsoYTXXy/79Ty8FjacU7m0e
OEYQxqcqRvv95JtWGNi6ZnvFSZkeIxDNU00ts5InObXvYzSiulp4JljHV5edUcSI
hcIbwA9Yg5SMxhWjiAqIbEZbMwMJruSAQcsvztl7blG4L5Rfkj31/Ihk3jiddCUc
R4wgZkGyy736HgtqKP3+gf52BTa2jzCJGcPzDKQaLan3QglOWvDdveRN5ojaRWqP
cp+CzAPOvMFc4NB631wvgEGhQu0/gFs65HOI48bXwQ8iaFIQSLV79x3Z/Tw/Ozd8
m8OB2/ZMdIyRCXPcYiIj2jK1vtMSNzre9V6KRDWGAa7vU/uG1B8=
=Uqnj
-----END PGP SIGNATURE-----

--Ymggz7j3n/7S8TXn--