Page 1 of 1

Building an OS-Specific Toolchain with Sysroot

Posted: Thu Dec 12, 2019 6:19 am
by ThisMayWork
Hello everyone,

I have successfully created an OS-Specific Toolchain (merely a renamed version of Binutils and GCC, with my OS added as a target) and would like to move on to a "truer" version, which utilizes my LibC headers.

My question is, what needs to be there as far as the LibC is concerned to build Binutils and GCC with the Sysroot option? Do I need to provide implementations or just headers?

Thank you in advance,
Nick

Re: Building an OS-Specific Toolchain with Sysroot

Posted: Thu Dec 12, 2019 11:12 pm
by Korona
I assume that you want to build a cross compiler (i.e., a compiler targetting your OS but running on Linux) and not a compiler running on your OS. For GCC and binutils, you need next to nothing (maybe a few headers, I don't remember the details). For libgcc and libstdc++, you need libc headers and implementations; those libraries link against libc. If you want to build those libraries, you also need to install the libc headers before building GCC, otherwise GCC's configure script picks up wrong options.

In general, the procedure to build a working toolchain in one go is: install libc headers into sysroot -> build compiler -> build and install libc into sysroot -> build libgcc -> build libstdc++ and other libraries.

Re: Building an OS-Specific Toolchain with Sysroot

Posted: Fri Dec 13, 2019 3:00 am
by ThisMayWork
Korona wrote:I assume that you want to build a cross compiler (i.e., a compiler targetting your OS but running on Linux) and not a compiler running on your OS. For GCC and binutils, you need next to nothing (maybe a few headers, I don't remember the details). For libgcc and libstdc++, you need libc headers and implementations; those libraries link against libc. If you want to build those libraries, you also need to install the libc headers before building GCC, otherwise GCC's configure script picks up wrong options.

In general, the procedure to build a working toolchain in one go is: install libc headers into sysroot -> build compiler -> build and install libc into sysroot -> build libgcc -> build libstdc++ and other libraries.
Thank you for the info! Your assumption is correct, I forgot to mention that I wanted an OS-specific cross-toolchain! The process now makes a lot more sense. Do you by any chance have some more specific info on the libgcc environment requirements? How much of a libc do I have to provide for it to build? I am not quite sure what libgcc is expecting from me :oops: .