Compiling glibc with LLVM

Hi,

I read on the gentoo website http://en.gentoo-wiki.com/wiki/Llvm that glibc cannot be compiled using llvm because of some GNU extensions which LLVM does not support.

Has there been any success in compiling glibc using LLVM so as to get the bytecode?
We are looking to do whole program analysis to look at control flows including those in libc… we were hoping that we could get the control flows using LLVM API’s for glibc.

Has anyone tried this before?

Thanks

Nipun

Hi Nipun,

As you say, glibc is rather GCC –oriented. I certainly haven’t tried this myself, but have you thought of using an alternate C library such as RedHat newlib? That can certainly be compiled by clang (we do it every night).

Cheers,

James

Hi James,

I will look into the RedHat newlib library, however, we def are looking for a solution for GCC as well, but maybe newlib would be a good way to go to test our complete workflow before putting an effort to use glibc.

btw. I did have another question, hopefully you would be able to answer, what we are looking to do is to get the control flow graph including some sort of alias analysis for function pointers. I see that there are already existing analysis passes in LLVM to get the control flow, however do you know how function pointer can be handled?

Thanks
Nipun

Hi James,

I will look into the RedHat newlib library, however, we def are looking for a solution for glibc, but maybe newlib would be a good way to go to test our complete workflow before putting an effort to generate control flow graphs for glibc.

btw. I did have another question, hopefully you would be able to answer, what we are looking to do is to get the control flow graph including some sort of alias analysis for function pointers. I see that there are already existing analysis passes in LLVM to get the control flow, however do you know how function pointer can be handled?

Thanks

Hi Nipun,

I’m afraid I don’t know the state of LLVM’s alias analysis. Hopefully someone more knowledgeable on the list can inform you.

Cheers,

James

Hi,

I read on the gentoo website MediaWiki 1.33.1 that
glibc cannot be compiled using llvm because of some GNU extensions which
LLVM does not support.

I am sure there is more than one gcc dependency in glibc, but the main
one I can remember is its use of -fno-toplevel-reorder, which we really
don't want to have in llvm/clang.

Has there been any success in compiling glibc using LLVM so as to get
the bytecode?
We are looking to do whole program analysis to look at control flows
including those in libc... we were hoping that we could get the control
flows using LLVM API's for glibc.

Has anyone tried this before?

Thanks
Nipun

Cheers,
Rafael

Hi James,

What kind of config parameters are needed to build newlib into bytecode?

Thanks,
Sam

James Molloy-3 wrote: