Specifying where Binutils is and what it is called

Jonathan Wakely jwakely.gcc@gmail.com
Sun Apr 19 18:49:35 GMT 2020


On Sun, 19 Apr 2020 at 16:16, R. Diez via Gcc-help <gcc-help@gcc.gnu.org> wrote:
>
> Hi all:
>
> I have been building cross-compiler toolchains for years with makefiles similar to this one:
>
> https://github.com/rdiez/JtagDue/blob/master/Toolchain/Makefile
>
> I have always been worried that installing GCC phase 2 on top of GCC phase 1 (with the same --prefix=/my/dir) may leave some undesired remnants behind.

That seems like an unnecessary worry. Why would the phase 1 compiler
install *more* than the final one?

> So I thought I should build and install GCC phase 1 somewhere else. After all, GCC phase 1 is not needed after the toolchain is complete.
>
> The steps would look like this:
>
> - Build and install Binutils with --prefix=/final/destination
> - Build and install GCC phase 1 (minimal compiler) with --prefix=/temporary/destination
> - Build and install Newlib with GCC phase 1 with --prefix=/final/destination
> - Build and install GCC phase 2 with --prefix=/final/destination
> - At this point, we could delete /temporary/destination
>
> Unfortunately, I am having trouble with GCC phase 1 and Newlib:
>
> a) If I configure GCC phase 1 with --prefix=/final/destination, it picks up the Binutils correctly.
>
> The names it finds are arm-none-eabi-ar etc.

Right, that's how it should work.

> But that is not what I want after all.

Why not?

> b) If I configure GCC phase 1 with --prefix=/temporary/destination, it does not find arm-none-eabi-ar and the like, even if they are in the PATH.
>
> It then picks up 'ar' for the host. Compilation fails later on with a message like this:
>
> Assembler messages:
> Fatal error: invalid -march= option: `armv7-m'
>
> It took some time to build everything and to realise what the error cause was. I wish that GCC checked during the configuration phase that the found 'ar' etc. actually support the asked target architecture.
>
> c) I can specify --with-build-time-tools=/some/dir , but then GCC does not pick full names like arm-none-eabi-ar . I have to specify a path like /home/rdiez/rdiez/arduino/toolchain-test-09-bin/arm-none-eabi/bin , which contains the same tools but with short names like "ar".
>
> The trouble is, GCC needs then those 'ar' etc. tool on the path when building Newlib. Because 'ar' for the host has then the same name as 'ar' for the cross-compilation target, the host tools are not available anymore, which causes problems later on. I really need --with-build-time-tools to pick full names like "arm-none-eabi-ar".
>
> d) I guess I could use --with-as and --with-ld to manually specify the right Binutils. The trouble is, there are other tools like objdump. GCC's own documentation warns about this:
>
> "When you use this option, you should ensure that dir includes ar, as, ld, nm, ranlib and strip if necessary, and possibly objdump. Otherwise, GCC may use an inconsistent set of tools."
>
> e) I could use the same --prefix for both GCC phase 1 and phase 2, delete the /final/destination when Newlib is complete, and reinstall to that /final/destination Binutils, Newlib and GCC phase 2. But that does not play well with Makefiles that are building in parallel. So I wish there is another way.

Why bother with the deleting things step?



More information about the Gcc-help mailing list