[Mesa-dev] [PATCH 3/5] clover: Add support for compiling to native object code v3

Jan Vesely jan.vesely at rutgers.edu
Tue Oct 21 11:07:59 PDT 2014


On Tue, 2014-10-21 at 09:50 -0700, Tom Stellard wrote:
[SNIP]
> > > +   void
> > > +   init_targets() {
> > > +      static bool targets_initialized = false;
> > > +      if (!targets_initialized) {
> > > +         LLVMInitializeAllTargets();
> > > +         LLVMInitializeAllTargetInfos();
> > > +         LLVMInitializeAllTargetMCs();
> > > +         LLVMInitializeAllAsmPrinters();
> > > +         targets_initialized = true;
> > Hi,
> > this part causes linking errors when llvm is built using cmake (split
> > shared libraries)
> > In function `LLVMInitializeAllAsmPrinters':
> > /home/vesely/.local/include/llvm/Config/AsmPrinters.def:27: undefined
> > reference to `LLVMInitializeAArch64AsmPrinter'
> > ...
> > for all targets other than r600
> > 
> > a quick fix would be to link against all LLVM libs (and let something
> > like -Wl,--as-needed sort it out)
> > 
> > but i think it would be nicer to have a pipe callback to do the
> > building. is there something I'm missing with that approach?
> > 
> 
> Having a callback is an interesting idea.  One downside I can see is
> that it would require to the pipe drivers to link against clang and LLVM.

I thought we could do something like this:
keep the frontend (CL -> IR) in clover
add a pipe callback to do IR -> elf binary

similar to what it was before adding SHADER_IR_NATIVE,
but it could do the second stage of compilation without running the
kernel.

The pipe driver will then run binaries it produced.
i thought this could be supported by all pipe drivers, and we could have
binary program cache without needing PIPE_SHADER_IR_NATIVE.

> 
> For the time being, I think the best fix would be to do conditional
> initialization based on the targets that may actually be used.  I can
> write up a patch for this.  Ideally we would link against as few target
> libraries as possible.  I think if we used --as-needed, we may end up
> pulling in all the libraries due to the way the library dependencies work
> (I'm not 100% sure about this, though).

I think --as-needed could at least strip out non-backend libs,
LLVMInitializeAll* will need all of the backends anyway (or selected
backends after your patch).
--as-needed also looked as a good alternative to hand picking
LLVM_COMPONENTS in configure.ac, but I'm not sure how it is supported
across platforms.

jan

> 
> -Tom
> 
> [snip] 
> > -- 
> > Jan Vesely <jan.vesely at rutgers.edu>
> 
> 
> 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141021/68823035/attachment.sig>


More information about the mesa-dev mailing list