LLVM/Clang cross-compiling for ARM

Damjan Marion damjan.marion at gmail.com
Thu Apr 14 07:14:02 UTC 2011


Hi Mark,

Seems that clang from current (made by i386 buildworld) is able to build ARM code:

# clang -v                                                                                                                                                          FreeBSD clang version 2.9 (trunk 126547) 20110226
Target: i386-undermydesk-freebsd9.0
Thread model: posix

# clang -march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf -integrated-as hello.c -o hello.o -c                                                                              
# file hello.o                                                                                                                                                     
hello.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

# clang -march=armv7-a -mfloat-abi=soft -ccc-host-triple arm-elf hello.c -o hello.S -S

# cat hello.S

	.syntax unified
	.cpu cortex-a8
	.eabi_attribute 6, 10
	.eabi_attribute 7, 65
	.eabi_attribute 8, 1
	.eabi_attribute 9, 2
	.eabi_attribute 10, 2
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.file	"hello.c"
	.text
	.globl	main
	.align	2
	.type	main,%function
main:
	push	{r11, lr}
	mov	r11, sp
	sub	sp, sp, #12
	mov	r0, #0
	str	r0, [r11, #-4]
	str	r0, [sp, #4]
	movw	r0, :lower16:.L.str
	movt	r0, :upper16:.L.str
	bl	printf
	str	r0, [sp]
	ldr	r0, [sp, #4]
	mov	sp, r11
	ldmia	sp!, {r11, pc}
.Ltmp0:
	.size	main, .Ltmp0-main

	.type	.L.str,%object
	.section	.rodata.str1.1,"aMS",%progbits,1
.L.str:
	.asciz	 "Hello World!\n"
	.size	.L.str, 14


Regards,

Damjan


On Apr 14, 2011, at 4:25 AM, Mark Tinguely wrote:

> From distant memory, Clang was looking up the current processor and compiled in the assembly options for that architecture (i386). I can't remember if it was still kicking out i386 assembly as well. One idea I had was short-circuit the answer to those architecture queries and return "arm".
> 
> Has anyone tried to compile Clang on an ARM arch and then build world with that? I suppose that would be a slow development environment.
> 
> --Mark.
> 
> On 4/13/2011 5:35 PM, Damjan Marion wrote:
>> Hi Vassilis,
>> 
>> On Apr 14, 2011, at 12:02 AM, Vassilis Laganakos wrote:
>> 
>>> Hello Damjan,
>>> 
>>> ----- Original Message -----
>>>> From:Damjan Marion<damjan.marion at gmail.com>
>>>> To:freebsd-arm at freebsd.org
>>>> Cc:
>>>> Sent:Sunday, April 10, 2011 5:10 PM
>>>> Subject:Re: LLVM/Clang cross-compiling for ARM
>>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> What is the current status of LLVM/Clang cross-compiling for ARM targets?
>>>> Is anybody working actively on this?
>>>> 
>>> I started taking a look into building llvm as cross-compiler
>>> for ARM and trying to build -CURRENT for an existing port,
>>> so see how far we get :)
>>> 
>>> I'm currently stuck a bit in the first step :) As Mark T. pointed
>>> out in a recent email, llvm in -CURRENT does not cross-build,
>>> so we have to use an external compiler for now.
>> What exactly is missing in current version of llvm in -CURRENT?
>> 
>> After reading some high level overview of llvm i was under impression
>> that llvm natively supports multiple targets, but seems that I was wrong.
>> 
>>> I'll hopefully get back soon with some useful info about this...
>> Cool, please keep us updated.
>> 
>> Thanks,
>> 
>> Damjan
>> _______________________________________________
>> freebsd-arm at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-arm
>> To unsubscribe, send any mail to "freebsd-arm-unsubscribe at freebsd.org"
>> 
> 



More information about the freebsd-arm mailing list