craftr-build / craftr-build-4.x

Frontend for the Craftr build framework.
https://craftr-build.github.io/craftr/
Other
60 stars 14 forks source link

Support for ARMCC compiler #116

Closed SadE54 closed 6 years ago

SadE54 commented 8 years ago

Hi,

I would like to use Craftr for embedded dev. Could it be possible to support the armcc compiler from ARM ? (From 3.5, this compiler is supported by cmake)

NiklasRosenstein commented 8 years ago

Hi! I'd be happy to look into this for you. Unfortunately I will be away until the 22nd this month. I hope you're not in a hurry with testing Craftr for your application.

Thanks for wanting to give it a try. :) On 15 Jun 2016 10:50 am, "SadE54" notifications@github.com wrote:

Hi,

I would like to use Craftr for embedded dev. Could it be possible to support the armcc compiler from ARM ? (From 3.5, this compiler is supported by cmake)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/craftr-build/craftr/issues/116, or mute the thread https://github.com/notifications/unsubscribe/ABQeJlOREESaSBumQvTpuqCPlA9ClgKaks5qL7zqgaJpZM4I2IZv .

SadE54 commented 8 years ago

Hi,

Thanks , it great to hear that. But take your time ! I'm not hurry , and it's your software :) I hope you soft will replace this f.... complicated Cmake for me !

NiklasRosenstein commented 8 years ago

Hi! It appears the ARM compilers are not free to use?

Also, armclang looks like it has the same interface as clang, so you could just set CC=armclang and it should work, eventually with some additional flags required.

SadE54 commented 8 years ago

Hi ,

You're right it's not free:-/ I didn't know about armclang (V6). it seems they rewrite compilers , based on clang. In fact, I was talking about armcc (compilers V4 and V5). But currently is there a langage 'agnostic' interface to use such specific compilers ? Anyway armcc is using almost the same flags than gcc and .dep files too.

NiklasRosenstein commented 8 years ago

I'll have to look how much a license costs, but I don't have any use other than testing to make it work with Craftr yet. :( There is a "standard" interface for Asm/C/C++ compilers to support platform independent compilation as good as possible. If armcc provides a Gcc-like interface, you should be able to create a wrapper like this:

from craftr.ext.compiler.gcc import GccCompiler
armcc = GccCompiler('armcc', 'c')
obj = armcc.compile(...)
bin = armcc.link(inputs = obj, ...)

However you an achieve the same behaviour by. setting the environment variable CC=armcc and use

from craftr.ext.platform import cc
NiklasRosenstein commented 8 years ago

Oh eventually it will complain when trying to detect the compiler version. It'll do armcc --version. What's the output for this command?

SadE54 commented 8 years ago

Hi, It does not make sense to buy a license :) . In fact , armcc is just a specific compiler among others. In embedded world , you can find a lot compilers more or less related to gcc , sometimes not related at all. But most of build systems are locked to gcc or clang or studio :-/ I'm a python newbie (but I really want to improve my skills) - and I don't know if it's easy or not to write a 'compiler plugin' for craftr !

and for the -- version thing : Fatal error: C3900U: Unrecognized option '--version'.

I have to type : armcc --vsn to get version

NiklasRosenstein commented 8 years ago

Hey! If you want to use GCC instead, it's probably just a matter of passing the target architecture to GCC..?

from craftr.ext import platform
obj = platform.cc.compile(
  sources = path.glob('src/*.c'),
  additional_flags = ['-arch=arm'],
)

Or does it require cross-compilation? In that case, just override CC to use the cross-compiler version of GCC.

CC=gcc-arm-linux-gnueabi craftr

I have to type : armcc --vsn to get version

Interesting. Could you show me the output of this? Craftr tries various invocations to find the compiler it is dealing with and parses the output to find the compiler's version.

NiklasRosenstein commented 8 years ago

Note: You can use a craftrc.py file to set environment variables always, so you don't have to specify CC=... on the command-line every time.

# craftrc.py
from craftr import environ
environ['CC'] = 'gcc-arm-linux-gnueabi'
NiklasRosenstein commented 8 years ago

Hey @SadE54 , I've just update the documentation with a tutorial on writing compiler plugins, I hope that helps you getting started. :) For simple projects, it might be enough to just use manual targets as a starter. I'd appreciate any feedback on the tutorial

http://craftr.readthedocs.io/en/latest/tutorials/compiler-plugins.html

SadE54 commented 8 years ago

Hi, Thanks for the tutorial . I'll start writing the plugin as soon as possible !