[LLVMdev] Generic target?

Samuel Crow samuraileumas at yahoo.com
Sun May 2 10:45:06 PDT 2010


Hello LLVM list,

I'm working on a wrapper for LibC and I think it would work a whole lot better for what I'm trying to do if I wasn't forced to use a specific endianness.  I'm trying to make it work in such a way that the compiler can generate code for a generic LLVM target such that the bitcodes won't need to have the alignment information or endianness until the final link stage at install time.

Here's the build process currently:

1.  The parser is built using LLVM-PEG parser generator which doesn't specify a target.  It exports bitcode successfully.

2.  The linker library used by the parser code and the main code completes the compiler bitcode thus creating a nearly complete compiler using LLVM-Link.

3.  At install time system specific LibC wrapper written in C and compiled with Clang is linked to the incoming bitcode file with LLVM-Link.

4.  Opt is invoked on it for LTO.

5.  LLC converts the code to Assembly source.

6.  The source is now assembled and linked to the real LibC calls contained in the LibC wrapper and the GLibC++ calls to satisfy the linker library are also linked in.

7.  Execution reveals a core-dump due to a file handle being converted to a NULL for some reason.

As for step 7, I'd prefer that execution would reveal a "hello world" output to indicate that our code was working.  :-)

Since the LibC wrapper is such simple code I doubt that it's truly to blame so I'm left at a loss to explain it except that the endianness and aligment characteristics of the linker library written using LLVM-C++ are embedded in the bitcode files too soon to allow generic linking.  The goal is to produce an endian-agnostic alignment-neutral bitcode in steps 1 and 2.  How far away is this in the LLVM side and what can be done to help with a generic target?

Links:
http://sourceforge.net/projects/llvmpeg/ is the project page for LLVM-PEG.  (Code is in SVN repository.  Click develop tab to access the SVN 
browser.)
http://sourceforge.net/projects/llvmlibc/ is the project page for LLVM-LibC wrapper.  (Code is in SVN repository.)

Thanks for your time,

--Sam Crow



      



More information about the llvm-dev mailing list