clang cross compiler
Posted: Thu Sep 20, 2012 4:03 pm
Has anyone made a howto for this yet? I compiled and tested my clang/llvm cross compiler this afternoon.
The Place to Start for Operating System Developers
http://f.osdev.org/
I stand corrected, thank you. It does seem that the page could use a lot of work (perhaps this is where kr651129 could come in.)dozniak wrote:http://wiki.osdev.org/LLVM_Cross-Compiler
That's interesting. I've never looked very far into Clang/LLVM, so I assumed it worked more like GCC in terms of portability.JamesM wrote:Clang/LLVM is inherently a cross compiler; you don't need to build it again.
Or since 3.1 you can just shorten this to:pitfall wrote:CLang is a native cross-compiler, I've only used it for some cross-compiling tests targeting ARM chips on my x86-64 laptop (don't even remember why, just remember I did it... -_-). For my OS I use an x86-64 GCC cross compiler so I can compile my kernel on my laptop and on my old Pentium 3 running Crunchbang-Linux, using an external drive for storage and two build directories on it, switching just one line in my makefile when switching from one computer to one another. And compiling GCC is an interesting piece of software-learning experience !
As far as I know, you can use -ccc-host-triple <your target output format> option with -march=<your target architecture> to cross-compile with LLVM. It's been a while since I used LLVM/CLang, but I think this'll work with some investigation.
EDIT
----------------------------------------------------------------------------
Here's an example quoted for some obscure mailing lists illustrating what I wrote :Code: Select all
-march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf
Code: Select all
-target armv7--eabi -mcpu=cortex-a9
-target replaced -ccc-host-triple, I believe either in 3.1 or shortly thereafter.pitfall wrote:Ok I didn't know about this way of shortening the command-line. I'll note it somewhere
libc++ is a separate project, as is the compiler-rt project (which replaces libgcc). Newlib is a C library and so is nothing to do with the compiler.OSwhatever wrote:The LLVM project download pages are nice enough to provide binaries for those who do not want to spend time compiling the compilers. However, these are provided without any libraries. The question is how to compile the libraries like newlib and libstd++.
Is there any progress compiling these libraries with or any libraries as at all? Do we we just have to use libraries created with GCC?
The build systems of the libraries are usually done for GCC and hacking the configuration can be very tricky. Can you in any way compile these libraries with a pure clang compiler or do you need the GCC front end?JamesM wrote:libc++ is a separate project, as is the compiler-rt project (which replaces libgcc). Newlib is a C library and so is nothing to do with the compiler.
libc++ and compiler-rt are both LLVM libraries and use the LLVM build system...OSwhatever wrote:The build systems of the libraries are usually done for GCC and hacking the configuration can be very tricky. Can you in any way compile these libraries with a pure clang compiler or do you need the GCC front end?JamesM wrote:libc++ is a separate project, as is the compiler-rt project (which replaces libgcc). Newlib is a C library and so is nothing to do with the compiler.
How easy is it to get libc++ running on your own OS or even compile? Is it lot of work or just in the case of newlib create functions or stubs for a bunch of POSIX calls?Owen wrote:libc++ and compiler-rt are both LLVM libraries and use the LLVM build system...
newlib can be built standalone and should just work if you specify CC=clang to configure. That said, newlib is a horrid mess.
LLVM-ld is for linking bitcode and currently depends upon the system linker.OSwhatever wrote:Also one thing I notice is that the llvm-ld linker doesn't support linker script which is quite essential for OS developers. Do you use the GCC linker instead or are there other ways?
Was fairly easy for me. That said, I disabled iostreams and use only parts of libc++ that don't need any syscalls at all.OSwhatever wrote:How easy is it to get libc++ running on your own OS or even compile? Is it lot of work or just in the case of newlib create functions or stubs for a bunch of POSIX calls?