Re: [PATCH v3 2/2] kbuild: Don't mess with the .cache.mk when root

From: Linus Torvalds
Date: Tue Mar 13 2018 - 13:39:45 EST


On Tue, Mar 13, 2018 at 9:44 AM, Doug Anderson <dianders@xxxxxxxxxxxx> wrote:
>> Is there any issue if I:
>>
>> $ make clean
>> $ make
>> $ sudo make install
>> <hack around>
>> $ make
>
> I don't personally know of any problems with the above flow.

This is my workflow, and what I suggest people do - only do "make
install" as root, everything else as a normal user.

And in fact, it occasionally _has_ broken, when "make install" has
done more than just install things, and created root-owned files and
directories (particularly the generated headers).

And then I complain to people, because then things like "make clean"
as a normal user ends up breaking too when there's some root-owned
file.

So it can break, but it's pretty rare. Usually it's something like
"people didn't use the proper sequence to update a file only if it
changed, and just blindly over-wrote a new version.

Generally, I prefer "make install" not even checking dependencies at
all, and just blindly copy things. And I'd definitely be ok with an
error rather than root generating files, although then I'd not
special-case mkcache, but all the *other* random file changes we do.

If Ingo wants to build as root, maybe we could even make him set some
environment flag to avoid errors.

(But I don't actually like the patch in question, because I really
think KBUILD_NOCACHE is much too specific a special case, and it
should be way more generic).

Linus