Re: [PATCH] FreeBSD arm support, EABI.

2014-11-09 Thread Andreas Tobler

Hi Richard,

On 07.11.14 14:45, Richard Earnshaw wrote:

On 02/11/14 22:11, Andreas Tobler wrote:

Hello all,

this is a patch which brings support for arm*-*-freebsd* to trunk.
The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and
armv6hf-*-freebsd*.
armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.

There is kernel development for armv8 aka. aarch64 ongoing but this is
not covered here. This patch only covers 32-bit arm in a basic manner.

The patch is built and tested against armv6, armv6hf and arm. The former
two tests (lots of) were done on a WANDBOARD-QUAD, the latter on a
MARVELL board with 256MB Ram and 200MHz cpu (around 72h+ for a build
and test.)

Results for armv6hf are on the list. Only one entry but locally I ran
several dozens runs...

Once if this patch is accepted a few test suite additions will follow.
(arm*-*-*eabi* -> arm_eabi)

The patch itself is also prepared for arm*eb*-*-freebsd*, but I could
not test since I lack the HW.


[snip]


This mostly looks OK, but a couple of nits.


Thank you for the review.


Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c(revision 217020)
+++ gcc/config/arm/arm.c(working copy)
@@ -2202,7 +2202,11 @@
  {
/* For Linux, we have access to kernel support for atomic operations.  */
if (arm_abi == ARM_ABI_AAPCS_LINUX)
+#ifndef __FreeBSD__
  init_sync_libfuncs (2 * UNITS_PER_WORD);
+#else
+init_sync_libfuncs (UNITS_PER_WORD);
+#endif


This would be better handled by some refactoring, so that we can
eliminate the conditionalized code in the main function.  Define
something like MAX_SYNC_LIBFUNC_SIZE and then override it in the
FreeBSD-specific header.


Done.


@@ -3036,6 +3040,9 @@
warning (0, "target CPU does not support unaligned accesses");
unaligned_access = 0;
  }
+#ifdef __FreeBSD__
+  unaligned_access = 0;
+#endif



This really should be fixed in the OS; you're not really supporting the
architecture properly if you don't allow this on v6 or later.  In the
mean time, the code should be moved to SUBTARGET_OVERRIDE_OPTIONS.


Agreed, for now as you suggested included it in the 
SUBTARGET_OVERRIDE_OPTIONS of config/arm/freebsd.h



Index: gcc/config/arm/freebsd.h
===
--- gcc/config/arm/freebsd.h(revision 0)
+++ gcc/config/arm/freebsd.h(working copy)



+
+/*  Use the AAPCS type for wchar_t, override the one from config/freebsd.h.  */
+#undef  WCHAR_TYPE
+#define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long int")


I don't think you should really be targeting anything that is not AAPCS
based; so this should surely collapse to 'unsigned int'.


Done.

Attached the revised version with adapted Changelog (thanks Gerald).
Bootstraped and tested (results sent).

Ok for trunk?

Thanks again for your time.
Andreas

toplevel:

2014-11-08  Andreas Tobler  

* configure.ac: Don't add ${libgcj} for arm*-*-freebsd*.
* configure: Regenerate.

gcc:
2014-11-08  Andreas Tobler  

* config.gcc (arm*-*-freebsd*): New configuration.
* config/arm/freebsd.h: New file.
* config.host: Add extra components for arm*-*-freebsd*.
* config/arm/arm.h: Introduce MAX_SYNC_LIBFUNC_SIZE.
* config/arm/arm.c (arm_init_libfuncs): Use MAX_SYNC_LIBFUNC_SIZE.


libgcc:
2014-11-08  Andreas Tobler  

* config.host (arm*-*-freebsd*): Add new configuration for
arm*-*-freebsd*.
* config/arm/freebsd-atomic.c: New file.
* config/arm/t-freebsd: Likewise.
* config/arm/unwind-arm.h: Add __FreeBSD__ to the list of
'PC-relative indirect' OS's.


libstdc++-v3:
2014-11-08  Andreas Tobler  

* configure.host: Add arm*-*-freebsd* port_specific_symbol_files.

Index: configure
===
--- configure   (revision 217256)
+++ configure   (working copy)
@@ -3352,6 +3352,9 @@
   alpha*-*-*vms*)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
+  arm*-*-freebsd*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
   arm-wince-pe)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
Index: configure.ac
===
--- configure.ac(revision 217256)
+++ configure.ac(working copy)
@@ -711,6 +711,9 @@
   alpha*-*-*vms*)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
+  arm*-*-freebsd*)
+noconfigdirs="$noconfigdirs ${libgcj}"
+;;
   arm-wince-pe)
 noconfigdirs="$noconfigdirs ${libgcj}"
 ;;
Index: gcc/config/arm/arm.c
===
--- gcc/config/arm/arm.c(revision 217256)
+++ gcc/config/arm/arm.c(working copy)
@@ -2229,7 +2229,7 @@
 {
   /* For Linux, we have access to kernel support for atomic operations.  */
   if (arm_abi == ARM_ABI_AAPCS_LINUX)

Re: [PATCH] FreeBSD arm support, EABI.

2014-11-07 Thread Richard Earnshaw
On 02/11/14 22:11, Andreas Tobler wrote:
> Hello all,
> 
> this is a patch which brings support for arm*-*-freebsd* to trunk.
> The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and 
> armv6hf-*-freebsd*.
> armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.
> 
> There is kernel development for armv8 aka. aarch64 ongoing but this is 
> not covered here. This patch only covers 32-bit arm in a basic manner.
> 
> The patch is built and tested against armv6, armv6hf and arm. The former 
> two tests (lots of) were done on a WANDBOARD-QUAD, the latter on a 
> MARVELL board with 256MB Ram and 200MHz cpu (around 72h+ for a build 
> and test.)
> 
> Results for armv6hf are on the list. Only one entry but locally I ran 
> several dozens runs...
> 
> Once if this patch is accepted a few test suite additions will follow.
> (arm*-*-*eabi* -> arm_eabi)
> 
> The patch itself is also prepared for arm*eb*-*-freebsd*, but I could 
> not test since I lack the HW.
> 
> I appreciate comments, questions and also an ack if this patch is ok for 
> trunk.
> 
> TIA,
> 
> Andreas
> 
> toplevel:
> 
> 2014-11-02  Andreas Tobler  
> 
>   * configure.ac: Don't add ${libgcj} for arm*-*-freebsd*.
>   * configure: Regenerate.
> 
> gcc:
> 
> 2014-11-02  Andreas Tobler  
> 
>   * config.gcc (arm*-*-freebsd*): New configuration.
>   * config/arm/freebsd.h: New file.
>   * config.host: A extras components for arm*-*-freebsd*.
>   * config/arm/arm.c (arm_init_libfuncs): FreeBSD does not support 8 byte
>   atomics for __ARM_ARCH__ < 6 yet.
>   (arm_option_override): FreeBSD has not yet implemented unaligned access.
> 
> libgcc:
> 
> 2014-11-02  Andreas Tobler  
> 
>   * config.host (arm*-*-freebsd*): Add new configuration for
>   arm*-*-freebsd*.
>   * config/arm/freebsd-atomic.c: New file.
>   * config/arm/t-freebsd: Likewise.
>   * config/arm/unwind-arm.h: Add __FreeBSD__ to the list of 'PC-relative
>   indirect' OS's.
> 
> libstdc++:
> 
> 2014-11-02  Andreas Tobler  
> 
>   * configure.host: Add arm*-*-freebsd* port_specific_symbol_files.
> 
> 

This mostly looks OK, but a couple of nits.


> Index: gcc/config/arm/arm.c
> ===
> --- gcc/config/arm/arm.c  (revision 217020)
> +++ gcc/config/arm/arm.c  (working copy)
> @@ -2202,7 +2202,11 @@
>  {
>/* For Linux, we have access to kernel support for atomic operations.  */
>if (arm_abi == ARM_ABI_AAPCS_LINUX)
> +#ifndef __FreeBSD__
>  init_sync_libfuncs (2 * UNITS_PER_WORD);
> +#else
> +init_sync_libfuncs (UNITS_PER_WORD);
> +#endif

This would be better handled by some refactoring, so that we can
eliminate the conditionalized code in the main function.  Define
something like MAX_SYNC_LIBFUNC_SIZE and then override it in the
FreeBSD-specific header.

> @@ -3036,6 +3040,9 @@
>warning (0, "target CPU does not support unaligned accesses");
>unaligned_access = 0;
>  }
> +#ifdef __FreeBSD__
> +  unaligned_access = 0;
> +#endif
>  

This really should be fixed in the OS; you're not really supporting the
architecture properly if you don't allow this on v6 or later.  In the
mean time, the code should be moved to SUBTARGET_OVERRIDE_OPTIONS.

> Index: gcc/config/arm/freebsd.h
> ===
> --- gcc/config/arm/freebsd.h  (revision 0)
> +++ gcc/config/arm/freebsd.h  (working copy)

> +
> +/*  Use the AAPCS type for wchar_t, override the one from config/freebsd.h.  
> */
> +#undef  WCHAR_TYPE
> +#define WCHAR_TYPE (TARGET_AAPCS_BASED ? "unsigned int" : "long int")

I don't think you should really be targeting anything that is not AAPCS
based; so this should surely collapse to 'unsigned int'.






Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Joseph Myers
On Mon, 3 Nov 2014, Andreas Tobler wrote:

> > The __FreeBSD__ conditionals in arm.c are incorrect.  Those would test for
> > FreeBSD *host*, but you need a conditional for FreeBSD *target* here.
> > 
> 
> Ouch, yes.
> 
> This I'd have to define via config/arm/freebsd.h, right?
> 
> #define ARM_FREEBSD

Yes, that seems the right place.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Andreas Tobler

On 03.11.14 18:53, Joseph Myers wrote:

On Sun, 2 Nov 2014, Andreas Tobler wrote:


* config/arm/arm.c (arm_init_libfuncs): FreeBSD does not support 8
byte
atomics for __ARM_ARCH__ < 6 yet.
(arm_option_override): FreeBSD has not yet implemented unaligned
access.


The __FreeBSD__ conditionals in arm.c are incorrect.  Those would test for
FreeBSD *host*, but you need a conditional for FreeBSD *target* here.



Ouch, yes.

This I'd have to define via config/arm/freebsd.h, right?

#define ARM_FREEBSD

Index: arm.c
===
--- arm.c   (revision 216539)
+++ arm.c   (working copy)
@@ -2188,7 +2188,11 @@
 {
   /* For Linux, we have access to kernel support for atomic 
operations.  */

   if (arm_abi == ARM_ABI_AAPCS_LINUX)
+#ifndef ARM_FREEBSD
 init_sync_libfuncs (2 * UNITS_PER_WORD);
+#else
+init_sync_libfuncs (UNITS_PER_WORD);
+#endif



Thank you!
Andreas




Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Joseph Myers
On Sun, 2 Nov 2014, Andreas Tobler wrote:

>   * config/arm/arm.c (arm_init_libfuncs): FreeBSD does not support 8
> byte
>   atomics for __ARM_ARCH__ < 6 yet.
>   (arm_option_override): FreeBSD has not yet implemented unaligned
> access.

The __FreeBSD__ conditionals in arm.c are incorrect.  Those would test for 
FreeBSD *host*, but you need a conditional for FreeBSD *target* here.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Andreas Tobler

Hi Kyrill,

On 03.11.14 12:44, Kyrill Tkachov wrote:


CC'ing arm maintainers and a couple of comments inline.


Thank you!


On 02/11/14 22:11, Andreas Tobler wrote:

Hello all,

this is a patch which brings support for arm*-*-freebsd* to trunk.
The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and
armv6hf-*-freebsd*.
armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.


Why split at ARM_ARCH == 6 ? I see in the patch you define
TARGET_FREEBSD_ARMv6 but
only ever use it to define the SUBTARGET_CPU_DEFAULT. In the other arm
triplets I don't think
we have architecture-specific identifiers in the arm* parts...


Well, I mentioned it in another response, it was unfortunate from me to 
write the equal sign. What we currently do is the following:


ARM_ARCH >= 6 becomes armv6*-*-freebsd*
ARM_ARCH <= 5 becomes arm-*-freebsd*

So, would you suggest to leave the SUBTARGET_CPU_DEFAULT away?


+
+#if defined (TARGET_FREEBSD_ARMv6)
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs
+#else
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
+#endif
+


What about ARMv7? The default CPU there is TARGET_CPU_cortexa8


Would fall under armv6 with the above rule.


Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 217020)
+++ gcc/config.gcc  (working copy)
@@ -259,7 +259,6 @@
  arm*-wince-pe*\
| arm*-*-ecos-elf   \
| arm*-*-elf\
- | arm*-*-freebsd* \
| arm*-*-linux* \
| arm*-*-uclinux*   \
| i[34567]86-go32-* \
@@ -1000,6 +999,27 @@
extra_options="${extra_options} arm/vxworks.opt"
tmake_file="${tmake_file} arm/t-arm arm/t-vxworks"
;;
+arm*-*-freebsd*)# ARM FreeBSD EABI
+   tm_file="dbxelf.h elfos.h ${fbsd_tm_file} arm/elf.h"
+   case $target in
+   arm*b-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+   ;;
+   esac
+   tmake_file="${tmake_file} arm/t-arm arm/t-bpabi"
+   tm_file="${tm_file} arm/bpabi.h arm/freebsd.h arm/aout.h arm/arm.h"
+   case $target in
+   armv[67]*-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
+   ;;
+   esac


So you also match armv7*-*-freebsd*. As mentioned above I'm not sure why
we would want these per-architecture triplets. If we do want to have
these per-architecture triplets, there is also the ARMv8 AArch32 state
which is supported in the arm backend and can be identified by ARM_ARCH
== 8. Do we want to add an armv8*-*-freebsd triplet as well?


Aehm, this is left over from a trial where I tried an 
armv7hf-*-freebsd*. This does not exist yet and I'm not sure if we 
really want that.


Regarding armv8, for the 64-bit there will be another triplet. armv8 
with AArch32 would also fall under armv6 now, but I can not say how it 
would behave, I lack the hardware ;)


Thanks for the feedback.

Andreas



Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Kyrill Tkachov

Hi Andreas,

CC'ing arm maintainers and a couple of comments inline.

On 02/11/14 22:11, Andreas Tobler wrote:

Hello all,

this is a patch which brings support for arm*-*-freebsd* to trunk.
The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and
armv6hf-*-freebsd*.
armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.


Why split at ARM_ARCH == 6 ? I see in the patch you define 
TARGET_FREEBSD_ARMv6 but
only ever use it to define the SUBTARGET_CPU_DEFAULT. In the other arm 
triplets I don't think

we have architecture-specific identifiers in the arm* parts...


+
+#if defined (TARGET_FREEBSD_ARMv6)
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs
+#else
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
+#endif
+


What about ARMv7? The default CPU there is TARGET_CPU_cortexa8


Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 217020)
+++ gcc/config.gcc  (working copy)
@@ -259,7 +259,6 @@
 arm*-wince-pe* \
   | arm*-*-ecos-elf\
   | arm*-*-elf \
- | arm*-*-freebsd* \
   | arm*-*-linux*  \
   | arm*-*-uclinux*\
   | i[34567]86-go32-*  \
@@ -1000,6 +999,27 @@
extra_options="${extra_options} arm/vxworks.opt"
tmake_file="${tmake_file} arm/t-arm arm/t-vxworks"
;;
+arm*-*-freebsd*)# ARM FreeBSD EABI
+   tm_file="dbxelf.h elfos.h ${fbsd_tm_file} arm/elf.h"
+   case $target in
+   arm*b-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+   ;;
+   esac
+   tmake_file="${tmake_file} arm/t-arm arm/t-bpabi"
+   tm_file="${tm_file} arm/bpabi.h arm/freebsd.h arm/aout.h arm/arm.h"
+   case $target in
+   armv[67]*-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
+   ;;
+   esac


So you also match armv7*-*-freebsd*. As mentioned above I'm not sure why 
we would want these per-architecture triplets. If we do want to have 
these per-architecture triplets, there is also the ARMv8 AArch32 state 
which is supported in the arm backend and can be identified by ARM_ARCH 
== 8. Do we want to add an armv8*-*-freebsd triplet as well?


Cheers,
Kyrill




Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Andreas Tobler
- Original Message 
From: Bin.Cheng 
To: Andreas Tobler 
Cc: GCC Patches 
Subject: Re: [PATCH] FreeBSD arm support, EABI.
Date: 03/11/14 10:04

> On Mon, Nov 3, 2014 at 6:11 AM, Andreas Tobler
<andreast-l...@fgznet.ch> wrote:
> > Hello all,
> >
> > this is a patch which brings support for arm*-*-freebsd* to trunk.
> > The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and
> > armv6hf-*-freebsd*.
> > armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.
> Just out of curiosity, what about armv7?

Sorry, I should have written 'armv6 stands for ARM_ARCH >= 6'. But I have no
evidence how an armv8 (ARM_ARCH == 8) will/would work.

Thanks for the curiosity :)

Andreas




Re: [PATCH] FreeBSD arm support, EABI.

2014-11-03 Thread Bin.Cheng
On Mon, Nov 3, 2014 at 6:11 AM, Andreas Tobler  wrote:
> Hello all,
>
> this is a patch which brings support for arm*-*-freebsd* to trunk.
> The architectures supported are arm-*-*freebsd*, armv6-*-freebsd* and
> armv6hf-*-freebsd*.
> armv6 stands for ARM_ARCH == 6, arm stands for ARM_ARCH < 6.
Just out of curiosity, what about armv7?

Thanks,
bin
>
> There is kernel development for armv8 aka. aarch64 ongoing but this is not
> covered here. This patch only covers 32-bit arm in a basic manner.
>
> The patch is built and tested against armv6, armv6hf and arm. The former two
> tests (lots of) were done on a WANDBOARD-QUAD, the latter on a MARVELL board
> with 256MB Ram and 200MHz cpu (around 72h+ for a build and test.)
>
> Results for armv6hf are on the list. Only one entry but locally I ran
> several dozens runs...
>
> Once if this patch is accepted a few test suite additions will follow.
> (arm*-*-*eabi* -> arm_eabi)
>
> The patch itself is also prepared for arm*eb*-*-freebsd*, but I could not
> test since I lack the HW.
>
> I appreciate comments, questions and also an ack if this patch is ok for
> trunk.
>
> TIA,
>
> Andreas
>
> toplevel:
>
> 2014-11-02  Andreas Tobler  
>
> * configure.ac: Don't add ${libgcj} for arm*-*-freebsd*.
> * configure: Regenerate.
>
> gcc:
>
> 2014-11-02  Andreas Tobler  
>
> * config.gcc (arm*-*-freebsd*): New configuration.
> * config/arm/freebsd.h: New file.
> * config.host: A extras components for arm*-*-freebsd*.
> * config/arm/arm.c (arm_init_libfuncs): FreeBSD does not support 8
> byte
> atomics for __ARM_ARCH__ < 6 yet.
> (arm_option_override): FreeBSD has not yet implemented unaligned
> access.
>
> libgcc:
>
> 2014-11-02  Andreas Tobler  
>
> * config.host (arm*-*-freebsd*): Add new configuration for
> arm*-*-freebsd*.
> * config/arm/freebsd-atomic.c: New file.
> * config/arm/t-freebsd: Likewise.
> * config/arm/unwind-arm.h: Add __FreeBSD__ to the list of
> 'PC-relative
> indirect' OS's.
>
> libstdc++:
>
> 2014-11-02  Andreas Tobler  
>
> * configure.host: Add arm*-*-freebsd* port_specific_symbol_files.
>


Re: [PATCH] FreeBSD arm support, EABI.

2014-11-02 Thread Gerald Pfeifer

On Sunday 2014-11-02 23:11, Andreas Tobler wrote:

this is a patch which brings support for arm*-*-freebsd* to trunk.


Nice!


* config.host: A extras components for arm*-*-freebsd*.


"Add" instead of "A"?

Gerald