clang cross compiler
clang cross compiler
Has anyone made a howto for this yet? I compiled and tested my clang/llvm cross compiler this afternoon.
- Kazinsal
- Member
- Posts: 559
- Joined: Wed Jul 13, 2011 7:38 pm
- Libera.chat IRC: Kazinsal
- Location: Vancouver
- Contact:
Re: clang cross compiler
I don't believe so.
Does your cross compiler work? If so, why don't you write a how-to yourself?
Does your cross compiler work? If so, why don't you write a how-to yourself?
Re: clang cross compiler
Clang/LLVM is inherently a cross compiler; you don't need to build it again.
- Kazinsal
- Member
- Posts: 559
- Joined: Wed Jul 13, 2011 7:38 pm
- Libera.chat IRC: Kazinsal
- Location: Vancouver
- Contact:
Re: clang cross compiler
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.
Re: clang cross compiler
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
Re: clang cross compiler
-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
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: clang cross compiler
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?
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?
Re: clang cross compiler
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?
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: clang cross compiler
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.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: clang cross 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.
newlib can be built standalone and should just work if you specify CC=clang to configure. That said, newlib is a horrid mess.
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: clang cross 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.
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?
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: clang cross compiler
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?
The linker replacement is lld, which is still immature. In the meantime, use Binutils.
-
- Member
- Posts: 595
- Joined: Mon Jul 05, 2010 4:15 pm
Re: clang cross compiler
I managed to compile my kernel with LLVM Clang and I must say it was much easier than I thought it would be. Compiling LLVM is much easier than compiling GCC to begin with, where GCC is just a myriad of configuration options and tinkering. Compling LLVM is pretty much straight forward, you compile it and that's it. Apparently, LLVM clang still needs gcc in order to create object files which I didn't have installed, only the ARM cross compiler and clang couldn't find it without adding a few options.
I'm amazed how little effort there was in order to make clang accept my code even with several what I thought was GCC compiler dependent. Newlib was from a GCC compiled build though.
The OS started up and was running on the first try.
I think I continue with LLVM from here on as it seems like this compiler was quite nice to work with. As I see it this compiler with be choice for many developers in the future.
I'm amazed how little effort there was in order to make clang accept my code even with several what I thought was GCC compiler dependent. Newlib was from a GCC compiled build though.
The OS started up and was running on the first try.
I think I continue with LLVM from here on as it seems like this compiler was quite nice to work with. As I see it this compiler with be choice for many developers in the future.
Re: clang cross compiler
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?
Learn to read.