[CRIU] Building PIE/PIC objects separately

Pavel Emelyanov xemul at parallels.com
Thu Oct 8 02:55:21 PDT 2015


On 10/07/2015 05:41 PM, Cyrill Gorcunov wrote:
> On Wed, Oct 07, 2015 at 04:27:53PM +0200, Laurent Dufour wrote:
>>>
>>> Hi! You know the former idea was exactly the opposite ;) We
>>> wanted to build them once and reuse it. Could you please
>>> point which exactly problems you're facing?
>>
>> Actually, I didn't face any issue, I had one with the memcpy symbol, but
>> I was able to resolve it in another way.
>>
>> My concern is that we are linking together objects which are not built
>> the same way between crtools and parasite/restorer.
> 
> True. But pie/ code is built that way it can be linked into non PIE
> code (but sure not the reverse).

Cyrill, I agree with Laurent here. The fact that we build shared code
once with -pie and link into both is, well, a hack :) IIRC we even tried
to go the elegant path some time ago, the CR_NOGLIBC macro is all about
it, thus e.g. pie/util-fd.c calls sendmsg in two ways, one via raw
syscall, the other one via glibc call, but AFAIU (I'm not a makefile
expert either ;) ) we only use the no-glibc path.

So can you, the greatest makefile expert we have on the list, help us
fix the build engine to allow building the shared stuff twice?

>> In addition building parasite/restorer objects separately, will remove
>> the need to pull architecture memcmp/cpy and bit operation for crtools
>> binaries. This way crtools will fully rely on the C library ones which
>> are updated and may be more efficient.
>>
>> May be it's fine to live with that, but this should not impact so much
>> the build time to build twice the 3 files below :)
> 
> You know, personally I won't mind if we build pie as a serapate
> but this will require either symlinks for the files (easy way)
> or hard lifting of the make engine (hard way).

Not sure why, but symlinks over the source code seem clumsy to me.

However, I see the 3rd way, it's just slightly more elegant than the way
with the symlinks :) but still. We take util.c in non-pie code, util.c in
pie and put util-fd.c in shared, then first two #include the latter (with
proper CR_NOGLIBC (un)def) and get built independently.

> At moment I fear
> I don't have time for the second. So if you can experiment with
> our make -- this would be just great.
> 
> Also, iirc Pavel has not be voting for two builds so we need to
> hear his opinion first. Pavel?

What I'd love to see is -- tuned Makefile-s that build needed shared 
code twice, please :)

-- Pavel



More information about the CRIU mailing list