[PATCH] add better support for Raspberry Pi board

Karel Gardas karel.gardas at centrum.cz
Tue Jan 29 14:06:53 CET 2013


Simon,

thanks for this. I've done this patch originally based on the complains 
on haskell-user mailing list about compilation to RPi. Otherwise I'm not 
that found of this hardware class, but rather prefer working on ARMv7 or 
even ARMv8.

Anyway, thanks!
Karel

On 01/29/13 11:27 AM, Simon Marlow wrote:
> I've finished this now. I committed the second part of your patch (the
> DriverPipeline one), fixed up the "detection" of hard-float, which was
> based on the triple passed to --target but needed some tweaking, and
> I've made it detect VFPv2 from the C compiler. We should probably be
> doing the hard-float detection the same way.
>
> So now you don't need any special -optlc options for registerised
> compilation with LLVM on Raspberry Pi, it just works.
>
> Cheers,
> Simon
>
> On 25/01/13 21:23, Karel Gardas wrote:
>>
>> BTW: I've forgot to mention: hard versus soft float abis are well
>> detected by configure itself. So this is not the problem in my patch.
>> The only issue is in testing/guessing for FPU/NEON. Good way may be to
>> grep /proc/cpuinfo but this is only applicable while doing native
>> compile on ARM-Linux platform. Is that what majority of GHC users will
>> do? I don't think so as I think the way for majority will be
>> cross-compilation but perhaps we can at least try it for those doing
>> native compiles? What do you think about it?
>>
>> Thanks!
>> Karel
>>
>> On 01/25/13 09:59 PM, Karel Gardas wrote:
>>> On 01/25/13 09:38 PM, Simon Marlow wrote:
>>>> This would improve things for RPi, but we shouldn't be guessing here.
>>>> gcc has predefines for the appropriate features:
>>>>
>>>> #define __ARM_PCS_VFP 1
>>>>
>>>> indicates hard-float ABI, and
>>>>
>>>> #define __VFP_FP__ 1
>>>>
>>>> indicates VFP presences (2 or 3? I don't know)
>>>
>>> The problem is that IIRC those defines are presented when you use
>>> appropriate GCC's command-line option. It does not tell anything about
>>> the target hardware itself. So that's why I'm just guessing in the
>>> patch. But honestly speaking do you think there is any other GHC user
>>> who would use GHC on ARMv6 and the hardware will be different than RPi?
>>> I think a chance for this is very low since otherwise everybody is using
>>> ARMv7 these days...
>>>
>>> Anyway, if you don't like guessing, what about to add few configure
>>> options which will drive the generation of ARM related bits into
>>> settings file and keeping some good defaults like we use now? i.e.
>>> ARMv7+VFPv3+NEON or ARMv6+VFPv2 or ARMv5 alone?
>>>
>>> Thanks!
>>> Karel
>>>
>>>>
>>>> Cheers,
>>>> Simon
>>>>
>>>> On 25/01/13 15:56, Karel Gardas wrote:
>>>>> This patch adds support for Raspberry Pi board. The board is based
>>>>> on Broadcom BCM2835, which includes ARM1176JZF-S CPU core. The core
>>>>> is classical ARM11 so implementing ARMv6 ISA, but also provides VFPv2
>>>>> FPU
>>>>> unit. As this looks like fairly popular hardware, in this patch we
>>>>> assume
>>>>> detected ARMv6 hardware to support VFPv2. Also as Raspberry Pi is very
>>>>> commonly
>>>>> used with hard-float ABI Linux distribution, the patch relaxes a
>>>>> condition
>>>>> of "hard-float support for ARMv7 only" to any general ARM core.
>>>>> ---
>>>>> aclocal.m4 | 2 +-
>>>>> compiler/main/DriverPipeline.hs | 9 ++++++---
>>>>> 2 files changed, 7 insertions(+), 4 deletions(-)
>>>>>
>>>>> diff --git a/aclocal.m4 b/aclocal.m4
>>>>> index edbe389..b23568f 100644
>>>>> --- a/aclocal.m4
>>>>> +++ b/aclocal.m4
>>>>> @@ -369,7 +369,7 @@ AC_DEFUN([GET_ARM_ISA],
>>>>> [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
>>>>> changequote(, )dnl
>>>>> ARM_ISA=ARMv6
>>>>> - ARM_ISA_EXT="[]"
>>>>> + ARM_ISA_EXT="[VFPv2]"
>>>>> changequote([, ])dnl
>>>>> ],
>>>>> [changequote(, )dnl
>>>>> diff --git a/compiler/main/DriverPipeline.hs
>>>>> b/compiler/main/DriverPipeline.hs
>>>>> index c24bb51..81d0bc0 100644
>>>>> --- a/compiler/main/DriverPipeline.hs
>>>>> +++ b/compiler/main/DriverPipeline.hs
>>>>> @@ -1454,14 +1454,17 @@ runPhase LlvmLlc input_fn dflags
>>>>> else if (elem VFPv3D16 ext)
>>>>> then ["-mattr=+v7,+vfp3,+d16"]
>>>>> else []
>>>>> + ArchARM ARMv6 ext _ -> if (elem VFPv2 ext)
>>>>> + then ["-mattr=+v6,+vfp2"]
>>>>> + else ["-mattr=+v6"]
>>>>> _ -> []
>>>>> -- On Ubuntu/Debian with ARM hard float ABI, LLVM's llc still
>>>>> -- compiles into soft-float ABI. We need to explicitly set abi
>>>>> -- to hard
>>>>> abiOpts = case platformArch (targetPlatform dflags) of
>>>>> - ArchARM ARMv7 _ HARD -> ["-float-abi=hard"]
>>>>> - ArchARM ARMv7 _ _ -> []
>>>>> - _ -> []
>>>>> + ArchARM _ _ HARD -> ["-float-abi=hard"]
>>>>> + ArchARM _ _ _ -> []
>>>>> + _ -> []
>>>>>
>>>>> sseOpts | isSse4_2Enabled dflags = ["-mattr=+sse42"]
>>>>> | isSse2Enabled dflags = ["-mattr=+sse2"]
>>>>>
>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> ghc-devs mailing list
>>> ghc-devs at haskell.org
>>> http://www.haskell.org/mailman/listinfo/ghc-devs
>>>
>>
>
>




More information about the ghc-devs mailing list