Quantcast

LLVM/Clang cross-compiling for ARM

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

LLVM/Clang cross-compiling for ARM

Damjan Marion

Hi,

What is the current status of LLVM/Clang cross-compiling for ARM targets?
Is anybody working actively on this?

As it natively supports v6 and v7 architectures sounds like perfect choice for new CPUs,
specially with fact that we cannot use recent gcc versions.

Thanks,

Damjan_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Vassilis Laganakos
Hello Damjan,

----- Original Message -----

> From:Damjan Marion <[hidden email]>
> To:[hidden email]
> 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.

I'll hopefully get back soon with some useful info about this...

> As it natively supports v6 and v7 architectures sounds like perfect choice for
> new CPUs,
> specially with fact that we cannot use recent gcc versions.
>
Yes :) however, we would need to commit a version of llvm
that can also cross-build in the build tree/system. Or else we're
exactly at the same point where we were with having a later
version of GCC as an external compiler. The fact that llvm can
be imported in the build system is the great win in this case ;)


Thanks,
Vassilis

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Damjan Marion

Hi Vassilis,

On Apr 14, 2011, at 12:02 AM, Vassilis Laganakos wrote:

> Hello Damjan,
>
> ----- Original Message -----
>> From:Damjan Marion <[hidden email]>
>> To:[hidden email]
>> 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
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Mark Tinguely-2
 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<[hidden email]>
>>> To:[hidden email]
>>> 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
> _______________________________________________
> [hidden email] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-arm
> To unsubscribe, send any mail to "[hidden email]"
>

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Damjan Marion

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<[hidden email]>
>>>> To:[hidden email]
>>>> 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
>> _______________________________________________
>> [hidden email] mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-arm
>> To unsubscribe, send any mail to "[hidden email]"
>>
>

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Vassilis Laganakos
In reply to this post by Damjan Marion




----- Original Message -----
[...]

> Hi Vassilis,
>
> On Apr 14, 2011, at 12:02 AM, Vassilis Laganakos wrote:
>
> > Hello Damjan,
> >
> > ----- Original Message -----
> >> From:Damjan Marion <[hidden email]>
> >> To:[hidden email]
> >> 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?
>
I didn't actively look into it, I trusted the info from http://wiki.freebsd.org/BuildingFreeBSDWithClang
that says: "Please note that cross compiling is not yet supported by clang." :)
So I went off to try building a cross-compiling llvn/clang that builts source
for ARM.

> 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 wasn't aware of that, but I do need to read a bit more about llvm ...

> >
> > I'll hopefully get back soon with some useful info about this...
>
> Cool, please keep us updated.
>
Sure!

Thanks,
Vassilis L.

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Vassilis Laganakos
In reply to this post by Damjan Marion
Hi Damjan, Mark,

----- Original Message -----

> From:Damjan Marion <[hidden email]>
> To:Mark Tinguely <[hidden email]>
> Cc:Vassilis Laganakos <[hidden email]>; "[hidden email]" <[hidden email]>
> Sent:Thursday, April 14, 2011 8:13 AM
> Subject:Re: LLVM/Clang cross-compiling for ARM
>
>
> 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
>
That's the same I get when I build llvm/clang as a cross-compiler, and I thought that
something was wrong. I'd expect that to be: "arm-unknown-freebsd9.0", but it
seems from your test bellow that it does generate ARM code.

> # 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
>


Well you proved the opposite from what we assumed, since this looks like ARM assembly to me :)

Anyone knows if something has changed in http://wiki.freebsd.org/BuildingFreeBSDWithClang
since it was last edited?


Damjan, if you find some more info about this with llvm/clang, could you please post
the links here? :)

Thanks,
Vassilis

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Mark Tinguely-2
On 4/14/2011 6:06 AM, Vassilis Laganakos wrote:

> Hi Damjan, Mark,
>
> ----- Original Message -----
>
>> From:Damjan Marion<[hidden email]>
>> To:Mark Tinguely<[hidden email]>
>> Cc:Vassilis Laganakos<[hidden email]>; "[hidden email]"<[hidden email]>
>> Sent:Thursday, April 14, 2011 8:13 AM
>> Subject:Re: LLVM/Clang cross-compiling for ARM
>>
>>
>> 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
>>
> That's the same I get when I build llvm/clang as a cross-compiler, and I thought that
> something was wrong. I'd expect that to be: "arm-unknown-freebsd9.0", but it
> seems from your test bellow that it does generate ARM code.
>
>> # 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
>>
>
> Well you proved the opposite from what we assumed, since this looks like ARM assembly to me :)
>
> Anyone knows if something has changed in http://wiki.freebsd.org/BuildingFreeBSDWithClang
> since it was last edited?
>
>
> Damjan, if you find some more info about this with llvm/clang, could you please post
> the links here? :)
>
> Thanks,
> Vassilis
>
>

Good news. Thank-you for the update.

--Mark.
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LLVM/Clang cross-compiling for ARM

Damjan Marion
In reply to this post by Vassilis Laganakos

Hi Vassilis,

On Apr 14, 2011, at 1:06 PM, Vassilis Laganakos wrote:

> Hi Damjan, Mark,
>
> ----- Original Message -----
>
>> From:Damjan Marion <[hidden email]>
>> To:Mark Tinguely <[hidden email]>
>> Cc:Vassilis Laganakos <[hidden email]>; "[hidden email]" <[hidden email]>
>> Sent:Thursday, April 14, 2011 8:13 AM
>> Subject:Re: LLVM/Clang cross-compiling for ARM
>>
>>
>> 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
>>
> That's the same I get when I build llvm/clang as a cross-compiler, and I thought that
> something was wrong. I'd expect that to be: "arm-unknown-freebsd9.0", but it
> seems from your test bellow that it does generate ARM code.

Seems that this just shows host architecture.

>
>> <snip>
>
> Well you proved the opposite from what we assumed, since this looks like ARM assembly to me :)
>
> Anyone knows if something has changed in http://wiki.freebsd.org/BuildingFreeBSDWithClang
> since it was last edited?

My understanding is that clang/LLVM architecture is build from day one to support cross compilation so same clang executable can build code for multiple targets. You can see the list of supported architectures with "llc --version"
For specific architecture you can see list of all variants and features with "llvm-as < /dev/null | llc -march=arm -mcpu=help"

Unfortunately llc and llvm-as are not built as part of buildworld. According to folks from freebsd-clang IRC channel llc and llvm-as are not built because there is no use of them.

>
>
> Damjan, if you find some more info about this with llvm/clang, could you please post
> the links here? :)

I dont have any special reference, but looking into source code might help :)

BTW According to #freebsd-clang folks cross-compilation might work just by renaming or symlinking clang to arm-freebsd-clang triple (or similar). They are also looking for feedback.

Regards,

Damjan




_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arm
To unsubscribe, send any mail to "[hidden email]"
Loading...