Compiling glibc on Linux

Hi,

I am trying to compile glibc on Linux using llvm. I need to do this for a research project.
The problem is that llvmc doesn't work, and I guess I have to set CC=llvmc to get the glic compiled. For some reason llvmc complains that it cannot find %llvmcc1%. I have this problem both on my Mac and my Linux system. Other tools that I have tested including llvm-gcc work without any problem.
First, I appreciate it if you let me know what can cause this problem and second, tell me if you think I have any chance to compile glibc using LLVM.

Thank you,
Babak

Babak,

As its manual page (http://llvm.org/docs/CommandGuide/html/llvmc.html)
states, llvmc is an experimental tool:

llvmc is considered an experimental LLVM tool because it has these
deficiencies:

Poor configuration support
        The support for configuring new languages, etc. is weak. There
        are many command line configurations that cannot be achieved
        with the current support. Furthermore the grammar is cumbersome
        for configuration files. Please see http://llvm.org/PR686 for
        further details.

That said, you should be able to get it to work with llvm-gcc.

Did you build llvm-gcc? Did you check the paths in the "c" config file?
Did you install the config files?

All of these things need to be done in order for the standard config
file to work.

Reid.

Reid,

Thank you for your quick reply.

Yes, I have built and installed llvm-gcc and "llvm-gcc --print-prog-name=cc1" return the correct path for cc1, so I assume its path is set correctly in the config files, but I haven't installed config files separately. Do I need to do that? Is there any documentation about it?

Thank you again,
Babak

Yes, I have built and installed llvm-gcc and "llvm-gcc --print-prog-
name=cc1" return the correct path for cc1, so I assume its path is
set correctly in the config files, but I haven't installed config
files separately. Do I need to do that? Is there any documentation
about it?

I'd strongly suggest just building with CC=llvm-gcc CXX=llvm-g++.

llvmc is extremely experimental and has not seen wide use.

-Chris

Thank you Chris.

Actually, I have changed the stack organization in the "llc" source codes for x86 target. Thus, I need libraries compiled with the new stack organization. If I use llvm-gcc (and apparently also llvmc), llc will not be invoked. I was hoping that llvmc would call llvm-gcc to compile to bc file and then call llc to compile to native assembly, but apparently this doesn't happen.
Do you know of any possible ways to involve llc in compilation of libraries?

--Babak

Babak,

I strongly suggest you drop trying to use llvmc. Instead, probably just
compiling your library with llvm-gcc should be sufficient. The llvm-gcc
tool has much of llc's functionality built in to it so you're going to
get the same output. If that doesn't work for you, then please describe
what you're trying to do in more detail and we'll tell you how it can be
done. Coming at it from the "llvmc doesn't work" angle, doesn't help us
solve your actual problem (because we don't know what it is).

Thanks,

Reid.

I am convinced to use llvm-gcc. As I mentioned in my previous email, I have changed native code generation in llc to generate code with a different stack organization. In order to have working binaries, the libraries must be compiled with the new tool and have the same stack organization. Now that I cannot use llc, it seems that I have to modify llvm-gcc to have it generate code with the stack organization that I want.

For X86 target I have particularly changed X86RegisterInfo::eliminateFrameIndex, X86RegisterInfo::emitPrologue and X86RegisterInfo::emitEpilogue in the llc source code.

Can I find equivalent functions in the llvm-gcc source, so that I can implement the needed stack organization?

Thank you,
Babak

I am convinced to use llvm-gcc. As I mentioned in my previous email,
I have changed native code generation in llc to generate code with a
different stack organization. In order to have working binaries, the
libraries must be compiled with the new tool and have the same stack
organization. Now that I cannot use llc, it seems that I have to
modify llvm-gcc to have it generate code with the stack organization
that I want.

For X86 target I have particularly changed
X86RegisterInfo::eliminateFrameIndex, X86RegisterInfo::emitPrologue
and X86RegisterInfo::emitEpilogue in the llc source code.

Can I find equivalent functions in the llvm-gcc source, so that I can
implement the needed stack organization?

Hi Babak,

Perhaps I don't understand you situation exactly, however llvm-gcc
uses the same libraries the llc uses. Loosely speaking, the "gcc" part
of llvm-gcc generates LLVM bytecode and sent to the LLVM libraries.

From there, it performs the optimizations and outputs code, etc. All

that llc does differently is it reads the bytecode directly. It then
sends it through the optimizers, etc.

Therefore, your changes to X86RegisterInfo is shared with all tools.

-bw

I am convinced to use llvm-gcc. As I mentioned in my previous email,
I have changed native code generation in llc to generate code with a
different stack organization. In order to have working binaries, the
libraries must be compiled with the new tool and have the same stack
organization. Now that I cannot use llc, it seems that I have to
modify llvm-gcc to have it generate code with the stack organization
that I want.

I think you're missing the point. llvm-gcc and llc link with *exactly*
the same set of libraries for code generation. If you've modified llc
then llvm-gcc (after rebuild) will produce the same results.

If you've built your own target then you need to ensure that llvm-gcc
links that target in by modifying the llvm-gcc/gcc/Makefile.in file.

For X86 target I have particularly changed
X86RegisterInfo::eliminateFrameIndex, X86RegisterInfo::emitPrologue
and X86RegisterInfo::emitEpilogue in the llc source code.

To be clear, llc does not contain any of those functions. They are part
of the X86 target in lib/Target/X86. This is the same X86 target that is
linked into llvm-gcc when you build it. There should be zero difference
between your llvm-gcc output and your llc output.

Can I find equivalent functions in the llvm-gcc source, so that I can
implement the needed stack organization?

Yes you can .. its the same source!

Thank you,
Babak

Hope this clears it up.

Reid.

Reid and Bill,

Thank you very much for your helpful comments.
Your comments helped me find out what part of my work was wrong that my changes were not effective in llvm-gcc.

Thank you again,
Babak

Cool! You're welcome :slight_smile:

-bw