Re: Use (two) different compilers at build-time?

From: Linus Torvalds
Date: Mon Sep 07 2015 - 16:59:49 EST


On Mon, Sep 7, 2015 at 1:53 PM, Sedat Dilek <sedat.dilek@xxxxxxxxx> wrote:
>
> That does not work.

.. because you didn't do what I told you to do.

> I copied a gcc-compiled percpu.o OR deleted/renamed percpu.o and
> re-invoked make - this starts a complete new build from scratch.

Right. Because you changed the compiler name, so now the build system
realizes that the old build instructions are stale.

Which is why you have to:

>> Use a wrapper around the compiler (and point to that wrapper with the
>> "to switch compilers from under the make, without the build paths
>> changing (because otherwise our makefile auto-machinery notices that
>> flags and command changed).
>>
>> Use CC (or CROSS_COMPILE) to point at your wrapper.
>
> No idea how to realize that, sorry.

Literally just do something like this:

- have a shell script call "mycompiler" and make it do gcc/llvm "$@".

- or even just use a symlink (the script has the advantage that you
can play with the options etc too)

- change the shell script (or symlink) itself, and make sure to use
the same CC for "make" at all times, so that the build script never
sees that the underlying command is now different.

It should work fine, I've done it a couple of times (although
admittedly not recently)

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/