On Mon, 2020-03-09 at 22:01 +0000, Joseph Myers wrote:
> On Mon, 9 Mar 2020, Paul Smith wrote:
> > I have a sysroot I've created (downloading RPMs from older systems and
> > unpacking them) which is sufficient to build GCC (and binutils etc.)  I
> > need the GCC binaries I create to be compiled using this sysroot so
> > that they can run on older systems.
> > 
> > It seems that options like --with-sysroot and --with-build-sysroot are
> > more about how the compiler builds other things and less about how the
> > compiler itself is built.
> 
> Yes.  The natural way to do this sort of thing is:
> 
> 1. Build a cross compiler (GCC and binutils) that's configured using 
> --with-sysroot to make use of the old-system sysroot.
> 
> 2. Use the compiler you built in the previous step whenever you want to 
> build binaries (of GCC or anything else) that will run on older systems.

Heh.  That's sort of what my makefile was already doing (except for
some reason I was building GCC 3 times not twice... I can't remember
why.  Some kind of canadian-cross; probably I just got lost in the
weeds somewhere all those years ago... or maybe back then the
sysroot options were not as complete/capable as they are now).

Reducing the build to two steps would help me but I only do those once
a year or so, so that's not so important.  Mainly I want to build a
profiled GCC, to reduce compile times.

OK, I'll give this a whirl and see how it goes; thanks Joseph!

As you astutely surmise, the resulting output needs to be relocatable
but not just once: the entire toolchain is checked into a Git
repository and I have no control over the path it's checked out into on
a given system.  So I don't think --with-build-sysroot suffices.

What I do is use shell script wrappers around the compiler which sets
up the correct sysroot flags etc. based on the invocation path then
calls the real binaries.  I'm happy to continue doing that.

I do also use -static-libgcc / -static-libstdc++ as you suggest.

Reply via email to