[PATCH] FreeBSD: Stop linking _p libs for -pg as of FreeBSD 14

2021-08-12 Thread Andreas Tobler via Gcc-patches

Hi,

I would like to commit the attached patch to trunk and after a settling 
period also to all open branches.

Is this ok?

TIA,
Andreas

From a8a602620917efad2579c0dc24b178c0f2b18ff3 Mon Sep 17 00:00:00 2001
From: Andreas Tobler 
Date: Thu, 12 Aug 2021 22:35:52 +0200
Subject: [PATCH] FreeBSD: Stop linking _p libs for -pg as of FreeBSD 14

As of FreeBSD version 14, FreeBSD no longer provides profiled system
libraries like libc_p and libpthread_p. Stop linking against them if
the FreeBSD major version is 14 or more.

gcc/ChangeLog

* config/freebsd-spec.h: Change the fbsd-lib-spec for FreeBSD > 13,
do not link against profiled system libraries if -pg is invoked.
Add a define to note about this change.
* config/aarch64/aarch64-freebsd.h: Use the note to inform if -pg
is invoked on FreeBSD > 13 that FreeBSD no longer provides profiled
system libraries.
* config/arm/freebsd.h: Likewise.
* config/i386/freebsd.h: Likewise.
* config/i386/freebsd64.h: Likewise.
* config/riscv/freebsd.h: Likewise.
* config/rs6000/freebsd64.h: Likewise.
* config/rs6000/sysv4.h: Likeise.
---
 gcc/config/aarch64/aarch64-freebsd.h |  1 +
 gcc/config/arm/freebsd.h |  1 +
 gcc/config/freebsd-spec.h| 18 ++
 gcc/config/i386/freebsd.h|  1 +
 gcc/config/i386/freebsd64.h  |  1 +
 gcc/config/riscv/freebsd.h   |  1 +
 gcc/config/rs6000/freebsd64.h|  1 +
 gcc/config/rs6000/sysv4.h|  1 +
 8 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-freebsd.h 
b/gcc/config/aarch64/aarch64-freebsd.h
index e2dfe784030..cde74fa7aa5 100644
--- a/gcc/config/aarch64/aarch64-freebsd.h
+++ b/gcc/config/aarch64/aarch64-freebsd.h
@@ -35,6 +35,7 @@
 #undef  FBSD_TARGET_LINK_SPEC
 #define FBSD_TARGET_LINK_SPEC " \
 %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}  \
+" FBSD_LINK_PG_NOTE "  \
 %{v:-V} \
 %{assert*} %{R*} %{rpath*} %{defsym*}   \
 %{shared:-Bshareable %{h*} %{soname*}}  \
diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h
index 8a970be0144..d82be28e263 100644
--- a/gcc/config/arm/freebsd.h
+++ b/gcc/config/arm/freebsd.h
@@ -47,6 +47,7 @@
 #undef LINK_SPEC
 #define LINK_SPEC "\
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}   \
+  " FBSD_LINK_PG_NOTE "
\
   %{v:-V}  \
   %{assert*} %{R*} %{rpath*} %{defsym*}
\
   %{shared:-Bshareable %{h*} %{soname*}}   \
diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h
index 2b492617a0d..3a66e9a0a15 100644
--- a/gcc/config/freebsd-spec.h
+++ b/gcc/config/freebsd-spec.h
@@ -92,19 +92,29 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
libc, depending on whether we're doing profiling or need threads support.
(similar to the default, except no -lg, and no -p).  */
 
+#if FBSD_MAJOR < 14
+#define FBSD_LINK_PG_NOTHREADS "%{!pg: -lc}  %{pg: -lc_p}"
+#define FBSD_LINK_PG_THREADS   "%{!pg: %{pthread:-lpthread} -lc} " \
+   "%{pg: %{pthread:-lpthread} -lc_p}"
+#define FBSD_LINK_PG_NOTE ""
+#else
+#define FBSD_LINK_PG_NOTHREADS "%{-lc} "
+#define FBSD_LINK_PG_THREADS   "%{pthread:-lpthread} -lc "
+#define FBSD_LINK_PG_NOTE "%{pg:%nFreeBSD no longer provides profiled "\
+ "system libraries}"
+#endif
+
 #ifdef FBSD_NO_THREADS
 #define FBSD_LIB_SPEC "
\
   %{pthread: %eThe -pthread option is only supported on FreeBSD when gcc \
 is built with the --enable-threads configure-time option.} \
   %{!shared:   \
-%{!pg: -lc}
\
-%{pg:  -lc_p}  \
+" FBSD_LINK_PG_NOTHREADS " \
   }"
 #else
 #define FBSD_LIB_SPEC "
\
   %{!shared:   \
-%{!pg: %{pthread:-lpthread} -lc}   \
-%{pg:  %{pthread:-lpthread_p} -lc_p}   \
+" FBSD_LINK_PG_THREADS "   \
   }   

Re: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD

2020-05-07 Thread Andreas Tobler

On 07.05.20 09:25, Kyrylo Tkachov wrote:

Hi Andreas,


-Original Message-
From: Gcc-patches  On Behalf Of
Andreas Tobler
Sent: 06 May 2020 21:17
To: GCC Patches 
Subject: [PATCH] libgcc: aarch64: Get hwcap for FreeBSD

Hi all,

Since FreeBSD 12, FreeBSD has a sys/auxv.h header too but it doesn't
provide the getauxval function. Instead it offers the elf_aux_info
function which provides a similar functionality.
This patch gets the hwcap for FreeBSD.

Is this ok for trunk?


This whole thing is gated on __gnu_linux__.  Does FreeBSD set that?


:) No, I developed the patch before you introduced the __gnu_linux__ guard.
This guard makes the patch obsolete.

Thanks,
Andreas



Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-06 Thread Andreas Tobler

On 06.05.20 22:27, Kamil Rytarowski wrote:

On 06.05.2020 22:25, Andreas Tobler wrote:

On 06.05.20 22:12, Jakub Jelinek wrote:

On Wed, May 06, 2020 at 09:54:47PM +0200, Andreas Tobler wrote:

--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,6 @@
-#include 
-
+#include 


It needs to be:

+#if __has_include()


+#include 


+#endif


Doh :(

Fixed, thanks.


__has_include doesn't include anything, just checks if the header is
available.


Then I just wonder why the tests passed on Linux (ubuntu-20.04)



alloca.h is only needed on solaris. Other system can use stdlib.h.


Ok, I see. and alloca-leak.c succeed because I included unconditionally 
the stdlib.h. Sigh, foot shot.


Thanks,
Andreas




Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-06 Thread Andreas Tobler

On 06.05.20 22:12, Jakub Jelinek wrote:

On Wed, May 06, 2020 at 09:54:47PM +0200, Andreas Tobler wrote:

--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,6 @@
-#include 
-
+#include 


It needs to be:

+#if __has_include()


+#include 


+#endif


Doh :(

Fixed, thanks.


__has_include doesn't include anything, just checks if the header is
available.


Then I just wonder why the tests passed on Linux (ubuntu-20.04)

Andreas


[PATCH] libgcc: aarch64: Get hwcap for FreeBSD

2020-05-06 Thread Andreas Tobler

Hi all,

Since FreeBSD 12, FreeBSD has a sys/auxv.h header too but it doesn't
provide the getauxval function. Instead it offers the elf_aux_info
function which provides a similar functionality.
This patch gets the hwcap for FreeBSD.

Is this ok for trunk?

TIA,
Andreas

+2020-05-05  Andreas Tobler  
+
+   * config/aarch64/lse-init.c: Get hwcap for FreeBSD.
+

diff --git a/libgcc/config/aarch64/lse-init.c 
b/libgcc/config/aarch64/lse-init.c

index 00e9ab8cd1c..ab0d6b2f754 100644
--- a/libgcc/config/aarch64/lse-init.c
+++ b/libgcc/config/aarch64/lse-init.c
@@ -41,7 +41,16 @@ unsigned long int __getauxval (unsigned long int);
 static void __attribute__((constructor))
 init_have_lse_atomics (void)
 {
+#ifndef __FreeBSD__
   unsigned long hwcap = __getauxval (AT_HWCAP);
+#else
+  unsigned long hwcap;
+  int err;
+
+  err = elf_aux_info(AT_HWCAP, , sizeof(hwcap));
+  if (err)
+hwcap = 0;
+#endif
   __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
 }



Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-06 Thread Andreas Tobler

On 04.05.20 12:10, Kamil Rytarowski wrote:

On 04.05.2020 12:04, Jakub Jelinek wrote:

On Mon, May 04, 2020 at 11:49:27AM +0200, Kamil Rytarowski wrote:

Please include in your patch "|| defined(__NetBSD__)".


is this ok for you?

This is one reason why I'd prefer #define alloca __builtin_alloca and
leave the include away.

Andreas


It looks fine to me now.

Personally, I would include stdlib.h unconditionally and alloca.h on
!FreeBSD && !NetBSD.


It just just a test.
Perhaps it could
#include 
#if __has_include()
#include 
#endif
?

Jakub



This looks fine too.



K, fine with me. I'll commit this solution once I finished testing. Thanks,
Andreas

+2020-05-07  Andreas Tobler  
+
+   * gcc.dg/analyzer/alloca-leak.c: Include alloca.h only if
+ available.
+   * gcc.dg/analyzer/data-model-1.c: Likewise
+   * gcc.dg/analyzer/malloc-1.c: Likewise.
+   * gcc.dg/analyzer/malloc-paths-8.c: Likewise.

diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c 
b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c

index 6d9fe3431ce..e4717a1bbb3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,6 @@
-#include 
-
+#include 
+#if __has_include()
+#endif
 void *test (void)
 {
   void *ptr = alloca (64);
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c 
b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c

index 1db99133d50..32559952e34 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,8 @@
 #include 
 #include 
 #include 
-#include 
+#if __has_include()
+#endif
 #include "analyzer-decls.h"

 struct foo
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c

index 3024e546137..0f3f1fc760a 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,5 @@
-#include 
+#if __has_include()
+#endif
 #include 

 extern int foo (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c

index 10b97a05402..35035d27ff7 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,8 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */

 #include 
-#include 
+#if __has_include()
+#endif
 #include 

 extern void do_stuff (const void *);


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-03 Thread Andreas Tobler

On 03.05.20 18:27, Kamil Rytarowski wrote:

On 01.05.2020 21:49, Andreas Tobler wrote:

Hi all,

FreeBSD does not have the alloca.h header. Do not include it in the test
cases which do include alloca.h.

There are two versions of this patch available, the one attached which
uses ifdef or another one which defines alloca with __builtin_alloca.

I tested both approaches and they work on FreeBSD. I do not know which
one you prefer.

Opinions welcome.

Ok for trunk?
TIA,
Andreas


Please include in your patch "|| defined(__NetBSD__)".


is this ok for you?

This is one reason why I'd prefer #define alloca __builtin_alloca and 
leave the include away.


Andreas
From 70165e30fb5b4398c903b4522d6496c7da7c12fa Mon Sep 17 00:00:00 2001
From: Andreas Tobler 
Date: Fri, 1 May 2020 21:10:39 +0200
Subject: [PATCH] testsuite: analyzer: Fix header include for Free/NetBSD

FreeBSD and NetBSD do not have the alloca.h header.
Fix this with ifndef on alloca.h.
---
 gcc/testsuite/ChangeLog| 8 
 gcc/testsuite/gcc.dg/analyzer/alloca-leak.c| 5 -
 gcc/testsuite/gcc.dg/analyzer/data-model-1.c   | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-1.c   | 2 ++
 gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c | 2 ++
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 185f9ea725e..3f7b409bd42 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-03  Andreas Tobler  
+
+   * gcc.dg/analyzer/alloca-leak.c: Do not include
+ alloca.h for Free/NetBSD.
+   * gcc.dg/analyzer/data-model-1.c: Likewise
+   * gcc.dg/analyzer/malloc-1.c: Likewise.
+   * gcc.dg/analyzer/malloc-paths-8.c: Likewise.
+
 2020-05-01  H.J. Lu  
 
PR target/93492
diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c 
b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
index 6d9fe3431ce..631e81b8cf4 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,8 @@
+#if defined (__FreeBSD__) || defined(__NetBSD__)
+#include 
+#else
 #include 
-
+#endif
 void *test (void)
 {
   void *ptr = alloca (64);
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c 
b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index 1db99133d50..f06651802a5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,9 @@
 #include 
 #include 
 #include 
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include "analyzer-decls.h"
 
 struct foo
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 3024e546137..046e3353192 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,6 @@
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include 
 
 extern int foo (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
index 10b97a05402..d55d6350da8 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,9 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */
 
 #include 
+#if (!defined(__FreeBSD__) && !defined(__NetBSD__))
 #include 
+#endif
 #include 
 
 extern void do_stuff (const void *);
-- 
2.24.1



Re: [committed] Darwin: Fix bootstrap break from libsanitizer changes

2020-05-01 Thread Andreas Tobler

On 01.05.20 21:02, Iain Sandoe wrote:

Hi,

The recent libsanitizer change seems to have had a corrupt
chunk, that caused it to apply a change part way through the
SUBTARGET_INIT_BUILTINS macro, leading to a bootstrap fail
in stage1.

tested on x86_64-darwin16,
applied to master,


Sorry for the break and thank you for the quick fix.

Andreas


gcc/ChangeLog:

2020-05-01  Iain Sandoe  

* config/i386/darwin.h: Repair SUBTARGET_INIT_BUILTINS.
Override SUBTARGET_SHADOW_OFFSET macro.
---
  gcc/ChangeLog| 5 +
  gcc/config/i386/darwin.h | 7 +++
  2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index cff9a8c6b01..fec934aae69 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -347,12 +347,11 @@ along with GCC; see the file COPYING3.  If not see
  #define SUBTARGET_INIT_BUILTINS   
\
do {
\
  ix86_builtins[(int) IX86_BUILTIN_CFSTRING]
\
+  = darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_CFSTRING)); \
+darwin_rename_builtins (); \
+  } while(0)
  
  /* Define the shadow offset for asan.  */

  #undef SUBTARGET_SHADOW_OFFSET
  #define SUBTARGET_SHADOW_OFFSET   \
(TARGET_LP64 ? HOST_WIDE_INT_1 << 44 : HOST_WIDE_INT_1 << 29)
-
-  = darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_CFSTRING)); \
-darwin_rename_builtins (); \
-  } while(0)





[PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-01 Thread Andreas Tobler

Hi all,

FreeBSD does not have the alloca.h header. Do not include it in the test 
cases which do include alloca.h.


There are two versions of this patch available, the one attached which 
uses ifdef or another one which defines alloca with __builtin_alloca.


I tested both approaches and they work on FreeBSD. I do not know which 
one you prefer.


Opinions welcome.

Ok for trunk?
TIA,
Andreas
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 949b81a4392..b67758bbc91 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-01  Andreas Tobler  
+
+   * gcc.dg/analyzer/alloca-leak.c: Do not include
+   alloca.h for FreeBSD.
+   *  gcc.dg/analyzer/data-model-1.c: Likewise
+   * gcc.dg/analyzer/malloc-1.c: Likewise.
+   * gcc.dg/analyzer/malloc-paths-8.c: Likewise.
+
 2020-05-01  Andreas Tobler  
 
* gcc.dg/asan/pr87930.c: Enable on x86_64 FreeBSD.
diff --git a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c 
b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
index 6d9fe3431ce..ed4e4e3 100644
--- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
+++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
@@ -1,5 +1,8 @@
+#ifdef __FreeBSD__
+#include 
+#else
 #include 
-
+#endif
 void *test (void)
 {
   void *ptr = alloca (64);
diff --git a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c 
b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
index 1db99133d50..6fa35db03b5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/data-model-1.c
@@ -1,7 +1,9 @@
 #include 
 #include 
 #include 
+#ifndef __FreeBSD__
 #include 
+#endif
 #include "analyzer-decls.h"
 
 struct foo
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 3024e546137..94f631b2a1d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -1,4 +1,6 @@
+#ifndef __FreeBSD__
 #include 
+#endif
 #include 
 
 extern int foo (void);
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c 
b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
index 10b97a05402..5fa9ad3b58e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-8.c
@@ -1,7 +1,9 @@
 /* { dg-additional-options "-fanalyzer-transitivity" } */
 
 #include 
+#ifndef __FreeBSD__
 #include 
+#endif
 #include 
 
 extern void do_stuff (const void *);
-- 
2.24.1



Re: [PATCH] libsanitizer: Add missign file and regen Makefile.in

2020-05-01 Thread Andreas Tobler

On 23.01.20 21:09, Jeff Law wrote:

On Wed, 2020-01-22 at 22:23 +0100, Andreas Tobler wrote:

Hi all,

I'm digginig out old patches and I want to complete the libasan support
for FreeBSD x86_64. The below one was not that obvious when you have
been away for the past years.

In the last import the sanitizer_platform_limits_freebsd.cpp got
forgotten. Fix this.

Ok for trunk once it's open again?

Thanks,
Andreas

libsanitizer/sanitizer_common:

  * Makefile.am: Add sanitizer_platform_limits_freebsd.cpp.
  * makefile.in: Regenerate

I think all the patches in this space are fine for the trunk.  As
someone else mentioned, the sanitizer patches should probably go
through the upstream project as GCC is downstream.


I finally did commit the gcc part. The one bit for libsanitizer I left away.

Thanks,
Andreas



Re: [PATCH] libsanitizer: Add missign file and regen Makefile.in

2020-01-25 Thread Andreas Tobler

On 23.01.20 21:09, Jeff Law wrote:

On Wed, 2020-01-22 at 22:23 +0100, Andreas Tobler wrote:

Hi all,

I'm digginig out old patches and I want to complete the libasan support
for FreeBSD x86_64. The below one was not that obvious when you have
been away for the past years.

In the last import the sanitizer_platform_limits_freebsd.cpp got
forgotten. Fix this.

Ok for trunk once it's open again?

Thanks,
Andreas

libsanitizer/sanitizer_common:

  * Makefile.am: Add sanitizer_platform_limits_freebsd.cpp.
  * makefile.in: Regenerate

I think all the patches in this space are fine for the trunk.  As
someone else mentioned, the sanitizer patches should probably go
through the upstream project as GCC is downstream.


Yup. Thanks for the feedback. I'm working on this one. It'll take some 
time since I learned it is not that easy to build llvm and run a simple 
test. But that is another story.


I'll commit w/o the sanitizer bit once trunk is open for new features.

Andreas


[PATCH] testsuite: Enable asan tests on FreeBSD x86_64

2020-01-22 Thread Andreas Tobler

Hi all,

and here the tests which should succeed now.

Ok for trunk (as usual if open...)

TIA,
Andreas


testsuite:

* gcc.dg/asan/pr87930.c: Enable on x86_64 FreeBSD.
* c-c++-common/asan/asan-interface-1.c: Likewise.
* c-c++-common/asan/clone-test-1.c: Likewise.
* c-c++-common/asan/no-asan-stack.c: Likewise.
* c-c++-common/asan/pr59063-1.c: Likewise.
* c-c++-common/asan/pr59063-2.c: Likewise.
* g++.dg/asan/asan_test.C: Likewise.
* g++.dg/asan/asan_test_utils.h: Likewise.
* g++.dg/asan/interception-failure-test-1.C: Likewise.
* g++.dg/asan/interception-malloc-test-1.C: Likewise


diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 70d7e8869e1..7e3534f84de 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2020-01-22  Andreas Tobler  
+
+   * gcc.dg/asan/pr87930.c: Enable on x86_64 FreeBSD.
+   * c-c++-common/asan/asan-interface-1.c: Likewise.
+   * c-c++-common/asan/clone-test-1.c: Likewise.
+   * c-c++-common/asan/no-asan-stack.c: Likewise.
+   * c-c++-common/asan/pr59063-1.c: Likewise.
+   * c-c++-common/asan/pr59063-2.c: Likewise.
+   * g++.dg/asan/asan_test.C: Likewise.
+   * g++.dg/asan/asan_test_utils.h: Likewise.
+   * g++.dg/asan/interception-failure-test-1.C: Likewise.
+   * g++.dg/asan/interception-malloc-test-1.C: Likewise.
+
 2020-01-22  Marek Polacek  
 
PR c++/93324 - ICE with -Wall on constexpr if.
diff --git a/gcc/testsuite/c-c++-common/asan/asan-interface-1.c 
b/gcc/testsuite/c-c++-common/asan/asan-interface-1.c
index 33ed1b0e845..2bf1fae857f 100644
--- a/gcc/testsuite/c-c++-common/asan/asan-interface-1.c
+++ b/gcc/testsuite/c-c++-common/asan/asan-interface-1.c
@@ -1,6 +1,6 @@
 /* Check that interface headers work. */
 
-/* { dg-do run { target { *-*-linux* } } } */
+/* { dg-do run { target { *-*-linux* *-*-freebsd* } } } */
 
 #include 
 
diff --git a/gcc/testsuite/c-c++-common/asan/clone-test-1.c 
b/gcc/testsuite/c-c++-common/asan/clone-test-1.c
index c58c376f5df..b95ec32f9ef 100644
--- a/gcc/testsuite/c-c++-common/asan/clone-test-1.c
+++ b/gcc/testsuite/c-c++-common/asan/clone-test-1.c
@@ -1,7 +1,7 @@
 /* Regression test for:
http://code.google.com/p/address-sanitizer/issues/detail?id=37 */
 
-/* { dg-do run { target { *-*-linux* } } } */
+/* { dg-do run { target { *-*-linux* x86_64-*-freebsd* } } } */
 /* { dg-require-effective-target clone } */
 /* { dg-require-effective-target hw } */
 /* { dg-options "-D_GNU_SOURCE" } */
diff --git a/gcc/testsuite/c-c++-common/asan/no-asan-stack.c 
b/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
index 59ae55b0b00..9d1d37cb6c4 100644
--- a/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
+++ b/gcc/testsuite/c-c++-common/asan/no-asan-stack.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && lp64 } } } 
*/
+/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* 
x86_64-*-freebsd* } && lp64 } } } */
 /* { dg-options "--param asan-stack=0" } */
 #include 
 
diff --git a/gcc/testsuite/c-c++-common/asan/pr59063-1.c 
b/gcc/testsuite/c-c++-common/asan/pr59063-1.c
index a22db6a0d82..1cc7f6f9428 100644
--- a/gcc/testsuite/c-c++-common/asan/pr59063-1.c
+++ b/gcc/testsuite/c-c++-common/asan/pr59063-1.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { *-*-linux* } } } */
+/* { dg-do run { target { *-*-linux* *-*-freebsd* } } } */
 
 #include 
 static int weak_gettime (clockid_t clk_id, struct timespec *tp)
diff --git a/gcc/testsuite/c-c++-common/asan/pr59063-2.c 
b/gcc/testsuite/c-c++-common/asan/pr59063-2.c
index 759b7f24d09..63a547f033f 100644
--- a/gcc/testsuite/c-c++-common/asan/pr59063-2.c
+++ b/gcc/testsuite/c-c++-common/asan/pr59063-2.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { *-*-linux* } } } */
+/* { dg-do run { target { *-*-linux* *-*-freebsd* } } } */
 /* { dg-options "-static-libasan" } */
 
 #include 
diff --git a/gcc/testsuite/g++.dg/asan/asan_test.C 
b/gcc/testsuite/g++.dg/asan/asan_test.C
index f3f7626ef3b..6db37411caf 100644
--- a/gcc/testsuite/g++.dg/asan/asan_test.C
+++ b/gcc/testsuite/g++.dg/asan/asan_test.C
@@ -1,12 +1,13 @@
-// { dg-do run { target { { *-*-linux* } && { { ! { i?86-*-linux* 
x86_64-*-linux* } } || sse2_runtime } } } }
+// { dg-do run { target { { *-*-linux* i?86-*-freebsd* x86_64-*-freebsd* } && 
{ { ! { i?86-*-linux* x86_64-*-linux* i?86-*-freebsd* x86_64-*-freebsd* } } || 
sse2_runtime } } } }
 // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } }
 // { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
 // { dg-additional-sources "asan_globals_test-wrapper.cc" }
-// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -g 
-DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 
-DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl"

[PATCH]: gcc: Enable bits for sanitizer support on FreeBSD x86_64

2020-01-22 Thread Andreas Tobler

Hi all,

this patch adds the necessary bits to enable asan support on FreeBSD x86_64.
Results will be produced over night.

Ok for trunk once it is open again?
TIA,
Andreas

gcc/

  * config/i386/i386.h: Define a new macro: SUBTARGET_SHADOW_OFFSET.
  * config/i386/i386.c (ix86_asan_shadow_offset): Use this macro.
  * config/i386/darwin.h: Override the SUBTARGET_SHADOW_OFFSET macro.
  * config/i386/freebsd.h: Likewise.
  * config/freebsd.h (LIBASAN_EARLY_SPEC): Define.
  LIBTSAN_EARLY_SPEC): Likewise. (LIBLSAN_EARLY_SPEC): Likewise.

libsanitizer:

  * configure.tgt: Add x86_64- and i?86-*-freebsd* targets.
  * asan/asan_interceptors.h: Define ASAN_INTERCEPT_SWAPCONTEXT for
  FreeBSD.

From 93978ce66c4eeff0bde2f44f8c0809fc66165e5b Mon Sep 17 00:00:00 2001
From: Andreas Tobler 
Date: Tue, 21 Jan 2020 22:17:09 +0100
diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h
index d9d6be7a8c8..4b5140bae02 100644
--- a/gcc/config/freebsd.h
+++ b/gcc/config/freebsd.h
@@ -62,6 +62,27 @@ along with GCC; see the file COPYING3.  If not see
 #define USE_LD_AS_NEEDED 1
 #endif
 
+/* Link -lasan early on the command line.  For -static-libasan, don't link
+   it for -shared link, the executable should be compiled with -static-libasan
+   in that case, and for executable link with --{,no-}whole-archive around
+   it to force everything into the executable.  And similarly for -ltsan
+   and -llsan.  */
+#if defined(HAVE_LD_STATIC_DYNAMIC)
+#undef LIBASAN_EARLY_SPEC
+#define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
+  "%{static-libasan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan -lpthread}"
+#undef LIBTSAN_EARLY_SPEC
+#define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan -lpthread}"
+#undef LIBLSAN_EARLY_SPEC
+#define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan -lpthread}"
+#endif
+
 /[  Target stuff  ]***/
 
 /* All FreeBSD Architectures support the ELF object file format.  */
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 1b94cb88c98..5b7b1e889a9 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -337,6 +337,12 @@ along with GCC; see the file COPYING3.  If not see
 #define SUBTARGET_INIT_BUILTINS
\
   do { \
 ix86_builtins[(int) IX86_BUILTIN_CFSTRING] \
+
+/* Define the shadow offset for asan.  */
+#undef SUBTARGET_SHADOW_OFFSET
+#define SUBTARGET_SHADOW_OFFSET\
+  (TARGET_LP64 ? HOST_WIDE_INT_1 << 44 : HOST_WIDE_INT_1 << 29)
+
   = darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_CFSTRING)); \
 darwin_rename_builtins (); \
   } while(0)
diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h
index 8fb0f0aaf5c..9d66602142e 100644
--- a/gcc/config/i386/freebsd.h
+++ b/gcc/config/i386/freebsd.h
@@ -129,3 +129,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
+/* Define the shadow offsets for asan.  */
+#undef SUBTARGET_SHADOW_OFFSET
+#define SUBTARGET_SHADOW_OFFSET\
+  (TARGET_LP64 ? HOST_WIDE_INT_1 << 46 : HOST_WIDE_INT_1 << 30)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ffe60baa72a..71baca4e0c9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -1396,9 +1396,7 @@ ix86_legitimate_combined_insn (rtx_insn *insn)
 static unsigned HOST_WIDE_INT
 ix86_asan_shadow_offset (void)
 {
-  return TARGET_LP64 ? (TARGET_MACHO ? (HOST_WIDE_INT_1 << 44)
-: HOST_WIDE_INT_C (0x7fff8000))
-: (HOST_WIDE_INT_1 << 29);
+  return SUBTARGET_SHADOW_OFFSET;
 }
 
 /* Argument support functions.  */
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 943e9a5c783..18b27bb535b 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1321,6 +1321,13 @@ extern const char *host_detect_local_cpu (int argc, 
const char **argv);
 #define SUBTARGET_FRAME_POINTER_REQUIRED 0
 #endif
 
+/* Define the shadow offset for asan. Other OS's can override in the
+   respective tm.h files.  */
+#ifndef SUBTARGET_SHADOW_OFFSET
+#define SUBTARGET_SHADOW_OFFSET\
+  (TARGET_LP64 ? HOST_WIDE_INT_C (0x7fff8000) : HOST_WIDE_INT_1 << 29)
+#endif
+
 /* Make sure we can access arbitrary call frames.  */
 #define SETUP_FRAME_ADDRESSES()  ix86_setup_frame_addresses ()
 
diff --git a/l

[PATCH] libsanitizer: Add missign file and regen Makefile.in

2020-01-22 Thread Andreas Tobler

Hi all,

I'm digginig out old patches and I want to complete the libasan support 
for FreeBSD x86_64. The below one was not that obvious when you have 
been away for the past years.


In the last import the sanitizer_platform_limits_freebsd.cpp got
forgotten. Fix this.

Ok for trunk once it's open again?

Thanks,
Andreas

libsanitizer/sanitizer_common:

* Makefile.am: Add sanitizer_platform_limits_freebsd.cpp.
* makefile.in: Regenerate

diff --git a/libsanitizer/sanitizer_common/Makefile.am 
b/libsanitizer/sanitizer_

common/Makefile.am
index df9c294151d..9653f27c09f 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -44,6 +44,7 @@ sanitizer_common_files = \
sanitizer_netbsd.cpp \
sanitizer_openbsd.cpp \
sanitizer_persistent_allocator.cpp \
+   sanitizer_platform_limits_freebsd.cpp \
sanitizer_platform_limits_linux.cpp \
sanitizer_platform_limits_openbsd.cpp \
sanitizer_platform_limits_posix.cpp \


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-10-26 Thread Andreas Tobler

On 04.10.19 19:04, Jeff Law wrote:

On 9/30/19 12:47 PM, Andreas Tobler wrote:

On 30.09.19 20:37, Kamil Rytarowski wrote:

On 30.09.2019 19:47, Jakub Jelinek wrote:

On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:

--- fprintf-2.c    (revision 276292)
+++ fprintf-2.c    (working copy)
@@ -1,7 +1,8 @@
   /* Verify that calls to fprintf don't get eliminated even if their
  result on success can be computed at compile time (they can fail).
  The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]*
possibly used unsafely; consider using \[^\n\]*\n" } */


I'm worried about that (^|\n) at the start + \n at the end, doesn't
it prune
too much then?
Looking at other tests, they dg-prune-output just a few words from a
message, or .*few words.*
So, can you try just
     { dg-prune-output "warning: warning: \[^\n\r\]* possibly used
unsafely; consider using" } */
or if that doesn't work, with .* at start end end?

 Jakub



Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



Ok, I think the attached version should also match these cases. Although
untested on NetBSD.
Kamil, if you have cycles, would you mind giving it a run? Thanks!
Andreas


OK assuming Kamil's testing shows that it works.


Kamil, do you have a feedback? If not I'm going to commit by tomorrow.

Andreas


Re: [patch, libgomp] testsuite remove alloca header

2019-10-02 Thread Andreas Tobler

On 02.10.19 12:19, Thomas Schwinge wrote:

Hi!

On 2019-09-30T15:22:52+0200, Jakub Jelinek  wrote:

On Mon, Sep 30, 2019 at 03:16:00PM +0200, Andreas Tobler wrote:

here on FreeBSD we lack the alloca.h header so two test cases fail to
compile.

Do the same as I did six years ago for another test case: 'Remove alloca.h
and replace it with __builtin_alloca"

Is this ok for trunk?

TIA,
Andreas

2019-09-30  Andreas Tobler  

* testsuite/libgomp.oacc-c-c++-common/loop-default.h: Remove alloca.h
inlcude. Replace alloca () with __builtin_alloca ().


s/inlcude/include/

Because the tests are already using GCC specific builtins
(__builtin_goacc_parlevel_id), I think that is ok, they aren't portable
anyway, CCing Thomas to confirm.


* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: Likewise.


Sure, that's fine, and (as far as I'm concerned) pre-approved, should any
additional such changes be necessary later on.

To record the review effort -- not very much here, admittedly ;-) --
please include "Reviewed-by: Thomas Schwinge "
in the commit log, see <https://gcc.gnu.org/wiki/Reviewed-by>.


I did the commit and hopefully I matched your expectations.
I didn't find an example, so I added the tag similar as we do in FreeBSD.

https://gcc.gnu.org/viewcvs/gcc?view=revision=276479

Danke,
Andreas


Re: [PATCH] libstdc++ testsuite, silence a FreeBSD libm warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 19:09, Andreas Tobler wrote:

Hi all,

the attached patch tries to silence a warning from the msun of FreeBSD.
When compiling the special_functions testcases, I get excess errors
because of this warning:

warning: tgammal has lower than advertised precision

With the patch, all special_functions test cases pass now.

What do you think?


I learned from the c-side, a patch to prune.exp might be too expensive 
if I only have a couple of test cases involved.


Here the version which only touches the affected test cases.

Which one do you prefer?

TIA,
Andreas

2019-09-30  Andreas Tobler  

* testsuite/ext/special_functions/airy_ai/check_nan.cc: Ignore the
FreeBSD warning about lower advertised precision of tgammal.
* testsuite/ext/special_functions/airy_bi/check_nan.cc: Likewise.
* testsuite/special_functions/07_cyl_bessel_i/check_nan.cc: Likewise.
* testsuite/special_functions/08_cyl_bessel_j/check_nan.cc: Likewise.
* testsuite/special_functions/09_cyl_bessel_k/check_nan.cc: Likewise.
* testsuite/special_functions/10_cyl_neumann/check_nan.cc: Likewise.
* testsuite/special_functions/19_sph_bessel/check_nan.cc: Likewise.
* testsuite/special_functions/21_sph_neumann/check_nan.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/
08_cyl_bessel_i/check_nan.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/
09_cyl_bessel_j/check_nan.cc: Likewise.
* testuite/tr1/5_numerical_facilities/special_functions/
10_cyl_bessel_k/check_nan.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/
11_cyl_neumann/check_nan.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/
21_sph_bessel/check_nan.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/special_functions/
23_sph_neumann/check_nan.cc: Likewise.
Index: ext/special_functions/airy_ai/check_nan.cc
===
--- ext/special_functions/airy_ai/check_nan.cc  (revision 276292)
+++ ext/special_functions/airy_ai/check_nan.cc  (working copy)
@@ -3,6 +3,7 @@
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
 // { dg-add-options ieee }
 // { dg-skip-if "no extensions in strict dialects" { *-*-* } { "-std=c++*" } }
+// { dg-prune-output ".*warning: tgammal has lower than advertised precision" }
 
 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
 //
Index: ext/special_functions/airy_bi/check_nan.cc
===
--- ext/special_functions/airy_bi/check_nan.cc  (revision 276292)
+++ ext/special_functions/airy_bi/check_nan.cc  (working copy)
@@ -3,6 +3,7 @@
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
 // { dg-add-options ieee }
 // { dg-skip-if "no extensions in strict dialects" { *-*-* } { "-std=c++*" } }
+// { dg-prune-output ".*warning: tgammal has lower than advertised precision" }
 
 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
 //
Index: special_functions/07_cyl_bessel_i/check_nan.cc
===
--- special_functions/07_cyl_bessel_i/check_nan.cc  (revision 276292)
+++ special_functions/07_cyl_bessel_i/check_nan.cc  (working copy)
@@ -2,6 +2,7 @@
 // { dg-require-c-std "" }
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
 // { dg-add-options ieee }
+// { dg-prune-output ".*warning: tgammal has lower than advertised precision" }
 
 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
 //
Index: special_functions/08_cyl_bessel_j/check_nan.cc
===
--- special_functions/08_cyl_bessel_j/check_nan.cc  (revision 276292)
+++ special_functions/08_cyl_bessel_j/check_nan.cc  (working copy)
@@ -2,6 +2,7 @@
 // { dg-require-c-std "" }
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
 // { dg-add-options ieee }
+// { dg-prune-output ".*warning: tgammal has lower than advertised precision" }
 
 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
 //
Index: special_functions/09_cyl_bessel_k/check_nan.cc
===
--- special_functions/09_cyl_bessel_k/check_nan.cc  (revision 276292)
+++ special_functions/09_cyl_bessel_k/check_nan.cc  (working copy)
@@ -2,6 +2,7 @@
 // { dg-require-c-std "" }
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
 // { dg-add-options ieee }
+// { dg-prune-output ".*warning: tgammal has lower than advertised precision" }
 
 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
 //
Index: special_functions/10_cyl_neumann/check_nan.cc
=

Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 20:37, Kamil Rytarowski wrote:

On 30.09.2019 19:47, Jakub Jelinek wrote:

On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:

--- fprintf-2.c (revision 276292)
+++ fprintf-2.c (working copy)
@@ -1,7 +1,8 @@
  /* Verify that calls to fprintf don't get eliminated even if their
 result on success can be computed at compile time (they can fail).
 The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */


I'm worried about that (^|\n) at the start + \n at the end, doesn't it prune
too much then?
Looking at other tests, they dg-prune-output just a few words from a
message, or .*few words.*
So, can you try just
{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider 
using" } */
or if that doesn't work, with .* at start end end?

Jakub



Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



Ok, I think the attached version should also match these cases. Although 
untested on NetBSD.

Kamil, if you have cycles, would you mind giving it a run? Thanks!
Andreas

Index: fprintf-2.c
===
--- fprintf-2.c (revision 276292)
+++ fprintf-2.c (working copy)
@@ -1,7 +1,8 @@
 /* Verify that calls to fprintf don't get eliminated even if their
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } */
 
 #include 
 #include 
Index: printf-2.c
===
--- printf-2.c  (revision 276292)
+++ printf-2.c  (working copy)
@@ -2,7 +2,8 @@
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } */
 
 #include 
 #include 
Index: user-printf.c
===
--- user-printf.c   (revision 276292)
+++ user-printf.c   (working copy)
@@ -2,7 +2,8 @@
don't get eliminated even if their result on success can be computed at
compile time (they can fail).
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely" } */
 
 #include 
 #include 


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 19:47, Jakub Jelinek wrote:

On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:

--- fprintf-2.c (revision 276292)
+++ fprintf-2.c (working copy)
@@ -1,7 +1,8 @@
  /* Verify that calls to fprintf don't get eliminated even if their
 result on success can be computed at compile time (they can fail).
 The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */


I'm worried about that (^|\n) at the start + \n at the end, doesn't it prune
too much then?
Looking at other tests, they dg-prune-output just a few words from a
message, or .*few words.*
So, can you try just
{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; consider 
using" } */
or if that doesn't work, with .* at start end end?


Ok, yes it works too with your suggestion.

Attached.

One question, doing it per test case is cheaper than in prune.exp? 
(Where we do it for 'all' test cases, needed or not.)


Thanks,
Andreas



Index: fprintf-2.c
===
--- fprintf-2.c (revision 276292)
+++ fprintf-2.c (working copy)
@@ -1,7 +1,8 @@
 /* Verify that calls to fprintf don't get eliminated even if their
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; 
consider using" } */
 
 #include 
 #include 
Index: printf-2.c
===
--- printf-2.c  (revision 276292)
+++ printf-2.c  (working copy)
@@ -2,7 +2,8 @@
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; 
consider using" } */
 
 #include 
 #include 
Index: user-printf.c
===
--- user-printf.c   (revision 276292)
+++ user-printf.c   (working copy)
@@ -2,7 +2,8 @@
don't get eliminated even if their result on success can be computed at
compile time (they can fail).
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; 
consider using" } */
 
 #include 
 #include 


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

On 30.09.19 19:20, Jakub Jelinek wrote:

On Mon, Sep 30, 2019 at 07:15:59PM +0200, Andreas Tobler wrote:

Hi all,

the below patch tries to silence a warning from the FreeBSD libc. This
warning currently makes all the test cases fail where we make use of the
tmpnam() function.

---
/usr/local/bin/ld: /tmp//ccBQaYlC.o: in function `main':
printf-2.c:(.text+0x8d): warning: warning: tmpnam() possibly used unsafely;
consider using mkstemp()
---

With this patch, all the *printf* test cases in the gcc part are now
passing.

What dou you think?


Wouldn't it be better to just dg-prune-output it in the 3 affected tests,
perhaps only for affected targets?


Thanks for the feedback!

This way?

TIA,
Andreas


2019-09-30  Andreas Tobler  

* gcc.c-torture/execute/fprintf-2.c: Silence a FreeBSD libc warning.
* gcc.c-torture/execute/printf-2.c: Likewise.
* gcc.c-torture/execute/user-printf.c: Likewise.


Index: fprintf-2.c
===
--- fprintf-2.c (revision 276292)
+++ fprintf-2.c (working copy)
@@ -1,7 +1,8 @@
 /* Verify that calls to fprintf don't get eliminated even if their
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */ 
 
 #include 
 #include 
Index: printf-2.c
===
--- printf-2.c  (revision 276292)
+++ printf-2.c  (working copy)
@@ -2,7 +2,8 @@
result on success can be computed at compile time (they can fail).
The calls can still be transformed into those of other functions.
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */
 
 #include 
 #include 
Index: user-printf.c
===
--- user-printf.c   (revision 276292)
+++ user-printf.c   (working copy)
@@ -2,7 +2,8 @@
don't get eliminated even if their result on success can be computed at
compile time (they can fail).
{ dg-require-effective-target unwrapped }
-   { dg-skip-if "requires io" { freestanding } } */
+   { dg-skip-if "requires io" { freestanding } }
+   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly used 
unsafely; consider using \[^\n\]*\n" } */
 
 #include 
 #include 


[PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Andreas Tobler

Hi all,

the below patch tries to silence a warning from the FreeBSD libc. This 
warning currently makes all the test cases fail where we make use of the 
tmpnam() function.


---
/usr/local/bin/ld: /tmp//ccBQaYlC.o: in function `main':
printf-2.c:(.text+0x8d): warning: warning: tmpnam() possibly used 
unsafely; consider using mkstemp()

---

With this patch, all the *printf* test cases in the gcc part are now 
passing.


What dou you think?

TIA,
Andreas

2019-09-30  Andreas Tobler  

* lib/prune.exp (prune_gcc_output): Silence a FreeBSD libc warning.

Index: lib/prune.exp
===
--- lib/prune.exp   (revision 276342)
+++ lib/prune.exp   (working copy)
@@ -73,6 +73,9 @@
 # Ignore harmless warnings from Xcode 4.0.
 regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact 
unwind for\[^\n\]*" $text "" text


+# Ignore FreeBSD libc warning
+regsub -all "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly 
used unsafely; consider using \[^\n\]*\n" $text "" text

+
 # Call into multiline.exp to handle any multiline output directives.
 set text [handle-multiline-outputs $text]



[PATCH] libstdc++ testsuite, silence a FreeBSD libm warning

2019-09-30 Thread Andreas Tobler

Hi all,

the attached patch tries to silence a warning from the msun of FreeBSD.
When compiling the special_functions testcases, I get excess errors 
because of this warning:


warning: tgammal has lower than advertised precision

With the patch, all special_functions test cases pass now.

What do you think?

TIA,
Andreas


2019-09-30  Andreas Tobler  

* testsuite/lib/prune.exp (libstdc++-dg-prune): Ignore the FreeBSD
warning about lower advertised precision of tgammal.


Index: testsuite/lib/prune.exp
===
--- testsuite/lib/prune.exp (revision 276342)
+++ testsuite/lib/prune.exp (working copy)
@@ -66,6 +66,10 @@
 # Ignore harmless warnings from Xcode 4.0.
 regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact 
unwind for\[^\n\]*" $text "" text


+# Ignore FreeBSD msun warning
+regsub -all "(^|\n)\[^\n]*ld: \[^\n\]* in function \[^\n\]*" $text 
"" text
+regsub -all "(^|\n)\[^\n]*warning: tgammal has lower than 
advertised precision" $text "" text

+
 foreach p $additional_prunes {
if { [string length $p] > 0 } {
# Following regexp matches a complete line containing $p.


[PATCH] Include netinet/in.h in include/experimental/internet

2019-09-30 Thread Andreas Tobler

Hi all,

I'm going to commit the attached patch to trunk.
It is preapproved by Jonathan. (via #irc)

On FreeBSD the netinet/in.h header is not included by arpa/inet.h, so do 
the include if we have the _GLIBCXX_HAVE_NETINET_IN_H defined.


This makes all the experimental/net/internet test cases pass here.

Any comments?

TIA,
Andreas

Commit one-liner:

Include netinet/in.h in include/experimental/internet

2019-09-30  Andreas Tobler  

* include/experimental/internet: Include netinet/in.h if we have
_GLIBCXX_HAVE_NETINET_IN_H defined.

Index: include/experimental/internet
===
--- include/experimental/internet   (revision 276342)
+++ include/experimental/internet   (working copy)
@@ -51,6 +51,9 @@
 #ifdef _GLIBCXX_HAVE_ARPA_INET_H
 # include   // inet_ntop
 #endif
+#ifdef _GLIBCXX_HAVE_NETINET_IN_H
+# include  // IPPROTO_IP
+#endif
 #ifdef _GLIBCXX_HAVE_NETINET_TCP_H
 # include // TCP_NODELAY
 #endif


[patch, libgomp] testsuite remove alloca header

2019-09-30 Thread Andreas Tobler

Hi,

here on FreeBSD we lack the alloca.h header so two test cases fail to 
compile.


Do the same as I did six years ago for another test case: 'Remove 
alloca.h and replace it with __builtin_alloca"


Is this ok for trunk?

TIA,
Andreas

2019-09-30  Andreas Tobler  

* testsuite/libgomp.oacc-c-c++-common/loop-default.h: Remove alloca.h
inlcude. Replace alloca () with __builtin_alloca ().
* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: Likewise.
Index: testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
===
--- testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c  (revision 
276292)
+++ testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c  (working copy)
@@ -1,7 +1,6 @@
 /* { dg-additional-options "-fopenacc-dim=16:16" } */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -28,9 +27,9 @@
 {
   int exit = 0;
   int ix;
-  int *gangs = (int *)alloca (gp * sizeof (int));
-  int *workers = (int *)alloca (wp * sizeof (int));
-  int *vectors = (int *)alloca (vp * sizeof (int));
+  int *gangs = (int *)__builtin_alloca (gp * sizeof (int));
+  int *workers = (int *)__builtin_alloca (wp * sizeof (int));
+  int *vectors = (int *)__builtin_alloca (vp * sizeof (int));
   int offloaded = 0;
   
   memset (gangs, 0, gp * sizeof (int));
Index: testsuite/libgomp.oacc-c-c++-common/loop-default.h
===
--- testsuite/libgomp.oacc-c-c++-common/loop-default.h  (revision 276292)
+++ testsuite/libgomp.oacc-c-c++-common/loop-default.h  (working copy)
@@ -1,5 +1,4 @@
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -28,9 +27,9 @@
 {
   int exit = 0;
   int ix;
-  int *gangs = (int *)alloca (gp * sizeof (int));
-  int *workers = (int *)alloca (wp * sizeof (int));
-  int *vectors = (int *)alloca (vp * sizeof (int));
+  int *gangs = (int *)__builtin_alloca (gp * sizeof (int));
+  int *workers = (int *)__builtin_alloca (wp * sizeof (int));
+  int *vectors = (int *)__builtin_alloca (vp * sizeof (int));
   int offloaded = 0;
 
   memset (gangs, 0, gp * sizeof (int));


Re: [PATCH] FreeBSD PowerPC use secure-plt

2019-09-30 Thread Andreas Tobler

On 26.09.19 08:13, Andreas Tobler wrote:

Hi Segher,

On 26.09.19 00:49, Segher Boessenkool wrote:


On Wed, Sep 25, 2019 at 10:46:57PM +0200, Andreas Tobler wrote:

--- gcc/config/rs6000/t-freebsd64   (revision 276090)
+++ gcc/config/rs6000/t-freebsd64   (working copy)
@@ -27,3 +27,6 @@
   MULTILIB_EXCEPTIONS =
   MULTILIB_OSDIRNAMES  = ../lib32
   
+SECURE_PLT = $(if $(findstring TARGET_FREEBSD32_SECURE_PLT=1, $(tm_defines)),msecure-plt)

+
+MULTILIB_EXTRA_OPTS += $(SECURE_PLT)


$(findstring) isn't super great, it looks for substrings, so it would
also match "TARGET_FREEBSD32_SECURE_PLT=123"; you can use $(filter) instead?


Thank you for the feedback. Indeed, filter looks better. Testing again :)

And here for completeness the CL.

2019-09-25  Andreas Tobler  

* config.gcc: Use the secure-plt on FreeBSD 13 and upwards for
32-bit PowerPC.
Define TARGET_FREEBSD32_SECURE_PLT for 64-bit PowerPC.
* config/rs6000/t-freebsd64: Make use of the above define and build
the 32-bit libraries with secure-plt.


Looks fine to me either way.


Committed to trunk.

Andreas


Re: [PATCH] FreeBSD PowerPC use secure-plt

2019-09-26 Thread Andreas Tobler

Hi Segher,

On 26.09.19 00:49, Segher Boessenkool wrote:


On Wed, Sep 25, 2019 at 10:46:57PM +0200, Andreas Tobler wrote:

--- gcc/config/rs6000/t-freebsd64   (revision 276090)
+++ gcc/config/rs6000/t-freebsd64   (working copy)
@@ -27,3 +27,6 @@
  MULTILIB_EXCEPTIONS =
  MULTILIB_OSDIRNAMES   = ../lib32
  
+SECURE_PLT = $(if $(findstring TARGET_FREEBSD32_SECURE_PLT=1, $(tm_defines)),msecure-plt)

+
+MULTILIB_EXTRA_OPTS += $(SECURE_PLT)


$(findstring) isn't super great, it looks for substrings, so it would
also match "TARGET_FREEBSD32_SECURE_PLT=123"; you can use $(filter) instead?


Thank you for the feedback. Indeed, filter looks better. Testing again :)

And here for completeness the CL.

2019-09-25  Andreas Tobler  

* config.gcc: Use the secure-plt on FreeBSD 13 and upwards for
32-bit PowerPC.
Define TARGET_FREEBSD32_SECURE_PLT for 64-bit PowerPC.
* config/rs6000/t-freebsd64: Make use of the above define and build
the 32-bit libraries with secure-plt.


Looks fine to me either way.


Thank you.

Andreas


[PATCH] FreeBSD PowerPC use secure-plt

2019-09-25 Thread Andreas Tobler

Hi all,

the attached patch makes use of the secure-plt for 32-bit PowerPC on 
FreeBSD 13 and upwards. The OS support will arrive in FreeBSD 13.0


I'd like to commit this patch to head and later to all open branches.

Comments appreciated!

If I do not get any, I'll commit in a few days.

TIA,
Andreas

--- UTC
Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 276112)
+++ gcc/config.gcc  (working copy)
@@ -2687,8 +2687,14 @@
tm_file="${tm_file} rs6000/default64.h rs6000/freebsd64.h"
tmake_file="${tmake_file} rs6000/t-freebsd64"
extra_options="${extra_options} rs6000/linux64.opt"
+   if test $fbsd_major -ge 13; then
+   tm_defines="${tm_defines} TARGET_FREEBSD32_SECURE_PLT=1"
+   fi
;;
 *)
+   if test $fbsd_major -ge 13; then
+   tm_file="rs6000/secureplt.h ${tm_file}"
+   fi
tm_file="${tm_file} rs6000/freebsd.h"
;;
esac
Index: gcc/config/rs6000/t-freebsd64
===
--- gcc/config/rs6000/t-freebsd64   (revision 276090)
+++ gcc/config/rs6000/t-freebsd64   (working copy)
@@ -27,3 +27,6 @@
 MULTILIB_EXCEPTIONS =
 MULTILIB_OSDIRNAMES= ../lib32
 
+SECURE_PLT = $(if $(findstring TARGET_FREEBSD32_SECURE_PLT=1, 
$(tm_defines)),msecure-plt)
+
+MULTILIB_EXTRA_OPTS += $(SECURE_PLT)


Re: [patch] Multilib support for amd64 FreeBSD

2019-05-11 Thread Andreas Tobler

On 25.04.19 22:07, Andreas Tobler wrote:

On 18.03.19 22:28, Andreas Tobler wrote:

On 18.03.19 22:22, Jeff Law wrote:

On 3/17/19 2:40 PM, Andreas Tobler wrote:

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing
is a bit tricky since the FreeBSD dynamic linker handles both, the
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the
32-bit binaries built. So far it looks good. Need to find a way to
extend the testsuite to handle this situation.

Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is
in stage4, right?
The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

   * config/i386/freebsd64.h: Add bits for 32-bit multilib support.
   * config/i386/t-freebsd64: New file.
   * config.gcc: Add the t-freebsd64 for multilib support.



stage4 is supposed to be regression fixes only, so it's difficult to
make a case for this patch to get into gcc-9.

I'd say defer to gcc-10.


Ok, fine with me.
Once gcc-10 opens, I will commit this patch also to all open and active
branches.


Commit to branch gcc8 done.

Andreas


Re: [patch] Multilib support for amd64 FreeBSD

2019-05-11 Thread Andreas Tobler

On 25.04.19 22:07, Andreas Tobler wrote:

On 18.03.19 22:28, Andreas Tobler wrote:

On 18.03.19 22:22, Jeff Law wrote:

On 3/17/19 2:40 PM, Andreas Tobler wrote:

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing
is a bit tricky since the FreeBSD dynamic linker handles both, the
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the
32-bit binaries built. So far it looks good. Need to find a way to
extend the testsuite to handle this situation.

Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is
in stage4, right?
The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

   * config/i386/freebsd64.h: Add bits for 32-bit multilib support.
   * config/i386/t-freebsd64: New file.
   * config.gcc: Add the t-freebsd64 for multilib support.



stage4 is supposed to be regression fixes only, so it's difficult to
make a case for this patch to get into gcc-9.

I'd say defer to gcc-10.


Ok, fine with me.
Once gcc-10 opens, I will commit this patch also to all open and active
branches.


Pushed to trunk, branches will follow.


Commit to branch gcc9 done.

Andreas



Re: [patch] Multilib support for amd64 FreeBSD

2019-04-25 Thread Andreas Tobler

On 18.03.19 22:28, Andreas Tobler wrote:

On 18.03.19 22:22, Jeff Law wrote:

On 3/17/19 2:40 PM, Andreas Tobler wrote:

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing
is a bit tricky since the FreeBSD dynamic linker handles both, the
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the
32-bit binaries built. So far it looks good. Need to find a way to
extend the testsuite to handle this situation.

Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is
in stage4, right?
The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

  * config/i386/freebsd64.h: Add bits for 32-bit multilib support.
  * config/i386/t-freebsd64: New file.
  * config.gcc: Add the t-freebsd64 for multilib support.



stage4 is supposed to be regression fixes only, so it's difficult to
make a case for this patch to get into gcc-9.

I'd say defer to gcc-10.


Ok, fine with me.
Once gcc-10 opens, I will commit this patch also to all open and active
branches.


Pushed to trunk, branches will follow.

Andreas



Re: [patch] Multilib support for amd64 FreeBSD

2019-03-18 Thread Andreas Tobler

On 18.03.19 22:22, Jeff Law wrote:

On 3/17/19 2:40 PM, Andreas Tobler wrote:

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing
is a bit tricky since the FreeBSD dynamic linker handles both, the
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the
32-bit binaries built. So far it looks good. Need to find a way to
extend the testsuite to handle this situation.

Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is
in stage4, right?
The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

 * config/i386/freebsd64.h: Add bits for 32-bit multilib support.
 * config/i386/t-freebsd64: New file.
 * config.gcc: Add the t-freebsd64 for multilib support.



stage4 is supposed to be regression fixes only, so it's difficult to
make a case for this patch to get into gcc-9.

I'd say defer to gcc-10.


Ok, fine with me.
Once gcc-10 opens, I will commit this patch also to all open and active 
branches.

Thank you for the statement.
Andreas




[patch] Multilib support for amd64 FreeBSD

2019-03-17 Thread Andreas Tobler

Hi all,

this patch adds support for multilib on x86_64-unknown-freebsd*
The multilibs are 32-bit.

This patch is functionality tested on gcc8 and gcc9. Test suite testing 
is a bit tricky since the FreeBSD dynamic linker handles both, the 
32-bit and the 64-bit binaries. So, if I have a 64-bit libgcc in the 
LD_LIBRARY_PATH the test fails.
I tweaked the build tree and removed the 64-bit libgcc to test the 
32-bit binaries built. So far it looks good. Need to find a way to 
extend the testsuite to handle this situation.


Any comments about it are welcome.

Also, when would be the best time to commit this patch? Afair trunk is 
in stage4, right?

The patch itself only affects x86_64-unknown-freebsd.

TIA,
Andreas

2019-03-17  Andreas Tobler  

* config/i386/freebsd64.h: Add bits for 32-bit multilib support.
* config/i386/t-freebsd64: New file.
* config.gcc: Add the t-freebsd64 for multilib support.


Index: config/i386/freebsd64.h
===
--- config/i386/freebsd64.h (revision 269746)
+++ config/i386/freebsd64.h (working copy)
@@ -31,7 +31,7 @@
 
 #undef LINK_SPEC
 #define LINK_SPEC "\
-  %{m32:-m elf_i386_fbsd} \
+  %{m32:-m elf_i386_fbsd}%{!m32:-m elf_x86_64_fbsd} \
   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
@@ -42,3 +42,6 @@
-dynamic-linker %(fbsd_dynamic_linker) } \
 %{static:-Bstatic}} \
   %{symbolic:-Bsymbolic}"
+
+#undef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "m64" }
Index: config/i386/t-freebsd64
===
--- config/i386/t-freebsd64 (nonexistent)
+++ config/i386/t-freebsd64 (working copy)
@@ -0,0 +1,30 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# The 32-bit libraries are found in /usr/lib32
+
+# To support i386 and x86-64, the directory structrue
+# should be:
+#
+#  /lib has x86-64 libraries.
+#  /lib32 has i386 libraries.
+#
+
+MULTILIB_OPTIONS= m32
+MULTILIB_DIRNAMES   = 32
+MULTILIB_OSDIRNAMES = ../lib32
Index: config.gcc
===
--- config.gcc  (revision 269746)
+++ config.gcc  (working copy)
@@ -4925,8 +4925,11 @@
;;
i[34567]86-*-dragonfly* | x86_64-*-dragonfly*)
;;
-   i[34567]86-*-freebsd* | x86_64-*-freebsd*)
+   i[34567]86-*-freebsd*)
;;
+   x86_64-*-freebsd*)
+   tmake_file="${tmake_file} i386/t-freebsd64"
+   ;;
ia64*-*-linux*)
;;
 


Re: [patch] Fix bootstrap powerpc*-*-freebsd* targets

2018-12-16 Thread Andreas Tobler

On 12.12.18 21:32, Andreas Tobler wrote:


this patch fixes bootstrap for my powerpc*-unknown-freebsd* targets.
The definition of GNU_USER_DYNAMIC_LINKER was recently moved to linux.h.

But the GNU_USER_DYNAMIC_LINKER is still used in rs6000/sysv4.h.
So I add an empty definition with guard to cure the bootstrap issue.

Ok for trunk?


This is another attemtp to fix bootstrap on powerpc*-unknown-freebsd* only.

This one is only for FreeBSD and so I can approve and apply myself.

Objections?

TIA,
Andreas

2018-12-16  Andreas Tobler  

* config/rs6000/freebsd.h: Add an empty definition for
GNU_USER_DYNAMIC_LINKER.
* config/rs6000/freebsd64.h: Likewise.

Index: freebsd.h
===
--- freebsd.h   (revision 267190)
+++ freebsd.h   (working copy)
@@ -72,4 +72,8 @@
 /* Use standard DWARF numbering for DWARF debugging information.  */
 #define RS6000_USE_DWARF_NUMBERING

+#ifndef GNU_USER_DYNAMIC_LINKER
+#define GNU_USER_DYNAMIC_LINKER ""
+#endif
+
 #define POWERPC_FREEBSD
Index: freebsd64.h
===
--- freebsd64.h (revision 267190)
+++ freebsd64.h (working copy)
@@ -421,4 +421,8 @@
 #define USE_LD_AS_NEEDED 1
 #endif

+#ifndef GNU_USER_DYNAMIC_LINKER
+#define GNU_USER_DYNAMIC_LINKER ""
+#endif
+
 #define POWERPC_FREEBSD


[patch][aarch64-*-*freebsd*] Enable TARGET_DEFAULT_ASYNC_UNWIND_TABLES

2018-12-12 Thread Andreas Tobler

Hi all,

I have this patch since a longer time in my tree. No obvious fallout 
visible.


I'm going to commit this patch in the next days if no one objects.

TIA,
Andreas

2018-12-12  Andreas Tobler  

* config.gcc: Enable TARGET_DEFAULT_ASYNC_UNWIND_TABLES on
aarch64*-*-freebsd*.


Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 267063)
+++ gcc/config.gcc  (working copy)
@@ -1012,6 +1012,7 @@
tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-freebsd.h"
tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-freebsd"
+   tm_defines="${tm_defines}  TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
;;
 aarch64*-*-linux*)
tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h"


[patch] Fix bootstrap for non linux powerpc targets

2018-12-12 Thread Andreas Tobler

Hi all,

this patch fixes bootstrap for my powerpc*-unknown-freebsd* targets.
The definition of GNU_USER_DYNAMIC_LINKER was recently moved to linux.h.

But the GNU_USER_DYNAMIC_LINKER is still used in rs6000/sysv4.h.
So I add an empty definition with guard to cure the bootstrap issue.

Ok for trunk?

TIA,
Andreas

2018-12-12  Andreas Tobler  

* config/rs6000/sysv4.h: Add an empty definition for
GNU_USER_DYNAMIC_LINKER for all targets which do not include
linux.h where GNU_USER_DYNAMIC_LINKER is defined.

Index: sysv4.h
===
--- sysv4.h (revision 267063)
+++ sysv4.h (working copy)
@@ -761,6 +761,9 @@
 #define MUSL_DYNAMIC_LINKER \
   "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"

+#ifndef GNU_USER_DYNAMIC_LINKER
+#define GNU_USER_DYNAMIC_LINKER ""
+#endif
 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
   %{rdynamic:-export-dynamic} \
   -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"


Re: Remove support for FreeBSD 4.x (and earlier)

2018-05-28 Thread Andreas Tobler

On 28.05.18 08:57, Gerald Pfeifer wrote:

On Thu, 24 May 2018, Jeff Law wrote:

Happy to trust you on what versions can be dropped and the resulting
simplifications.

Is it worth noting those old versions as deprecated/obsolete in config.gcc?


Good catch, Jeff, thanks.  Updated patch (also wrt. comments) below.

Andreas, anyhing from your side?


Ok.
Thanks,
Andreas


Gerald

2018-05-27  Gerald Pfeifer  

* config.gcc: Identify FreeBSD 3.x and 4.x as unsupported.

* config/freebsd-spec.h (FBSD_LIB_SPEC): Only consider FreeBSD 5
and later.

Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 260808)
+++ gcc/config.gcc  (working copy)
@@ -268,7 +268,7 @@
   | pdp11-*-bsd\
   | sparc-hal-solaris2*\
   | thumb-*-*  \
- | *-*-freebsd[12] | *-*-freebsd[12].* \
+ | *-*-freebsd[12] | *-*-freebsd[1234].* \
   | *-*-freebsd*aout*  \
   | *-*-linux*aout*\
   | *-*-linux*coff*\
Index: gcc/config/freebsd-spec.h
===
--- gcc/config/freebsd-spec.h   (revision 260808)
+++ gcc/config/freebsd-spec.h   (working copy)
@@ -79,15 +79,10 @@
  #define FBSD_ENDFILE_SPEC \
"%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
  
-/* Provide a LIB_SPEC appropriate for FreeBSD as configured and as

-   required by the user-land thread model.  Before __FreeBSD_version
-   500016, select the appropriate libc, depending on whether we're
-   doing profiling or need threads support.  At __FreeBSD_version
-   500016 and later, when threads support is requested include both
-   -lc and the threading lib instead of only -lc_r.  To make matters
-   interesting, we can't actually use __FreeBSD_version provided by
-directly since it breaks cross-compiling.  As a final
-   twist, make it a hard error if -pthread is provided on the command
+/* When threads support is requested include both -lc and the threading
+   library (which assumes FreeBSD 5.x or later, __FreeBSD_version 500016
+   to be precise).
+   And make it a hard error if -pthread is provided on the command
 line and gcc was configured with --disable-threads (this will help
 avoid bug reports from users complaining about threading when they
 misconfigured the gcc bootstrap but are later consulting FreeBSD
@@ -106,19 +101,8 @@
  %{pg:  -lc_p} \
}"
  #else
-#if FBSD_MAJOR < 5
  #define FBSD_LIB_SPEC "  \
%{!shared:  \
-%{!pg: \
-  %{!pthread:-lc}  \
-  %{pthread:-lc_r}}
\
-%{pg:  \
-  %{!pthread:-lc_p}
\
-  %{pthread:-lc_r_p}}  \
-  }"
-#else
-#define FBSD_LIB_SPEC "   \
-  %{!shared:   \
  %{!pg: %{pthread:-lpthread} -lc}  \
  %{pg:  %{pthread:-lpthread_p} -lc_p}  \
}   \
@@ -126,8 +110,10 @@
  %{pthread:-lpthread} -lc  \
}"
  #endif
-#endif
  
+/* To make matters interesting, we can't actually use __FreeBSD_version

+   provided by  directly since it breaks cross-compiling.  */
+
  #if FBSD_MAJOR < 6
  #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
  #else





Re: [PATCH][arm][FreeBSD] PR libgcc/84292

2018-04-27 Thread Andreas Tobler

On 26.04.18 09:49, Richard Biener wrote:

On Wed, Apr 25, 2018 at 10:41 PM, Andreas Tobler
<andreast-l...@fgznet.ch> wrote:

Hi all,

I'm going to commit this patch to all active branches as soon as the branch
status permits.
Built and tested on native armv5 FreeBSD12.


If you think it is safe then it's fine for gcc-8-branch now.


It is safe and it really only affects armv4/5 on FreeBSD.
But I'm not that fast and I do not manage it to commit to the branches 
within the next days.


Thanks,
Andreas


Thanks,
Andreas

2018-04-25  Andreas Tobler  <andre...@gcc.gnu.org>
 Maryse Levavasseur <maryse.levavass...@stormshield.eu>

 PR libgcc/84292
 * config/arm/freebsd-atomic.c (SYNC_OP_AND_FETCH_N): Fix the
 op_and_fetch to return the right result.






[PATCH][arm][FreeBSD] PR libgcc/84292

2018-04-25 Thread Andreas Tobler

Hi all,

I'm going to commit this patch to all active branches as soon as the 
branch status permits.

Built and tested on native armv5 FreeBSD12.

Thanks,
Andreas

2018-04-25  Andreas Tobler  <andre...@gcc.gnu.org>
Maryse Levavasseur <maryse.levavass...@stormshield.eu>

PR libgcc/84292
* config/arm/freebsd-atomic.c (SYNC_OP_AND_FETCH_N): Fix the
op_and_fetch to return the right result.
Index: config/arm/freebsd-atomic.c
===
--- config/arm/freebsd-atomic.c (revision 259656)
+++ config/arm/freebsd-atomic.c (working copy)
@@ -171,9 +171,9 @@
 
 #defineSYNC_OP_AND_FETCH_N(N, TYPE, LDR, STR, NAME, OP)
\
 TYPE HIDDEN\
-__sync_##NAME##_and_fetch_##N (TYPE *mem, TYPE val)\
+__sync_##NAME##_and_fetch_##N (TYPE *mem, TYPE val)\
 {  \
-unsigned int old, temp, ras_start;  \
+unsigned int old, temp, ras_start, res; \
 \
 ras_start = ARM_RAS_START; \
 __asm volatile (   \
@@ -180,23 +180,23 @@
 /* Set up Restartable Atomic Sequence.  */ \
 "1:"   \
 "\tadr   %2, 1b\n" \
-"\tstr   %2, [%5]\n"   \
+"\tstr   %2, [%6]\n"   \
 "\tadr   %2, 2f\n" \
-"\tstr   %2, [%5, #4]\n"   \
+"\tstr   %2, [%6, #4]\n"   \
 \
-"\t"LDR" %0, %4\n" /* Load old value.  */  \
-"\t"OP"  %2, %0, %3\n" /* Calculate new value.  */ \
-"\t"STR" %2, %1\n" /* Store new value.  */ \
+"\t"LDR" %0, %5\n" /* Load old value.  */  \
+"\t"OP"  %3, %0, %4\n" /* Calculate new value.  */ \
+"\t"STR" %3, %1\n" /* Store new value.  */ \
 \
 /* Tear down Restartable Atomic Sequence.  */  \
 "2:"   \
 "\tmov   %2, #0x\n"\
-"\tstr   %2, [%5]\n"   \
+"\tstr   %2, [%6]\n"   \
 "\tmov   %2, #0x\n"\
-"\tstr   %2, [%5, #4]\n"   \
-: "=" (old), "=m" (*mem), "=" (temp)   \
+"\tstr   %2, [%6, #4]\n"   \
+: "=" (old), "=m" (*mem), "=" (temp), "=" (res)  \
 : "r" (val), "m" (*mem), "r" (ras_start)); \
-return (old);  \
+return (res);  \
 }
 
 #defineEMIT_ALL_OPS_N(N, TYPE, LDR, STR, STREQ)
\


Re: [PATCH] use shasum instead of sha512sum on FreeBSD and DragonFly

2018-01-15 Thread Andreas Tobler

On 15.01.18 13:59, Jonathan Wakely wrote:

boru on Freenode's #gcc channel pointed out that
contrib/download_prerequisites should use shasum for FreeBSD, not
sha512sum (which comes from GNU coreutils on GNU/Linux).  I checked
FreeBSD 11.0 and 10.2 and neither has sha512sum, not does DragonFly
4.2, another FreeBSD derivative.

OK for trunk?


Works here on FreeBSD, thanks.
Andreas



[patch][libgcc] FreeBSD amd64 unwind fix

2017-11-02 Thread Andreas Tobler

Hi all,

The attached patch fixes the PR 82635. I tested it on all active 
branches including the gcc-6 branch where we make extensive use of this 
MD_FALLBACK_FRAME_STATE_FOR macro. Namely in the libjava test suite. 
(Found no other suitable tests which do make use of this macro).

No regressions.

If there are no objections, I'm going to commit the patch below to all 
active branches in the next days.


Thanks,
Andreas

2017-11-02  Andreas Tobler  <andre...@gcc.gnu.org>

PR libgcc/82635
* config/i386/freebsd-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Use a
sysctl to determine whether we're in a trampoline.
Keep the pattern matching method for systems without
KERN_PROC_SIGTRAMP sysctl.

Index: libgcc/config/i386/freebsd-unwind.h
===
--- libgcc/config/i386/freebsd-unwind.h (revision 254350)
+++ libgcc/config/i386/freebsd-unwind.h (working copy)
@@ -28,7 +28,10 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
 
 #define REG_NAME(reg)  sf_uc.uc_mcontext.mc_## reg
@@ -36,6 +39,38 @@
 #ifdef __x86_64__
 #define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state
 
+#ifdef KERN_PROC_SIGTRAMP
+/* FreeBSD past 9.3 provides a kern.proc.sigtramp. sysctl that
+   returns the location of the signal trampoline. Use this to find
+   out whether we're in a trampoline.
+*/
+static int
+x86_64_outside_sigtramp_range (unsigned char *pc)
+{
+  static int sigtramp_range_determined = 0;
+  static unsigned char *sigtramp_start, *sigtramp_end;
+
+  if (sigtramp_range_determined == 0)
+{
+  struct kinfo_sigtramp kst = {0};
+  size_t len = sizeof (kst);
+  int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_SIGTRAMP, getpid() };
+
+  sigtramp_range_determined = 1;
+  if (sysctl (mib, 4, , , NULL, 0) == 0)
+  {
+sigtramp_range_determined = 2;
+sigtramp_start = kst.ksigtramp_start;
+sigtramp_end   = kst.ksigtramp_end;
+  }
+}
+  if (sigtramp_range_determined < 2)  /* sysctl failed if < 2 */
+return 1;
+
+  return (pc < sigtramp_start || pc >= sigtramp_end);
+}
+#endif
+
 static _Unwind_Reason_Code
 x86_64_freebsd_fallback_frame_state
 (struct _Unwind_Context *context, _Unwind_FrameState *fs)
@@ -43,6 +78,7 @@
   struct sigframe *sf;
   long new_cfa;
 
+#ifndef KERN_PROC_SIGTRAMP
   /* Prior to FreeBSD 9, the signal trampoline was located immediately
  before the ps_strings.  To support non-executable stacks on AMD64,
  the sigtramp was moved to a shared page for FreeBSD 9.  Unfortunately
@@ -62,12 +98,15 @@
 && *(unsigned int *)(context->ra +  8) == 0x01a1c0c7
 && *(unsigned int *)(context->ra + 12) == 0x050f ))
 return _URC_END_OF_STACK;
+#else
+  if (x86_64_outside_sigtramp_range(context->ra))
+return _URC_END_OF_STACK;
+#endif
 
   sf = (struct sigframe *) context->cfa;
   new_cfa = sf->REG_NAME(rsp);
   fs->regs.cfa_how = CFA_REG_OFFSET;
-  /* Register 7 is rsp  */
-  fs->regs.cfa_reg = 7;
+  fs->regs.cfa_reg =  __LIBGCC_STACK_POINTER_REGNUM__;
   fs->regs.cfa_offset = new_cfa - (long) context->cfa;
 
   /* The SVR4 register numbering macros aren't usable in libgcc.  */


Re: [patch][arm] gcc-7-branch: Fix bootstrap on FreeBSD

2017-10-17 Thread Andreas Tobler

Hi Kyrill,

On 17.10.17 12:02, Kyrill Tkachov wrote:


On 16/10/17 20:00, Andreas Tobler wrote:

Hi all,

I struggled over a bootstrap issue while building gcc-7 for
armv7-*-freebsd*

I got a 'permission denied' while creating the arm-tables.opt file.

The source tree is located on a nfs server.

The below patch fixed it for me.

Ok to apply?

TIA,
Andreas

2017-10-16  Andreas Tobler  <andre...@gcc.gnu.org>

 * config/arm/t-arm (MD_INCLUDES): Create arm-tables.opt via
 intermediate arm-tables.new like the other awk generated files.

Index: config/arm/t-arm
===
--- config/arm/t-arm(revision 253792)
+++ config/arm/t-arm(working copy)
@@ -75,8 +75,8 @@
   $(srcdir)/config/arm/arm-tables.opt: $(srcdir)/config/arm/parsecpu.awk \
 $(srcdir)/config/arm/arm-cpus.in
  $(AWK) -f $(srcdir)/config/arm/parsecpu.awk -v cmd=opt \
-   $(srcdir)/config/arm/arm-cpus.in > \
-   $(srcdir)/config/arm/arm-tables.opt
+   $(srcdir)/config/arm/arm-cpus.in > arm-tables.new
+   mv arm-tables.new $(srcdir)/config/arm/arm-tables.opt



This looks ok to me as it makes the rule consistent with the other
awk-generated files.

Out of interest, this looks like a small subset of Richard's patch [1]
at r249971.


Hehe, now as you say, yes. But I wasn't aware about it. I just tried to 
fix my bootstrap issue and compared the snippet with main. And tried if 
it helps to use an intermediate file.



Have you tried that patch on the branch?


No, is this patch going to appear on the gcc-7 branch?
If it is, then I'll not apply my patchlet above.


[1] https://gcc.gnu.org/ml/gcc-patches/2017-07/msg00223.html


Thanks,
Andreas



[patch][arm] gcc-7-branch: Fix bootstrap on FreeBSD

2017-10-16 Thread Andreas Tobler

Hi all,

I struggled over a bootstrap issue while building gcc-7 for armv7-*-freebsd*

I got a 'permission denied' while creating the arm-tables.opt file.

The source tree is located on a nfs server.

The below patch fixed it for me.

Ok to apply?

TIA,
Andreas

2017-10-16  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/t-arm (MD_INCLUDES): Create arm-tables.opt via
intermediate arm-tables.new like the other awk generated files.

Index: config/arm/t-arm
===
--- config/arm/t-arm(revision 253792)
+++ config/arm/t-arm(working copy)
@@ -75,8 +75,8 @@
 $(srcdir)/config/arm/arm-tables.opt: $(srcdir)/config/arm/parsecpu.awk \
   $(srcdir)/config/arm/arm-cpus.in
$(AWK) -f $(srcdir)/config/arm/parsecpu.awk -v cmd=opt \
-   $(srcdir)/config/arm/arm-cpus.in > \
-   $(srcdir)/config/arm/arm-tables.opt
+   $(srcdir)/config/arm/arm-cpus.in > arm-tables.new
+   mv arm-tables.new $(srcdir)/config/arm/arm-tables.opt

 $(srcdir)/config/arm/arm-cpu.h: $(srcdir)/config/arm/parsecpu.awk \
   $(srcdir)/config/arm/arm-cpus.in


Re: [patch][arm][FreeBSD] gcc-6/5: add support for armv7*-*-freebsd*

2017-10-10 Thread Andreas Tobler

On 08.10.17 23:12, Andreas Tobler wrote:

Hi all,

and here is the patch for gcc-6/5 branch to add support for
armv7*-*-freebsd*

The difference towards trunk is the missing of target_cpu_cname which is
solved differently.

I'm aware of the gcc-5 branch status and I will not apply before gcc-5.5
is released. I'll also will not apply on the gcc-5 branch if the branch
gets closed.

If you have any objections, please speak up.


Committed _only_ on the gcc-6 branch: 253604

Andreas


2017-10-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: (armv7*-*-freebsd*): New target.
Define TARGET_FREEBSD_ARMv7
* config/arm/freebsd.h: Use TARGET_FREEBSD_ARMv7 to define the
default cpu for armv7*-*-freebsd*.


Index: config/arm/freebsd.h
===
--- config/arm/freebsd.h(revision 253513)
+++ config/arm/freebsd.h(working copy)
@@ -112,6 +112,10 @@
   #undef  WCHAR_TYPE_SIZE
   #define WCHAR_TYPE_SIZE BITS_PER_WORD

+#if defined (TARGET_FREEBSD_ARMv7)
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_genericv7a
+#else
   #if defined (TARGET_FREEBSD_ARMv6)
   #undef  SUBTARGET_CPU_DEFAULT
   #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs
@@ -119,6 +123,7 @@
   #undef  SUBTARGET_CPU_DEFAULT
   #define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
   #endif
+#endif

   /* FreeBSD 10 does not support unaligned access for armv6 and up.
  Unaligned access support was added in FreeBSD 11.  */
Index: config.gcc
===
--- config.gcc  (revision 253513)
+++ config.gcc  (working copy)
@@ -1072,6 +1072,10 @@
  tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
   fi
;;
+   armv7*-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv7=1"
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+   ;;
esac
with_tls=${with_tls:-gnu}
;;





Re: [patch][arm][FreeBSD] gcc-7 branch: add support for armv7*-*-freebsd*

2017-10-10 Thread Andreas Tobler

On 08.10.17 22:58, Andreas Tobler wrote:

Hi all,

here is the patch witch adds support for armv7*-*-freebsd* on the gcc-7
branch.

The difference towards trunk is the target_cpu_cname.

I'll commit this one if no objections pop up.


Committed in 253603

Andreas


2017-10-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: (armv7*-*-freebsd*): New target.
(armv6*-*-freebsd*): Remove obsolete TARGET_FREEBSD_ARMv6 define.


Index: config.gcc
===
--- config.gcc  (revision 253528)
+++ config.gcc  (working copy)
@@ -1077,11 +1077,14 @@
case $target in
armv6*-*-freebsd*)
target_cpu_cname="arm1176jzfs"
-   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
   if test $fbsd_major -ge 11; then
  tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
   fi
;;
+   armv7*-*-freebsd*)
+   target_cpu_cname="genericv7a"
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+   ;;
*)
target_cpu_cname="arm9"
;;





Re: [patch][arm][FreeBSD] add support for armv7*-*-freebsd*

2017-10-10 Thread Andreas Tobler

On 08.10.17 22:51, Andreas Tobler wrote:

Hi all,

I'm going to commit this patch if no objections pop up.

We (FreeBSD folks) have added a new target tripplet for armv7*-*-freebsd*
To be able to build GCC we need the below changes.

Results will be posted to the usual place, once they completed

While here I remove an obsolete define.

I'll post similar patches for gcc-7, gcc-6 and gcc-5 branches.
They differ a bit...

Please speak up if you do not agree.



Commited in 253602

Andreas




[patch][arm][FreeBSD] gcc-6/5: add support for armv7*-*-freebsd*

2017-10-08 Thread Andreas Tobler

Hi all,

and here is the patch for gcc-6/5 branch to add support for 
armv7*-*-freebsd*


The difference towards trunk is the missing of target_cpu_cname which is 
solved differently.


I'm aware of the gcc-5 branch status and I will not apply before gcc-5.5 
is released. I'll also will not apply on the gcc-5 branch if the branch 
gets closed.


If you have any objections, please speak up.

TIA,
Andreas

2017-10-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: (armv7*-*-freebsd*): New target.
Define TARGET_FREEBSD_ARMv7
* config/arm/freebsd.h: Use TARGET_FREEBSD_ARMv7 to define the
default cpu for armv7*-*-freebsd*.


Index: config/arm/freebsd.h
===
--- config/arm/freebsd.h(revision 253513)
+++ config/arm/freebsd.h(working copy)
@@ -112,6 +112,10 @@
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE BITS_PER_WORD

+#if defined (TARGET_FREEBSD_ARMv7)
+#undef  SUBTARGET_CPU_DEFAULT
+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_genericv7a
+#else
 #if defined (TARGET_FREEBSD_ARMv6)
 #undef  SUBTARGET_CPU_DEFAULT
 #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs
@@ -119,6 +123,7 @@
 #undef  SUBTARGET_CPU_DEFAULT
 #define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
 #endif
+#endif

 /* FreeBSD 10 does not support unaligned access for armv6 and up.
Unaligned access support was added in FreeBSD 11.  */
Index: config.gcc
===
--- config.gcc  (revision 253513)
+++ config.gcc  (working copy)
@@ -1072,6 +1072,10 @@
tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
 fi
;;
+   armv7*-*-freebsd*)
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv7=1"
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+   ;;
esac
with_tls=${with_tls:-gnu}
;;


[patch][arm][FreeBSD] gcc-7 branch: add support for armv7*-*-freebsd*

2017-10-08 Thread Andreas Tobler

Hi all,

here is the patch witch adds support for armv7*-*-freebsd* on the gcc-7 
branch.


The difference towards trunk is the target_cpu_cname.

I'll commit this one if no objections pop up.
TIA,

Andreas

2017-10-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: (armv7*-*-freebsd*): New target.
(armv6*-*-freebsd*): Remove obsolete TARGET_FREEBSD_ARMv6 define.


Index: config.gcc
===
--- config.gcc  (revision 253528)
+++ config.gcc  (working copy)
@@ -1077,11 +1077,14 @@
case $target in
armv6*-*-freebsd*)
target_cpu_cname="arm1176jzfs"
-   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
 if test $fbsd_major -ge 11; then
tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
 fi
;;
+   armv7*-*-freebsd*)
+   target_cpu_cname="genericv7a"
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+   ;;
*)
target_cpu_cname="arm9"
;;


[patch][arm][FreeBSD] add support for armv7*-*-freebsd*

2017-10-08 Thread Andreas Tobler

Hi all,

I'm going to commit this patch if no objections pop up.

We (FreeBSD folks) have added a new target tripplet for armv7*-*-freebsd*
To be able to build GCC we need the below changes.

Results will be posted to the usual place, once they completed

While here I remove an obsolete define.

I'll post similar patches for gcc-7, gcc-6 and gcc-5 branches.
They differ a bit...

Please speak up if you do not agree.

TIA,
Andreas

2017-10-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc (armv7*-*-freebsd*): New target.
(armv6*-*-freebsd*): Remove obsolete TARGET_FREEBSD_ARMv6 define.

Index: config.gcc
===
--- config.gcc  (revision 253528)
+++ config.gcc  (working copy)
@@ -1093,11 +1093,14 @@
case $target in
armv6*-*-freebsd*)
target_cpu_cname="arm1176jzf-s"
-   tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
 if test $fbsd_major -ge 11; then
tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
 fi
;;
+   armv7*-*-freebsd*)
+   target_cpu_cname="generic-armv7-a"
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+   ;;
*)
target_cpu_cname="arm9"
;;


[committed] Fix bootstrap on armv6-*-freebsd

2017-06-20 Thread Andreas Tobler

Hi All,

I committed the chunk below to fix bootstrap on armv6*-*-freebsd.

Andreas

2017-06-20  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc (armv6*-*-freebsd*): Change the target_cpu_cname to
arm1176jzf-s.

Index: config.gcc
===
--- config.gcc  (revision 249427)
+++ config.gcc  (working copy)
@@ -1089,7 +1089,7 @@
tm_file="${tm_file} arm/bpabi.h arm/freebsd.h arm/aout.h arm/arm.h"
case $target in
armv6*-*-freebsd*)
-   target_cpu_cname="arm1176jzfs"
+   target_cpu_cname="arm1176jzf-s"
tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
 if test $fbsd_major -ge 11; then
tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"


Re: [patch] FreeBSD arm: make _Unwind_G/SetIP available as function.

2017-05-17 Thread Andreas Tobler

On 07.05.17 21:23, Andreas Tobler wrote:

Hi all,

On FreeBSD we make use of the functions _Unwind_GetIP, _Unwind_GetIPInfo
and _Unwind_SetIP outside of GCC. All other FreeBSD targets have these
functions available except arm.

Now since the GCC port for arm*-*-freebsd* is used more often (not only
by me ;), I was pointed out that these functions are not available.

The below patch tries to fix this.

Is the patch ok for trunk and after a while also for all active
branches? (7,6,5?)

I am the FreeBSD maintainer, yes, but I prefer to have an ack since the
affected files are not only used by FreeBSD. And if somebody has better
idea, I welcome the input.


Commit to trunk done. Branch commits will follow soon.
Andreas



TIA,
Andreas

2017-05-07  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/unwind-arm.h: Make _Unwind_GetIP, _Unwind_GetIPInfo and
_Unwind_SetIP available as functions for arm*-*-freebsd*.
* config/arm/unwind-arm.c: Implement the above.





Re: [patch] FreeBSD arm libgcc config.host

2017-05-10 Thread Andreas Tobler

On 07.05.17 21:30, Andreas Tobler wrote:

Hi all,

I'm going to commit the below patch to all active branches. (8,7,6,5)
It makes arm*-*-freebsd* use the generic FreeBSD t-slibgcc-elf-ver
definition. This makes all FreeBSD targets 'consistent' in this area.

If not ok, please speak up soon.


Commit done.

Andreas


TIA,
Andreas

2017-05-07  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host): Use the generic FreeBSD t-slibgcc-elf-ver for
arm*-*-freebsd instead of the t-slibgcc-libgcc.

Index: config.host
===
--- config.host (revision 247727)
+++ config.host (working copy)
@@ -397,7 +397,7 @@
;;
   arm*-*-freebsd*)# ARM FreeBSD EABI
tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix arm/t-elf"
-   tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd t-slibgcc-libgcc"
+   tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd"
tm_file="${tm_file} arm/bpabi-lib.h"
unwind_header=config/arm/unwind-arm.h
tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp
t-softfp"





[patch] FreeBSD arm libgcc config.host

2017-05-07 Thread Andreas Tobler

Hi all,

I'm going to commit the below patch to all active branches. (8,7,6,5)
It makes arm*-*-freebsd* use the generic FreeBSD t-slibgcc-elf-ver 
definition. This makes all FreeBSD targets 'consistent' in this area.


If not ok, please speak up soon.

TIA,
Andreas

2017-05-07  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host): Use the generic FreeBSD t-slibgcc-elf-ver for
arm*-*-freebsd instead of the t-slibgcc-libgcc.

Index: config.host
===
--- config.host (revision 247727)
+++ config.host (working copy)
@@ -397,7 +397,7 @@
;;
 arm*-*-freebsd*)# ARM FreeBSD EABI
tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix arm/t-elf"
-   tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd t-slibgcc-libgcc"
+   tmake_file="${tmake_file} arm/t-bpabi arm/t-freebsd"
tm_file="${tm_file} arm/bpabi-lib.h"
unwind_header=config/arm/unwind-arm.h
 	tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp 
t-softfp"


[patch] FreeBSD arm: make _Unwind_G/SetIP available as function.

2017-05-07 Thread Andreas Tobler

Hi all,

On FreeBSD we make use of the functions _Unwind_GetIP, _Unwind_GetIPInfo 
and _Unwind_SetIP outside of GCC. All other FreeBSD targets have these 
functions available except arm.


Now since the GCC port for arm*-*-freebsd* is used more often (not only 
by me ;), I was pointed out that these functions are not available.


The below patch tries to fix this.

Is the patch ok for trunk and after a while also for all active 
branches? (7,6,5?)


I am the FreeBSD maintainer, yes, but I prefer to have an ack since the 
affected files are not only used by FreeBSD. And if somebody has better 
idea, I welcome the input.


TIA,
Andreas

2017-05-07  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/unwind-arm.h: Make _Unwind_GetIP, _Unwind_GetIPInfo and
_Unwind_SetIP available as functions for arm*-*-freebsd*.
* config/arm/unwind-arm.c: Implement the above.

Index: libgcc/config/arm/unwind-arm.h
===
--- libgcc/config/arm/unwind-arm.h  (revision 247727)
+++ libgcc/config/arm/unwind-arm.h  (working copy)
@@ -72,6 +72,7 @@
 {
   return _URC_FAILURE;
 }
+#ifndef __FreeBSD__
   /* Return the address of the instruction, not the actual IP value.  */
 #define _Unwind_GetIP(context) \
   (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
@@ -78,6 +79,12 @@
 
 #define _Unwind_SetIP(context, val) \
   _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
+#else
+  #undef _Unwind_GetIPInfo
+  _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
+  _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
+  void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
+#endif
 
 #ifdef __cplusplus
 }   /* extern "C" */
Index: libgcc/config/arm/unwind-arm.c
===
--- libgcc/config/arm/unwind-arm.c  (revision 247727)
+++ libgcc/config/arm/unwind-arm.c  (working copy)
@@ -509,3 +509,25 @@
 {
   return __gnu_unwind_pr_common (state, ucbp, context, 2);
 }
+
+#ifdef __FreeBSD__
+/* FreeBSD expects these to be functions */
+inline _Unwind_Ptr
+_Unwind_GetIP (struct _Unwind_Context *context)
+{
+  return _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1;
+}
+
+inline _Unwind_Ptr
+_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn)
+{
+  *ip_before_insn = 0;
+  return _Unwind_GetIP (context);
+}
+
+inline void
+_Unwind_SetIP (struct _Unwind_Context *context, _Unwind_Ptr val)
+{
+  _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1));
+}
+#endif


[patch] aarch64 FreeBSD MCOUNT_NAME

2017-04-08 Thread Andreas Tobler

Hi all,

I'm going to commit the attached patch to trunk and all active branches 
in the next hours.


Again, a few tests fixed.

Also, I added a comment which I missed in my last commmit.

Thanks,
Andreas


2017-04-08  Andreas Tobler  <andre...@gcc.gnu.org>

* config/aarch64/aarch64-freebsd.h: Define MCOUNT_NAME.
Add comment for WCHAR_T.

Index: gcc/config/aarch64/aarch64-freebsd.h
===
--- gcc/config/aarch64/aarch64-freebsd.h(revision 246785)
+++ gcc/config/aarch64/aarch64-freebsd.h(working copy)
@@ -91,7 +91,12 @@
 #undef TARGET_BINDS_LOCAL_P
 #define TARGET_BINDS_LOCAL_P default_binds_local_p_2

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

+#undef MCOUNT_NAME
+#define MCOUNT_NAME ".mcount"
+
 #endif  /* GCC_AARCH64_FREEBSD_H */


[patch] aarch64 FreeBSD wchar_t

2017-04-07 Thread Andreas Tobler

Hi all,

I'm going to commit this patch to all active branches (5,6,7) in the 
next hours.


A few failures less in the testsuite.

Thanks,
Andreas

2017-04-07  Andreas Tobler  <andre...@gcc.gnu.org>

* config/aarch64/aarch64-freebsd.h: Define WCHAR_TYPE.

===
--- aarch64-freebsd.h   (revision 246772)
+++ aarch64-freebsd.h   (working copy)
@@ -91,4 +91,7 @@
 #undef TARGET_BINDS_LOCAL_P
 #define TARGET_BINDS_LOCAL_P default_binds_local_p_2

+#undef  WCHAR_TYPE
+#define WCHAR_TYPE  "unsigned int"
+
 #endif  /* GCC_AARCH64_FREEBSD_H */


Re: [PATCH, aarch64] add unwind support for aarch64-*-freebsd*

2017-03-09 Thread Andreas Tobler

On 09.03.17 22:44, Gerald Pfeifer wrote:

On Thu, 9 Mar 2017, Andreas Tobler wrote:

Ping!


Why are you pinging this, Andreas?  Are you seeking review to
make sure this is appropriate?


2017-02-16  John Marino  <gnu...@marino.st>

* config/aarch64/freebsd-unwind.h: New file.
* config.host: Add aarch64-*-freebsd unwinder.


I'm asking since this looks like a FreeBSD-related, in fact,
FreeBSD-specific patch to me.

And MAINTAINERS has

  freebsd     Andreas Tobler  <andre...@gcc.gnu.org>

so this is something you can approve yourself.


Basically yes, but I'm not sure how the planning and the freeze for 
trunk is. This is why ping.


Thanks,
Andreas


Re: [PATCH, aarch64] add unwind support for aarch64-*-freebsd*

2017-03-09 Thread Andreas Tobler

Ping!

TIA,
Andreas

On 16.02.17 20:21, Andreas Tobler wrote:

Hi all,

the attached patch adds unwind support for aarch64-*-freebsd*.

John used to catch unwind tests in ada.
So far it bootstraps and I see no regressions.

is this ok for trunk?

TIA,
Andreas

2017-02-16  John Marino  <gnu...@marino.st>

* config/aarch64/freebsd-unwind.h: New file.
* config.host: Add aarch64-*-freebsd unwinder.





Re: [PATCH PR79562] fix bootstrap on FreeBSD

2017-02-17 Thread Andreas Tobler

On 16.02.17 22:20, Andreas Tobler wrote:

On 16.02.17 22:03, Jakub Jelinek wrote:

On Thu, Feb 16, 2017 at 09:57:48PM +0100, Andreas Tobler wrote:

is this patch ok for trunk?

Fixes bootstrap for x86_64-*-freebsd12 where the internal struct rtentry has
gone from userland.

TIA,
Andreas

2017-02-16  Andreas Tobler  <andre...@gcc.gnu.org>

PR sanitizer/79562
* sanitizer_common/sanitizer_platform_limits_posix.cc: Cherry-pick
upstream r294806.


Ok, thanks.

I'm just surprised by the
"The problem was introduced within the last 8 days."
comment in the PR, because this file has been modified last time on
2016-11-08.


Yeah, I understand. This is due to the fact that on FreeBSD trunk (aka.
*-*-freebsd12) this commit
(https://svnweb.freebsd.org/base?view=revision=313560) dropped
the _WANT_RTENTRY from net/route.h.
Iow, all version of FreeBSD < svn commit r313560 will build w/o patch.



Is it ok to apply on gcc5 and gcc6 branch too? They are also affected.

TIA,

Andreas






Re: [PATCH PR79562] fix bootstrap on FreeBSD

2017-02-16 Thread Andreas Tobler

On 16.02.17 22:03, Jakub Jelinek wrote:

On Thu, Feb 16, 2017 at 09:57:48PM +0100, Andreas Tobler wrote:

is this patch ok for trunk?

Fixes bootstrap for x86_64-*-freebsd12 where the internal struct rtentry has
gone from userland.

TIA,
Andreas

2017-02-16  Andreas Tobler  <andre...@gcc.gnu.org>

PR sanitizer/79562
* sanitizer_common/sanitizer_platform_limits_posix.cc: Cherry-pick
upstream r294806.


Ok, thanks.

I'm just surprised by the
"The problem was introduced within the last 8 days."
comment in the PR, because this file has been modified last time on
2016-11-08.


Yeah, I understand. This is due to the fact that on FreeBSD trunk (aka. 
*-*-freebsd12) this commit 
(https://svnweb.freebsd.org/base?view=revision=313560) dropped 
the _WANT_RTENTRY from net/route.h.

Iow, all version of FreeBSD < svn commit r313560 will build w/o patch.

Thanks,
Andreas




Index: libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(revision 245506)
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(working copy)
@@ -21,11 +21,6 @@
 #ifdef _FILE_OFFSET_BITS
 #undef _FILE_OFFSET_BITS
 #endif
-#if SANITIZER_FREEBSD
-#define _WANT_RTENTRY
-#include 
-#include 
-#endif
 #include 
 #include 
 #include 
@@ -420,6 +415,7 @@
   unsigned struct_input_absinfo_sz = sizeof(struct input_absinfo);
   unsigned struct_input_id_sz = sizeof(struct input_id);
   unsigned struct_mtpos_sz = sizeof(struct mtpos);
+  unsigned struct_rtentry_sz = sizeof(struct rtentry);
   unsigned struct_termio_sz = sizeof(struct termio);
   unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
   unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
@@ -439,7 +435,6 @@
   unsigned struct_midi_info_sz = sizeof(struct midi_info);
   unsigned struct_mtget_sz = sizeof(struct mtget);
   unsigned struct_mtop_sz = sizeof(struct mtop);
-  unsigned struct_rtentry_sz = sizeof(struct rtentry);
   unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
   unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
   unsigned struct_synth_info_sz = sizeof(struct synth_info);



Jakub





[PATCH PR79562] fix bootstrap on FreeBSD

2017-02-16 Thread Andreas Tobler

Hi all,

is this patch ok for trunk?

Fixes bootstrap for x86_64-*-freebsd12 where the internal struct rtentry 
has gone from userland.


TIA,
Andreas

2017-02-16  Andreas Tobler  <andre...@gcc.gnu.org>

PR sanitizer/79562
* sanitizer_common/sanitizer_platform_limits_posix.cc: Cherry-pick
upstream r294806.
Index: libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(revision 245506)
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
(working copy)
@@ -21,11 +21,6 @@
 #ifdef _FILE_OFFSET_BITS
 #undef _FILE_OFFSET_BITS
 #endif
-#if SANITIZER_FREEBSD
-#define _WANT_RTENTRY
-#include 
-#include 
-#endif
 #include 
 #include 
 #include 
@@ -420,6 +415,7 @@
   unsigned struct_input_absinfo_sz = sizeof(struct input_absinfo);
   unsigned struct_input_id_sz = sizeof(struct input_id);
   unsigned struct_mtpos_sz = sizeof(struct mtpos);
+  unsigned struct_rtentry_sz = sizeof(struct rtentry);
   unsigned struct_termio_sz = sizeof(struct termio);
   unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
   unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
@@ -439,7 +435,6 @@
   unsigned struct_midi_info_sz = sizeof(struct midi_info);
   unsigned struct_mtget_sz = sizeof(struct mtget);
   unsigned struct_mtop_sz = sizeof(struct mtop);
-  unsigned struct_rtentry_sz = sizeof(struct rtentry);
   unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
   unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
   unsigned struct_synth_info_sz = sizeof(struct synth_info);


[PATCH, aarch64] add unwind support for aarch64-*-freebsd*

2017-02-16 Thread Andreas Tobler

Hi all,

the attached patch adds unwind support for aarch64-*-freebsd*.

John used to catch unwind tests in ada.
So far it bootstraps and I see no regressions.

is this ok for trunk?

TIA,
Andreas

2017-02-16  John Marino  

* config/aarch64/freebsd-unwind.h: New file.
* config.host: Add aarch64-*-freebsd unwinder.
Index: config.host
===
--- config.host (revision 245512)
+++ config.host (working copy)
@@ -340,7 +340,7 @@
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
-   md_unwind_header=aarch64/aarch64-unwind.h
+   md_unwind_header=aarch64/freebsd-unwind.h
;;
 aarch64*-*-linux*)
extra_parts="$extra_parts crtfastmath.o"
Index: config/aarch64/freebsd-unwind.h
===
--- config/aarch64/freebsd-unwind.h (nonexistent)
+++ config/aarch64/freebsd-unwind.h (working copy)
@@ -0,0 +1,108 @@
+/* DWARF2 EH unwinding support for FreeBSD/ARM64 (aarch64).
+   Copyright (C) 2017 Free Software Foundation, Inc.
+   Contributed by John Marino 
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+.  */
+
+/* Identify a signal frame, and set the frame state data appropriately.
+   See unwind-dw2.c for the structs. */
+
+/* Always include AArch64 unwinder header file.  */
+#include "config/aarch64/aarch64-unwind.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define REG_NAME(reg)   mc_gpregs.gp_## reg
+#define XREG(num)   mc_gpregs.gp_x[num]
+#define DARC__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__
+
+#define MD_FALLBACK_FRAME_STATE_FOR aarch64_freebsd_fallback_frame_state
+
+static int
+aarch64_outside_sigtramp_range (unsigned char *pc)
+{
+  static int sigtramp_range_determined = 0;
+  static unsigned char *sigtramp_start, *sigtramp_end;
+
+  if (sigtramp_range_determined == 0)
+{
+  struct kinfo_sigtramp kst = {0};
+  size_t len = sizeof (kst);
+  int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_SIGTRAMP, getpid() };
+
+  sigtramp_range_determined = 1;
+  if (sysctl (mib, 4, , , NULL, 0) == 0)
+  {
+sigtramp_range_determined = 2;
+sigtramp_start = kst.ksigtramp_start;
+sigtramp_end   = kst.ksigtramp_end;
+  }
+}
+  if (sigtramp_range_determined < 2)  /* sysctl failed if < 2 */
+return 1;
+
+  return (pc < sigtramp_start || pc >= sigtramp_end);
+}
+
+static _Unwind_Reason_Code
+aarch64_freebsd_fallback_frame_state
+(struct _Unwind_Context *context, _Unwind_FrameState *fs)
+{
+  int n;
+  struct sigframe *sf;
+  mcontext_t *sc;
+  _Unwind_Ptr new_cfa;
+
+  if (aarch64_outside_sigtramp_range(context->ra))
+return _URC_END_OF_STACK;
+
+  sf = (struct sigframe *) context->cfa;
+  sc = >sf_uc.uc_mcontext;
+
+  new_cfa = (_Unwind_Ptr) sc;
+  fs->regs.cfa_how = CFA_REG_OFFSET;
+  fs->regs.cfa_reg = __LIBGCC_STACK_POINTER_REGNUM__;
+  fs->regs.cfa_offset = new_cfa - (_Unwind_Ptr) context->cfa;
+
+  for (n = 0; n < 32; n++)
+fs->regs.reg[n].how = REG_SAVED_OFFSET;
+
+  for (n = 0; n < 30; n++)
+fs->regs.reg[n].loc.offset = (_Unwind_Ptr) &(sc->XREG(n)) - new_cfa;
+
+  fs->regs.reg[30].loc.offset = (_Unwind_Ptr) &(sc->REG_NAME(lr)) - new_cfa;
+  fs->regs.reg[31].loc.offset = (_Unwind_Ptr) &(sc->REG_NAME(sp)) - new_cfa;
+
+  fs->regs.reg[DARC].how = REG_SAVED_OFFSET;
+  fs->regs.reg[DARC].loc.offset = (_Unwind_Ptr) &(sc->REG_NAME(elr)) - new_cfa;
+
+  fs->retaddr_column = DARC;
+  fs->signal_frame = 1;
+
+  return _URC_NO_REASON;
+}


Re: [RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-23 Thread Andreas Tobler

On 23.01.17 18:48, Jakub Jelinek wrote:

On Mon, Jan 23, 2017 at 06:42:15PM +0100, Andreas Tobler wrote:

Something like below?

If ok, I can commit, right?

Thanks,

Andreas

2017-01-23  Andreas Tobler  <andre...@gcc.gnu.org>

* config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
size of buf.
(aarch64_elf_asm_destructor): Likewise.
--- config/aarch64/aarch64.c(revision 244819)
+++ config/aarch64/aarch64.c(working copy)
@@ -5787,7 +5787,11 @@
   else
 {
   section *s;
-  char buf[18];
+  /* The size of the buf must be big enough to hold the string and the
+ full integer size of priority. Otherwise we will get a warning
+ about format-truncation.
+  */


Please put the */ on the same line as about format-truncation, like:
 about format-truncation.  */
After . there should be 2 spaces rather than one.
Also, the comment doesn't tell the truth, the buffer doesn't have to be that
big, because we know priority is bounded, just the compiler doesn't know
that.  So perhaps:
  /* While priority is known to be in range [0, 65535], so 18 bytes
 would be enough, the compiler might not know that.  To avoid
 -Wformat-truncation false positive, use a larger size.  */
  char buf[23];
or so?



Danke.

Andreas

2017-01-23  Andreas Tobler  <andre...@gcc.gnu.org>

* config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
size of buf.
(aarch64_elf_asm_destructor): Likewise.

Index: config/aarch64/aarch64.c
===
--- config/aarch64/aarch64.c(revision 244819)
+++ config/aarch64/aarch64.c(working copy)
@@ -5787,7 +5787,10 @@
   else
 {
   section *s;
-  char buf[18];
+  /* While priority is known to be in range [0, 65535], so 18 bytes
+ would be enough, the compiler might not know that.  To avoid
+ -Wformat-truncation false positive, use a larger size.  */
+  char buf[23];
   snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
   s = get_section (buf, SECTION_WRITE, NULL);
   switch_to_section (s);
@@ -5804,7 +5807,10 @@
   else
 {
   section *s;
-  char buf[18];
+  /* While priority is known to be in range [0, 65535], so 18 bytes
+ would be enough, the compiler might not know that.  To avoid
+ -Wformat-truncation false positive, use a larger size.  */
+  char buf[23];
   snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
   s = get_section (buf, SECTION_WRITE, NULL);
   switch_to_section (s);


Re: [RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-23 Thread Andreas Tobler

On 23.01.17 11:07, Richard Earnshaw (lists) wrote:

On 21/01/17 20:15, Andreas Tobler wrote:

On 21.01.17 00:42, Jakub Jelinek wrote:

On Fri, Jan 20, 2017 at 01:37:13PM -0700, Jeff Law wrote:

Which is best will depend on what the front/mid ends might have
done to
apply the documented limit.


Here I know not enough to give a decision. In tree the priority_type is
unsigned short. In varasm priority is an int.

Similar functions, like arm_elf_asm_cdtor, do use the sprintf
instead of
snprintf. They theoretically have the same issue.

So, either:
2.) use %.5hu in snprintf
or
3.) cast priority in snprintf to (unsigned short)

I'd go with #2.  I think #3 still requires range propagation to avoid
the
false positive.


I actually think 1.) is best work-around, after 18 bytes there will be
some
padding so 23 bytes will almost always eat the same amount of stack
space,
and we avoid actually adding some instruction to cast it or hoping all
the
libcs we run on support %.5hu properly.


Richard, what do you think about this suggestion?

Thanks,
Andreas




I'm happy to go with that, but please add a comment as well, or some
well meaning individual may accidentally reverse the change after
counting the bytes...


Something like below?

If ok, I can commit, right?

Thanks,

Andreas

2017-01-23  Andreas Tobler  <andre...@gcc.gnu.org>

* config/aarch64/aarch64.c (aarch64_elf_asm_constructor): Increase
size of buf.
(aarch64_elf_asm_destructor): Likewise.


Index: config/aarch64/aarch64.c
===
--- config/aarch64/aarch64.c(revision 244819)
+++ config/aarch64/aarch64.c(working copy)
@@ -5787,7 +5787,11 @@
   else
 {
   section *s;
-  char buf[18];
+  /* The size of the buf must be big enough to hold the string and the
+ full integer size of priority. Otherwise we will get a warning
+ about format-truncation.
+  */
+  char buf[23];
   snprintf (buf, sizeof (buf), ".init_array.%.5u", priority);
   s = get_section (buf, SECTION_WRITE, NULL);
   switch_to_section (s);
@@ -5804,7 +5808,11 @@
   else
 {
   section *s;
-  char buf[18];
+  /* The size of the buf must be big enough to hold the string and the
+ full integer size of priority. Otherwise we will get a warning
+ about format-truncation.
+  */
+  char buf[23];
   snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
   s = get_section (buf, SECTION_WRITE, NULL);
   switch_to_section (s);


Re: [RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-21 Thread Andreas Tobler

On 21.01.17 00:42, Jakub Jelinek wrote:

On Fri, Jan 20, 2017 at 01:37:13PM -0700, Jeff Law wrote:

Which is best will depend on what the front/mid ends might have done to
apply the documented limit.


Here I know not enough to give a decision. In tree the priority_type is
unsigned short. In varasm priority is an int.

Similar functions, like arm_elf_asm_cdtor, do use the sprintf instead of
snprintf. They theoretically have the same issue.

So, either:
2.) use %.5hu in snprintf
or
3.) cast priority in snprintf to (unsigned short)

I'd go with #2.  I think #3 still requires range propagation to avoid the
false positive.


I actually think 1.) is best work-around, after 18 bytes there will be some
padding so 23 bytes will almost always eat the same amount of stack space,
and we avoid actually adding some instruction to cast it or hoping all the
libcs we run on support %.5hu properly.


Richard, what do you think about this suggestion?

Thanks,
Andreas



Re: [RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-20 Thread Andreas Tobler

On 20.01.17 17:12, Richard Earnshaw (lists) wrote:

On 19/01/17 06:38, Andreas Tobler wrote:

On 19.01.17 00:33, Jeff Law wrote:

On 01/18/2017 11:43 AM, Andreas Tobler wrote:

Hi all,

I have the following issue here on aarch64-*-freebsd:

(sorry if the format is hardly readable)

..
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c: In
function 'void aarch64_elf_asm_destructor(rtx, int)':
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1:
error: %.5u' directive output may be truncated writing between 5 and 10
bytes into a region of size 6 [-Werror=format-truncation=]
 aarch64_elf_asm_destructor (rtx symbol, int priority)
 ^~
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1:
note: using the range [1, 4294967295] for directive argument
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5768:65:
note: format output between 18 and 23 bytes into a destination of
size 18
   snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);

^
...

This is the code snippet, it does not only occur in aarch64, but also at
least in pa and avr.


static void
aarch64_elf_asm_destructor (rtx symbol, unsigned short priority)
{
  if (priority == DEFAULT_INIT_PRIORITY)
default_dtor_section_asm_out_destructor (symbol, priority);
  else
{
  section *s;
  char buf[18];
  snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
  s = get_section (buf, SECTION_WRITE, NULL);
  switch_to_section (s);
  assemble_align (POINTER_SIZE);
  assemble_aligned_integer (POINTER_BYTES, symbol);
}
}


I have now four options to solve this, (a fifth one would be to remove
format-truncation from -Wall/Wextra?)

1.) increase buf to 23
2.) use %.5hu in snprintf
3.) cast priority in snprintf to (unsigned int)
4.) make priority unsigned short.

Solution 1, 2 and 3 work, but with pros and cons.

#3 likely won't work with with lower optimization levels since it
depends on VRP to narrow the object's range.

I'd approve #2 or #1 without hesitation.


Ok.

I did a mistake while describing the situation. The function has this
parameter:

aarch64_elf_asm_destructor (rtx symbol, int priority)

I copied the already modified piece of code



Ah, that makes much more sense.


So the cast in #3 would be (unsigned short) iso (unsigned int).

If no other opinions come up I'll go with #2.

Thanks.
Andreas




I agree, some sort of cast seems preferable.  The documentation for
constructor priorities says that the lowest priority is 65535, so
alternatives here are:

- assert (priority < 65536) then cast to unsigned short.
- simply cast to unsigned short
- saturate to 16 bits unsigned then cast to short.

Which is best will depend on what the front/mid ends might have done to
apply the documented limit.


Here I know not enough to give a decision. In tree the priority_type is 
unsigned short. In varasm priority is an int.


Similar functions, like arm_elf_asm_cdtor, do use the sprintf instead of 
snprintf. They theoretically have the same issue.


So, either:
2.) use %.5hu in snprintf
or
3.) cast priority in snprintf to (unsigned short)


Thanks,
Andreas



Re: [RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-18 Thread Andreas Tobler

On 19.01.17 00:33, Jeff Law wrote:

On 01/18/2017 11:43 AM, Andreas Tobler wrote:

Hi all,

I have the following issue here on aarch64-*-freebsd:

(sorry if the format is hardly readable)

..
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c: In
function 'void aarch64_elf_asm_destructor(rtx, int)':
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1:
error: %.5u' directive output may be truncated writing between 5 and 10
bytes into a region of size 6 [-Werror=format-truncation=]
 aarch64_elf_asm_destructor (rtx symbol, int priority)
 ^~
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1:
note: using the range [1, 4294967295] for directive argument
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5768:65:
note: format output between 18 and 23 bytes into a destination of size 18
   snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);

^
...

This is the code snippet, it does not only occur in aarch64, but also at
least in pa and avr.


static void
aarch64_elf_asm_destructor (rtx symbol, unsigned short priority)
{
  if (priority == DEFAULT_INIT_PRIORITY)
default_dtor_section_asm_out_destructor (symbol, priority);
  else
{
  section *s;
  char buf[18];
  snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
  s = get_section (buf, SECTION_WRITE, NULL);
  switch_to_section (s);
  assemble_align (POINTER_SIZE);
  assemble_aligned_integer (POINTER_BYTES, symbol);
}
}


I have now four options to solve this, (a fifth one would be to remove
format-truncation from -Wall/Wextra?)

1.) increase buf to 23
2.) use %.5hu in snprintf
3.) cast priority in snprintf to (unsigned int)
4.) make priority unsigned short.

Solution 1, 2 and 3 work, but with pros and cons.

#3 likely won't work with with lower optimization levels since it
depends on VRP to narrow the object's range.

I'd approve #2 or #1 without hesitation.


Ok.

I did a mistake while describing the situation. The function has this 
parameter:


aarch64_elf_asm_destructor (rtx symbol, int priority)

I copied the already modified piece of code

So the cast in #3 would be (unsigned short) iso (unsigned int).

If no other opinions come up I'll go with #2.

Thanks.
Andreas




[RFC] fix bootstrap on aarch64-*-freebsd and probably others

2017-01-18 Thread Andreas Tobler

Hi all,

I have the following issue here on aarch64-*-freebsd:

(sorry if the format is hardly readable)

..
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c: In 
function 'void aarch64_elf_asm_destructor(rtx, int)':
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1: 
error: %.5u' directive output may be truncated writing between 5 and 10 
bytes into a region of size 6 [-Werror=format-truncation=]

 aarch64_elf_asm_destructor (rtx symbol, int priority)
 ^~
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5760:1: 
note: using the range [1, 4294967295] for directive argument
/export/devel/net/src/gcc/head/gcc/gcc/config/aarch64/aarch64.c:5768:65: 
note: format output between 18 and 23 bytes into a destination of size 18

   snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);

^
...

This is the code snippet, it does not only occur in aarch64, but also at 
least in pa and avr.



static void
aarch64_elf_asm_destructor (rtx symbol, unsigned short priority)
{
  if (priority == DEFAULT_INIT_PRIORITY)
default_dtor_section_asm_out_destructor (symbol, priority);
  else
{
  section *s;
  char buf[18];
  snprintf (buf, sizeof (buf), ".fini_array.%.5u", priority);
  s = get_section (buf, SECTION_WRITE, NULL);
  switch_to_section (s);
  assemble_align (POINTER_SIZE);
  assemble_aligned_integer (POINTER_BYTES, symbol);
}
}


I have now four options to solve this, (a fifth one would be to remove 
format-truncation from -Wall/Wextra?)


1.) increase buf to 23
2.) use %.5hu in snprintf
3.) cast priority in snprintf to (unsigned int)
4.) make priority unsigned short.

Solution 1, 2 and 3 work, but with pros and cons.

The last option is the cleanest one, but it involves changing priority 
everywhere in the gcc/gcc sources. I started and saw how many places I 
have to change before I continue I would like to ask you guys, which 
one is the prefered solution?


Thanks for feedback.
Andreas


Re: [patch] aarch64-*-freebsd* support for gcc.

2017-01-09 Thread Andreas Tobler

On 13.10.16 17:14, Jeff Law wrote:

On 10/12/2016 01:43 PM, Andreas Tobler wrote:


libgcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host: Add support for aarch64-*-freebsd*.

gcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Add aarch64-*-freebsd* support.
* config.host: Likewise.
* config/aarch64/aarch64-freebsd.h: New file.
* config/aarch64/t-aarch64-freebsd: Ditto.

toplevel:

2016-10-10  Andreas Tobler <andre...@gcc.gnu.org>

* configure.ac: Add aarch64-*-freebsd*.
* configure: Regenerate.

Certainly OK for the trunk.  Jakub, Richi & Joseph make the rules for
the release branches.


I had a chat with Jakub and I learned as long as there is no branch
freeze or such, every global reviewer can approve such a patch backport.
So may I ask you, would you mind approving this patch for 6.x and 5.x?

Yes.  Approved for 5.x and 6.x.


After fixing a bootstrap comparison failure on 6.x finally committed to 
6.x (244242) and 5.x (244243)


Thanks,
Andreas



Re: [PATCH] Fix late dwarf generated early from optimized out globals

2017-01-09 Thread Andreas Tobler

On 09.01.17 18:36, Jakub Jelinek wrote:

On Mon, Jan 09, 2017 at 06:25:05PM +0100, Andreas Tobler wrote:

On 09.01.17 12:25, Jakub Jelinek wrote:

On Mon, Jan 09, 2017 at 11:53:38AM +0100, Richard Biener wrote:

Ok, attached the part I bootstrapped successfully on amd64-*-freebsd12 and
aarch64-*-freebsd12. From the amd64 run you'll find some test results at the
usual place. The aarch64 run takes some more time.

I hope I got it right this time :)
What do you think?


Looks good to me with the added comment to dwarf2out_late_global_decl
exchanged to the one on trunk.


The formatting is completely wrong.
Lines indented e.g. by 7 spaces (or tab + 1/3 space(s)),
/* comment inside of { block starting in the same column as {
(should be 2 columns to the right), && ! not aligned below VAR_P,
or indenting by 3 columns instead of 2.


Hehe, yep. This time done with emacs ;)

Here the hopefully final patch with proper ChangeLog and formatting fixed.

Ok to apply?


Formatting LGTM, so I think Richard's approval applies now.


Thanks a lot!

Committed as 244240.

Andreas



Re: [PATCH] Fix late dwarf generated early from optimized out globals

2017-01-09 Thread Andreas Tobler

On 09.01.17 12:25, Jakub Jelinek wrote:

On Mon, Jan 09, 2017 at 11:53:38AM +0100, Richard Biener wrote:

Ok, attached the part I bootstrapped successfully on amd64-*-freebsd12 and
aarch64-*-freebsd12. From the amd64 run you'll find some test results at the
usual place. The aarch64 run takes some more time.

I hope I got it right this time :)
What do you think?


Looks good to me with the added comment to dwarf2out_late_global_decl
exchanged to the one on trunk.


The formatting is completely wrong.
Lines indented e.g. by 7 spaces (or tab + 1/3 space(s)),
/* comment inside of { block starting in the same column as {
(should be 2 columns to the right), && ! not aligned below VAR_P,
or indenting by 3 columns instead of 2.


Hehe, yep. This time done with emacs ;)

Here the hopefully final patch with proper ChangeLog and formatting fixed.

Ok to apply?

Thanks,
Andreas

2017-01-09  Andreas Tobler  <andre...@gcc.gnu.org>

Backport from mainline
2016-09-19  Richard Biener  <rguent...@suse.de>

* dwarf2out.c (dwarf2out_late_global_decl): When being during the
early debug phase do not add locations but only const value
attributes.

Backport from mainline
2016-10-20  Richard Biener  <rguent...@suse.de>

* cgraphunit.c (analyze_functions): Set node->definition to
false to signal symbol removal to debug_hooks->late_global_decl.

Index: gcc/dwarf2out.c
===
--- gcc/dwarf2out.c (revision 244100)
+++ gcc/dwarf2out.c (working copy)
@@ -23752,7 +23752,16 @@
 {
   dw_die_ref die = lookup_decl_die (decl);
   if (die)
-   add_location_or_const_value_attribute (die, decl, false);
+{
+  /* We get called via the symtab code invoking late_global_decl
+ for symbols that are optimized out.  Do not add locations
+ for those.  */
+  varpool_node *node = varpool_node::get (decl);
+  if (! node || ! node->definition)
+tree_add_const_value_attribute_for_decl (die, decl);
+  else
+add_location_or_const_value_attribute (die, decl, false);
+}
 }
 }
 
Index: gcc/cgraphunit.c
===
--- gcc/cgraphunit.c(revision 244100)
+++ gcc/cgraphunit.c(working copy)
@@ -1193,8 +1193,16 @@
 at looking at optimized away DECLs, since
 late_global_decl will subsequently be called from the
 contents of the now pruned symbol table.  */
- if (!decl_function_context (node->decl))
-   (*debug_hooks->late_global_decl) (node->decl);
+ if (VAR_P (node->decl)
+ && !decl_function_context (node->decl))
+   {
+ /* We are reclaiming totally unreachable code and variables
+so they effectively appear as readonly.  Show that to
+the debug machinery.  */
+ TREE_READONLY (node->decl) = 1;
+ node->definition = false;
+ (*debug_hooks->late_global_decl) (node->decl);
+   }
 
  node->remove ();
  continue;


Re: [PATCH] Fix late dwarf generated early from optimized out globals

2017-01-05 Thread Andreas Tobler

On 05.01.17 13:05, Richard Biener wrote:

On Wed, 4 Jan 2017, Andreas Tobler wrote:


On 04.01.17 10:21, Richard Biener wrote:

On Wed, 28 Dec 2016, Andreas Tobler wrote:


On 28.12.16 19:24, Richard Biener wrote:

On December 27, 2016 11:17:00 PM GMT+01:00, Andreas Tobler
<andreast-l...@fgznet.ch> wrote:

On 16.09.16 13:30, Richard Biener wrote:

On Thu, 15 Sep 2016, Richard Biener wrote:



This addresses sth I needed to address with the early LTO debug

patches

(you might now figure I'm piecemail merging stuff from that
patch).

When the cgraph code optimizes out a global we call the

late_global_decl

debug hook to eventually add a DW_AT_const_value to its DIE (we

don't

really expect a location as that will be invalid after optimizing

out

and will be pruned).

With the early LTO debug patches I have introduced a

early_dwarf_finished

flag (mainly for consistency checking) and I figured I can use
that

to

detect the call to the late hook during the early phase and
provide
the following cleaned up variant of avoiding to create locations

that

require later pruning (which doesn't work with emitting the early

DIEs).


Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

I verified it does the correct thing for a unit like

static const int i = 2;

(but ISTR we do have at least one testcase in the testsuite as

well).


Will commit if testing finishes successfully.


Ok, so it showed issues when merging that back to early-LTO-debug.
Turns out in LTO we never call early_finish and thus

early_dwarf_finished

was never set.  Also dwarf2out_late_global_decl itself is a better
place to constrain generating locations.

The following variant is in very late stage of testing.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
LTO bootstrap on x86_64-unknown-linux-gnu in stage3.  LTO bootstrap
with early-LTO-debug in stage3, bootstraped with early-LTO-debug,
testing in progress.


Any chance to backport this commit (r240228) to 6.x?
It fixes a bootstrap comparison issue on aarch64-*-freebsd*.
The aarch64-*-freebsd* port is not yet merged to 6.x and 5.4.x due to
the bootstrap comparison failure I faced.


Did you analyze the bootstrap miscompare?  I suspect the patch merely
papers
over the problem.


gcc/contrib/compare-debug -p prev-gcc/ipa-icf.o gcc/ipa-icf.o
prev-gcc/ipa-icf.o.stripped. gcc/ipa-icf.o.stripped. differ: char 52841,
line
253


The objdump -dSx diff on the non stripped object looked always more or
less
the same, a rodata offset which was different.

-   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x1d8
+   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x410


Hmm, sounds like a constant pool entry was created by -g at a different
time (and thus offset) from regular compilation.  So yes, the patch
in question should have the affect to "fix" this.

Note that I later changed the fix with

2016-10-20  Richard Biener  <rguent...@suse.de>

* cgraphunit.c (analyze_functions): Set node->definition to
false to signal symbol removal to debug_hooks->late_global_decl.
* ipa.c (symbol_table::remove_unreachable_nodes): When not in
WPA signal symbol removal to the debuginfo machinery.
* dwarf2out.c (dwarf2out_late_global_decl): Instead of
using early_finised to guard the we're called for symbol
removal case look at the symtabs definition flag.
(gen_variable_die): Remove redundant check.

(the dwarf2out_late_global_decl and analyze_functions part are
relevant).

That should be the fix to backport (avoiding the early_dwarf_finished
part).


Ok, I bootstrapped with the attached snippet (had to tweak a bit to apply
cleanly). w/o the previous mentioned fix (r240228). Is this what you had in
mind or do you think some parts of the other fix (r240228) is also needed?


Not sure if you need the dwarf2out.c part you included but you clearly
missed the dwarf2out_late_global_decl part doing

  /* We get called via the symtab code invoking late_global_decl
 for symbols that are optimized out.  Do not add locations
 for those.  */
  varpool_node *node = varpool_node::get (decl);
  if (! node || ! node->definition)
tree_add_const_value_attribute_for_decl (die, decl);
  else
add_location_or_const_value_attribute (die, decl, false);

I wouldn't include the ipa.c part unless required (it adds additional
debug for optimized out decls).


Ok, attached the part I bootstrapped successfully on amd64-*-freebsd12 
and aarch64-*-freebsd12. From the amd64 run you'll find some test 
results at the usual place. The aarch64 run takes some more time.


I hope I got it right this time :)
What do you think?

Thanks,
Andreas

Index: dwarf2out.c
===
--- dwarf2out.c (revision 244100)
+++ dwarf2out.c (working copy)
@@ -23752,7 +23752,17 

Re: [PATCH] Fix late dwarf generated early from optimized out globals

2017-01-04 Thread Andreas Tobler

On 04.01.17 10:21, Richard Biener wrote:

On Wed, 28 Dec 2016, Andreas Tobler wrote:


On 28.12.16 19:24, Richard Biener wrote:

On December 27, 2016 11:17:00 PM GMT+01:00, Andreas Tobler
<andreast-l...@fgznet.ch> wrote:

On 16.09.16 13:30, Richard Biener wrote:

On Thu, 15 Sep 2016, Richard Biener wrote:



This addresses sth I needed to address with the early LTO debug

patches

(you might now figure I'm piecemail merging stuff from that patch).

When the cgraph code optimizes out a global we call the

late_global_decl

debug hook to eventually add a DW_AT_const_value to its DIE (we

don't

really expect a location as that will be invalid after optimizing

out

and will be pruned).

With the early LTO debug patches I have introduced a

early_dwarf_finished

flag (mainly for consistency checking) and I figured I can use that

to

detect the call to the late hook during the early phase and provide
the following cleaned up variant of avoiding to create locations

that

require later pruning (which doesn't work with emitting the early

DIEs).


Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

I verified it does the correct thing for a unit like

static const int i = 2;

(but ISTR we do have at least one testcase in the testsuite as

well).


Will commit if testing finishes successfully.


Ok, so it showed issues when merging that back to early-LTO-debug.
Turns out in LTO we never call early_finish and thus

early_dwarf_finished

was never set.  Also dwarf2out_late_global_decl itself is a better
place to constrain generating locations.

The following variant is in very late stage of testing.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
LTO bootstrap on x86_64-unknown-linux-gnu in stage3.  LTO bootstrap
with early-LTO-debug in stage3, bootstraped with early-LTO-debug,
testing in progress.


Any chance to backport this commit (r240228) to 6.x?
It fixes a bootstrap comparison issue on aarch64-*-freebsd*.
The aarch64-*-freebsd* port is not yet merged to 6.x and 5.4.x due to
the bootstrap comparison failure I faced.


Did you analyze the bootstrap miscompare?  I suspect the patch merely papers
over the problem.


gcc/contrib/compare-debug -p prev-gcc/ipa-icf.o gcc/ipa-icf.o
prev-gcc/ipa-icf.o.stripped. gcc/ipa-icf.o.stripped. differ: char 52841, line
253


The objdump -dSx diff on the non stripped object looked always more or less
the same, a rodata offset which was different.

-   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x1d8
+   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x410


Hmm, sounds like a constant pool entry was created by -g at a different
time (and thus offset) from regular compilation.  So yes, the patch
in question should have the affect to "fix" this.

Note that I later changed the fix with

2016-10-20  Richard Biener  <rguent...@suse.de>

* cgraphunit.c (analyze_functions): Set node->definition to
false to signal symbol removal to debug_hooks->late_global_decl.
* ipa.c (symbol_table::remove_unreachable_nodes): When not in
WPA signal symbol removal to the debuginfo machinery.
* dwarf2out.c (dwarf2out_late_global_decl): Instead of
using early_finised to guard the we're called for symbol
removal case look at the symtabs definition flag.
(gen_variable_die): Remove redundant check.

(the dwarf2out_late_global_decl and analyze_functions part are
relevant).

That should be the fix to backport (avoiding the early_dwarf_finished
part).


Ok, I bootstrapped with the attached snippet (had to tweak a bit to 
apply cleanly). w/o the previous mentioned fix (r240228). Is this what 
you had in mind or do you think some parts of the other fix (r240228) is 
also needed?


Thanks for the help, really appreciated.

Andreas


Index: cgraphunit.c
===
--- cgraphunit.c(revision 244050)
+++ cgraphunit.c(working copy)
@@ -1193,8 +1193,16 @@
 at looking at optimized away DECLs, since
 late_global_decl will subsequently be called from the
 contents of the now pruned symbol table.  */
- if (!decl_function_context (node->decl))
-   (*debug_hooks->late_global_decl) (node->decl);
+ if (VAR_P (node->decl)
+   && !decl_function_context (node->decl))
+{
+   /* We are reclaiming totally unreachable code and variables
+   so they effectively appear as readonly.  Show that to
+   the debug machinery.  */
+   TREE_READONLY (node->decl) = 1;
+   node->definition = false;
+   (*debug_hooks->late_global_decl) (node->decl);
+}
 
  node->remove ();
  continue;
Index: dwarf2out.c
===
--- dwarf2out.c (revision 2440

Re: [PATCH] Fix late dwarf generated early from optimized out globals

2016-12-28 Thread Andreas Tobler

On 28.12.16 19:24, Richard Biener wrote:

On December 27, 2016 11:17:00 PM GMT+01:00, Andreas Tobler 
<andreast-l...@fgznet.ch> wrote:

On 16.09.16 13:30, Richard Biener wrote:

On Thu, 15 Sep 2016, Richard Biener wrote:



This addresses sth I needed to address with the early LTO debug

patches

(you might now figure I'm piecemail merging stuff from that patch).

When the cgraph code optimizes out a global we call the

late_global_decl

debug hook to eventually add a DW_AT_const_value to its DIE (we

don't

really expect a location as that will be invalid after optimizing

out

and will be pruned).

With the early LTO debug patches I have introduced a

early_dwarf_finished

flag (mainly for consistency checking) and I figured I can use that

to

detect the call to the late hook during the early phase and provide
the following cleaned up variant of avoiding to create locations

that

require later pruning (which doesn't work with emitting the early

DIEs).


Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

I verified it does the correct thing for a unit like

static const int i = 2;

(but ISTR we do have at least one testcase in the testsuite as

well).


Will commit if testing finishes successfully.


Ok, so it showed issues when merging that back to early-LTO-debug.
Turns out in LTO we never call early_finish and thus

early_dwarf_finished

was never set.  Also dwarf2out_late_global_decl itself is a better
place to constrain generating locations.

The following variant is in very late stage of testing.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
LTO bootstrap on x86_64-unknown-linux-gnu in stage3.  LTO bootstrap
with early-LTO-debug in stage3, bootstraped with early-LTO-debug,
testing in progress.


Any chance to backport this commit (r240228) to 6.x?
It fixes a bootstrap comparison issue on aarch64-*-freebsd*.
The aarch64-*-freebsd* port is not yet merged to 6.x and 5.4.x due to
the bootstrap comparison failure I faced.


Did you analyze the bootstrap miscompare?  I suspect the patch merely papers 
over the problem.


gcc/contrib/compare-debug -p prev-gcc/ipa-icf.o gcc/ipa-icf.o
prev-gcc/ipa-icf.o.stripped. gcc/ipa-icf.o.stripped. differ: char 52841, 
line 253



The objdump -dSx diff on the non stripped object looked always more or 
less the same, a rodata offset which was different.


-   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x1d8
+   1448: R_AARCH64_ADD_ABS_LO12_NC .rodata+0x410


Was that regular bootstrap (with or without compare-debug)?


Hm, regular bootstrap, --with-build-config=bootstrap-debug?

Or do you have something else in mind?

I rerun on 6.x w/o 'patch' now. Hopefully in 12h I have something.

Btw, I bisected on trunk, r240227 was nok, the next, r240228 was ok. 
Then I took the part from r240228 to the 6.x branch and my comparison 
issue was gone.


If I miss something you need to know pls let me know.

TIA,
Andreas



Re: [PATCH] Fix late dwarf generated early from optimized out globals

2016-12-27 Thread Andreas Tobler

On 16.09.16 13:30, Richard Biener wrote:

On Thu, 15 Sep 2016, Richard Biener wrote:



This addresses sth I needed to address with the early LTO debug patches
(you might now figure I'm piecemail merging stuff from that patch).

When the cgraph code optimizes out a global we call the late_global_decl
debug hook to eventually add a DW_AT_const_value to its DIE (we don't
really expect a location as that will be invalid after optimizing out
and will be pruned).

With the early LTO debug patches I have introduced a early_dwarf_finished
flag (mainly for consistency checking) and I figured I can use that to
detect the call to the late hook during the early phase and provide
the following cleaned up variant of avoiding to create locations that
require later pruning (which doesn't work with emitting the early DIEs).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

I verified it does the correct thing for a unit like

static const int i = 2;

(but ISTR we do have at least one testcase in the testsuite as well).

Will commit if testing finishes successfully.


Ok, so it showed issues when merging that back to early-LTO-debug.
Turns out in LTO we never call early_finish and thus early_dwarf_finished
was never set.  Also dwarf2out_late_global_decl itself is a better
place to constrain generating locations.

The following variant is in very late stage of testing.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
LTO bootstrap on x86_64-unknown-linux-gnu in stage3.  LTO bootstrap
with early-LTO-debug in stage3, bootstraped with early-LTO-debug,
testing in progress.


Any chance to backport this commit (r240228) to 6.x?
It fixes a bootstrap comparison issue on aarch64-*-freebsd*.
The aarch64-*-freebsd* port is not yet merged to 6.x and 5.4.x due to 
the bootstrap comparison failure I faced.


I did a bootstrap with a backport of this revision to 6.x on 
amd64-*-freebsd* and I did not see any issues.


TIA,
Andreas


2016-09-16  Richard Biener  

* dwarf2out.c (early_dwarf_finished): New global.
(set_early_dwarf::set_early_dwarf): Assert early_dwarf_finished
is false.
(dwarf2out_early_finish): Set early_dwarf_finished at the end,
if called from LTO exit early.
(dwarf2out_late_global_decl): When being during the early
debug phase do not add locations but only const value attributes.
Adjust the way we generate early DIEs for LTO.

lto/
* lto.c (lto_main): Invoke early_finish debug hook.




Re: [PATCH/AARCH64] Improved -mcpu/mtune/march=native handling

2016-11-11 Thread Andreas Tobler

On 11.11.16 11:06, Richard Earnshaw wrote:

On 11/11/16 02:56, Andrew Pinski wrote:

As I mentioned in my other emails, parsing /proc/cpuinfo has one issue
is that the current parsing assumes many different things about the
format.  So the best way to do this is to parse
/sys/devices/system/cpu/cpuN/regs/identification/midr_el1 files
instead.  To get which cpu are present (though not necessarily online)
we parse "/sys/devices/system/cpu/present" file.  We fall back to
parsing /proc/cpu if any parsing fails of these files including not
finding out which cpu we are on.  The main reason why we fall back is
because only newer kernels support exporting this file.  To get the
features I just look at the hwcap that the kernel passes to userspace
so I needed to add an extra argument to AARCH64_OPT_EXTENSION.  I also
had to define some HWCAP_* macros in driver-aarch64.c since older
kernels headers don't have these values defined.

It should also be possible to parse
/sys/devices/system/cpu/cpu%d/cache%d directory to get cache
information too but that is left for another patch and another time.

Since I don't have access to a big.LITTLE system, someone should test
there with a new enough kernel; I was using stock 4.9.0-rc3.

OK?  Bootstrapped and tested on ThunderX on aarch64-linux-gnu with no
regressions and making sure /proc/cpuinfo is not read (by using
strace).

Thanks,
Andrew Pinski

ChangeLog:
* config/aarch64/aarch64-option-extensions.def: Document extra
argument to AARCH64_OPT_EXTENSION.  Update for the extra argument for
all of the option extensions.
* config/aarch64/driver-aarch64.c: Include sys/auxv.h and asm/hwcap.h.


GCC supports native builds on freebsd as well as linux.  Isn't this
going to break that?


It will.
Andreas


R.


(HWCAP_CRC32): Define if needed.
(HWCAP_ATOMICS): Likewise.
(HWCAP_FPHP): Likewise.
(HWCAP_ASIMDHP): Likewise.
(aarch64_arch_extension): New field hwcap_mask.
(AARCH64_OPT_EXTENSION): Handle extra argument.
(AARCH64_BIG_LITTLE): Always put the larger core number first.
(valid_bL_core_p): Don't check AARCH64_BIG_LITTLE for the opposite
order as it already handles the order.
(implementor_from_midr): New function.
(part_no_from_midr): New function.
(sysfsformat): New define.
(host_detect_local_cpu_sys): New function.
(host_detect_local_cpu): Call host_detect_local_cpu_sys if opening
"/sys/devices/system/cpu/present" file worked.
* common/config/aarch64/aarch64-common.c (AARCH64_OPT_EXTENSION):
Handle extra argument.








Re: [PATCH] Fix assembler arguments for -m16

2016-11-06 Thread Andreas Tobler

On 06.11.16 21:38, Uros Bizjak wrote:

On Sun, Nov 6, 2016 at 5:48 PM, Gerald Pfeifer  wrote:

It appears this got stuck.

Uros, is this okay?  I can handle the commit if you approve.


Looks good to me, so OK if tested on non-glibc system.



Results w/o patch:
https://gcc.gnu.org/ml/gcc-testresults/2016-11/msg00627.html

Results with patch:
https://gcc.gnu.org/ml/gcc-testresults/2016-11/msg00672.html

Andreas


Thanks,
Uros.


Gerald

On Wed, 6 Jul 2016, Roger Pau Monne wrote:

At the moment the -m16 option only passes the "--32" parameter to the
assembler on glibc OSes, while on other OSes the assembler is called without
any specific flag. This is wrong and causes the assembler to fail. Fix it
by adding support for the -m16 option to x86-64.h.

2016-07-06  Roger Pau Monné  

  * x86-64.h: append --32 to the assembler options when -m16 is used
  even on non-glibc OSes.

---
Cc: h...@gcc.gnu.org
Cc: ger...@freebsd.org
---
This should be backported to all stable branches up to 4.9 (when -m16 was
introduced).

Please keep me on Cc since I'm not subscribed to the list, thanks.
---
 gcc/config/i386/x86-64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h
index b0bf835..9e6c6eb 100644
--- a/gcc/config/i386/x86-64.h
+++ b/gcc/config/i386/x86-64.h
@@ -49,7 +49,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #define WCHAR_TYPE_SIZE 32

 #undef ASM_SPEC
-#define ASM_SPEC "%{m32:--32} %{m64:--64} %{mx32:--x32}"
+#define ASM_SPEC "%{m16|m32:--32} %{m64:--64} %{mx32:--x32}"

 #undef ASM_OUTPUT_ALIGNED_BSS
 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \






Re: [patch] aarch64-*-freebsd* support for gcc.

2016-10-12 Thread Andreas Tobler

Hi Jeff,

On 10.10.16 23:10, Jeff Law wrote:

On 10/10/2016 03:07 PM, Andreas Tobler wrote:

Hi all,

the attached patch brings support for the aarch64-*-freebsd* target.

Bootstraped and tested, results on the list. Not that many results due
to board instabilities I lack a cavium ;)

Ok for main? And if yes, how far can I backport? Down to 5.4?

TIA,
Andreas

libgcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host: Add support for aarch64-*-freebsd*.

gcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Add aarch64-*-freebsd* support.
* config.host: Likewise.
* config/aarch64/aarch64-freebsd.h: New file.
* config/aarch64/t-aarch64-freebsd: Ditto.

toplevel:

2016-10-10  Andreas Tobler <andre...@gcc.gnu.org>

* configure.ac: Add aarch64-*-freebsd*.
* configure: Regenerate.

Certainly OK for the trunk.  Jakub, Richi & Joseph make the rules for
the release branches.


I had a chat with Jakub and I learned as long as there is no branch 
freeze or such, every global reviewer can approve such a patch backport. 
So may I ask you, would you mind approving this patch for 6.x and 5.x?


TIA,
Andreas



Re: [patch] aarch64-*-freebsd* support for gcc.

2016-10-10 Thread Andreas Tobler

On 10.10.16 23:10, Jeff Law wrote:

On 10/10/2016 03:07 PM, Andreas Tobler wrote:

Hi all,

the attached patch brings support for the aarch64-*-freebsd* target.

Bootstraped and tested, results on the list. Not that many results due
to board instabilities I lack a cavium ;)

Ok for main? And if yes, how far can I backport? Down to 5.4?

TIA,
Andreas

libgcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host: Add support for aarch64-*-freebsd*.

gcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Add aarch64-*-freebsd* support.
* config.host: Likewise.
* config/aarch64/aarch64-freebsd.h: New file.
* config/aarch64/t-aarch64-freebsd: Ditto.

toplevel:

2016-10-10  Andreas Tobler <andre...@gcc.gnu.org>

* configure.ac: Add aarch64-*-freebsd*.
* configure: Regenerate.

Certainly OK for the trunk.  Jakub, Richi & Joseph make the rules for
the release branches.


Thank you again Jeff.

Committed to trunk with r240949.

Andreas



[patch] aarch64-*-freebsd* support for gcc.

2016-10-10 Thread Andreas Tobler

Hi all,

the attached patch brings support for the aarch64-*-freebsd* target.

Bootstraped and tested, results on the list. Not that many results due 
to board instabilities I lack a cavium ;)


Ok for main? And if yes, how far can I backport? Down to 5.4?

TIA,
Andreas

libgcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.host: Add support for aarch64-*-freebsd*.

gcc:

2016-10-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Add aarch64-*-freebsd* support.
* config.host: Likewise.
* config/aarch64/aarch64-freebsd.h: New file.
* config/aarch64/t-aarch64-freebsd: Ditto.

toplevel:

2016-10-10  Andreas Tobler <andre...@gcc.gnu.org>

* configure.ac: Add aarch64-*-freebsd*.
* configure: Regenerate.

Index: configure.ac
===
--- configure.ac(revision 240948)
+++ configure.ac(working copy)
@@ -727,6 +727,9 @@
   *-*-vxworks*)
 noconfigdirs="$noconfigdirs target-libffi"
 ;;
+  aarch64*-*-freebsd*)
+noconfigdirs="$noconfigdirs target-libffi"
+;;
   alpha*-*-*vms*)
 noconfigdirs="$noconfigdirs target-libffi"
 ;;
Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 240948)
+++ gcc/config.gcc  (working copy)
@@ -937,6 +937,11 @@
done
TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
;;
+aarch64*-*-freebsd*)
+   tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}"
+   tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-freebsd.h"
+   tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-freebsd"
+   ;;
 aarch64*-*-linux*)
tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-linux.h"
Index: gcc/config.host
===
--- gcc/config.host (revision 240948)
+++ gcc/config.host (working copy)
@@ -99,7 +99,7 @@
 esac
 
 case ${host} in
-  aarch64*-*-linux*)
+  aarch64*-*-freebsd* | aarch64*-*-linux*)
 case ${target} in
   aarch64*-*-*)
host_extra_gcc_objs="driver-aarch64.o"
Index: gcc/config/aarch64/aarch64-freebsd.h
===
--- gcc/config/aarch64/aarch64-freebsd.h(nonexistent)
+++ gcc/config/aarch64/aarch64-freebsd.h(working copy)
@@ -0,0 +1,94 @@
+/* Definitions for AArch64 running FreeBSD
+   Copyright (C) 2016 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_AARCH64_FREEBSD_H
+#define GCC_AARCH64_FREEBSD_H
+
+#undef  SUBTARGET_CPP_SPEC
+#define SUBTARGET_CPP_SPEC FBSD_CPP_SPEC
+
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define TARGET_LINKER_EMULATION  "aarch64fbsdb"
+#else
+#define TARGET_LINKER_EMULATION  "aarch64fbsd"
+#endif
+
+#undef  SUBTARGET_EXTRA_LINK_SPEC
+#define SUBTARGET_EXTRA_LINK_SPEC " -m" TARGET_LINKER_EMULATION
+
+#undef  FBSD_TARGET_LINK_SPEC
+#define FBSD_TARGET_LINK_SPEC " \
+%{p:%nconsider using `-pg' instead of `-p' with gprof (1) } \
+%{v:-V} \
+%{assert*} %{R*} %{rpath*} %{defsym*}   \
+%{shared:-Bshareable %{h*} %{soname*}}  \
+%{symbolic:-Bsymbolic}  \
+%{static:-Bstatic}  \
+%{!static:  \
+  %{rdynamic:-export-dynamic}   \
+  %{!shared:-dynamic-linker " FBSD_DYNAMIC_LINKER " }}  \
+-X" SUBTARGET_EXTRA_LINK_SPEC " \
+%{mbig-endian:-EB} %{mlittle-endian:-EL}"
+
+#if TARGET_FIX_ERR_A53_835769_DEFAULT
+#define CA53_ERR_835769_SPEC \
+  " %{!mno-fix-cortex-a53-835769:--fix-cortex-a53-835769}"
+#else
+#define CA53_ERR_835769_SPEC \
+  " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}"
+#endif
+
+#ifdef TARGET_FIX_ERR_A53_843419_DEFAULT

Re: [patch] FreeBSD armv6 unaligned access

2016-06-10 Thread Andreas Tobler

Hi Gerald,

On 10.06.16 22:26, Gerald Pfeifer wrote:


On Fri, 10 Jun 2016, Andreas Tobler wrote:

FreeBSD 11 will bring unaligned access support for armv6 and up.
This patch enables it.

If no objection I'll commit it to trunk, gcc-6 branch and gcc-5
branch in the next days.


As FreeBSD maintainer, you don't need to wait, though it is
considered good practice to first start on trunk and push back
to release branches after a few days (or weeks).

For a straightforward change like this I don't think that is
necessary, though.


I know. But I prefer to make my FreeBSD only patches available for 
comments to all before I commit. I could have done a commit to all 
branches w/o timed notice, just with the patch and CL.



2016-06-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/freebsd.h: Enable unaligned access for armv6 on
FreeBSD 11.


Two comments on this ChangeLog:  Right now all versions are enabled,
aren't they?  And this is not specific to FreeBSD 11, but 11 and above?


The first part I do not understand. The second part, sure, 11 and above.


So, how about the following variation?

* config/arm/freebsd.h: Only enable unaligned access for armv6
on FreeBSD 11 and above.


Np with me.

Thanks,
Andreas
Thanks,
Andreas


[patch] FreeBSD armv6 unaligned access

2016-06-10 Thread Andreas Tobler

Hi all,

FreeBSD 11 will bring unaligned access support for armv6 and up.
This patch enables it.

If no objection I'll commit it to trunk, gcc-6 branch and gcc-5 branch 
in the next days.


Thanks,
Andreas

2016-06-10  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/freebsd.h: Enable unaligned access for armv6 on
FreeBSD 11.
Index: config/arm/freebsd.h
===
--- config/arm/freebsd.h(revision 237314)
+++ config/arm/freebsd.h(working copy)
@@ -120,6 +120,9 @@
 #define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
 #endif
 
+/* FreeBSD 10 does not support unaligned access for armv6 and up.
+   Unaligned access support was added in FreeBSD 11.  */
+#if FBSD_MAJOR < 11
 #define SUBTARGET_OVERRIDE_INTERNAL_OPTIONS\
 do {   \
 if (opts_set->x_unaligned_access == 1) \
@@ -127,6 +130,7 @@
 if (opts->x_unaligned_access)  \
opts->x_unaligned_access = 0;   \
 } while (0)
+#endif
 
 #undef MAX_SYNC_LIBFUNC_SIZE
 #define MAX_SYNC_LIBFUNC_SIZE 4 /* UNITS_PER_WORD not defined yet.  */


Re: [patch] config.gcc FreeBSD ARM

2016-05-30 Thread Andreas Tobler

On 27.05.16 22:34, Andreas Tobler wrote:

Hi all,

The FreeBSD ARM people eliminated the extra armv6hf target and moved the
hardfloat 'functionality' into the armv6-*-freebsd11+ target.
This applies / will apply (FreeBSD11 is not released yet. Planned date
in September 16) to FreeBSD11. On FreeBSD10 armv6 still has only soft
float. The armv6hf is not life on FreeBSD10.

This simplifies life a bit.

I'll commit the attached patch to all the active branches. Regarding the
gcc-5 branch, do I have permission to apply?


Committed to trunk and gcc-6, waiting till gcc-5 is open again.

Andreas


2016-05-27  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Move hard float support for arm*hf*-*-freebsd* into
armv6*-*-freebsd* for FreeBSD11*. Eliminate the arm*hf*-*-freebsd*
target.

Index: config.gcc
===
--- config.gcc  (revision 236835)
+++ config.gcc  (working copy)
@@ -1058,13 +1058,11 @@
case $target in
armv6*-*-freebsd*)
tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
+if test $fbsd_major -ge 11; then
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+fi
;;
esac
-   case $target in
-   arm*hf-*-freebsd*)
-   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
-   ;;
-   esac
with_tls=${with_tls:-gnu}
;;
  arm*-*-netbsdelf*)





[patch] config.gcc FreeBSD ARM

2016-05-27 Thread Andreas Tobler

Hi all,

The FreeBSD ARM people eliminated the extra armv6hf target and moved the 
hardfloat 'functionality' into the armv6-*-freebsd11+ target.
This applies / will apply (FreeBSD11 is not released yet. Planned date 
in September 16) to FreeBSD11. On FreeBSD10 armv6 still has only soft 
float. The armv6hf is not life on FreeBSD10.


This simplifies life a bit.

I'll commit the attached patch to all the active branches. Regarding the 
gcc-5 branch, do I have permission to apply?


TIA,
Andreas

2016-05-27  Andreas Tobler  <andre...@gcc.gnu.org>

* config.gcc: Move hard float support for arm*hf*-*-freebsd* into
armv6*-*-freebsd* for FreeBSD11*. Eliminate the arm*hf*-*-freebsd*
target.

Index: config.gcc
===
--- config.gcc  (revision 236835)
+++ config.gcc  (working copy)
@@ -1058,13 +1058,11 @@
case $target in
armv6*-*-freebsd*)
tm_defines="${tm_defines} TARGET_FREEBSD_ARMv6=1"
+if test $fbsd_major -ge 11; then
+   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
+fi
;;
esac
-   case $target in
-   arm*hf-*-freebsd*)
-   tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1"
-   ;;
-   esac
with_tls=${with_tls:-gnu}
;;
 arm*-*-netbsdelf*)


[PATCH] bootstrap/69611

2016-02-03 Thread Andreas Tobler

Hi all,

this patch fixes bootstrap on FreeBSD PowerPC and hopefully all other 
PowerPC targets which do not have float128 support.


The patch itself is a bandaid to survive stage4. We have to come up with 
a better solution for FreeBSD and all other soft float targets which do 
not support float128.


The patch was tested by Michael Meissner on different POWER machines.

Ok to commit to trunk?

TIA,
Andreas

2016-02-03  Andreas Tobler  <andre...@gcc.gnu.org>

PR bootstrap/69611
* config/rs6000/sfp-machine.h: Guard __sfp_exceptions with
__FLOAT128__ to compile only for __float128 capable targets.

Index: config/rs6000/sfp-machine.h
===
--- config/rs6000/sfp-machine.h (revision 233109)
+++ config/rs6000/sfp-machine.h (working copy)
@@ -110,7 +110,7 @@
floating point on pre-ISA 3.0 machines without the IEEE 128-bit 
floating

point support.  */

-#ifndef __NO_FPRS__
+#ifdef __FLOAT128__
 #define ISA_BIT(x) (1LL << (63 - x))

 /* Use the same bits of the FPSCR.  */
@@ -151,7 +151,7 @@
   } while (0)

 # define FP_ROUNDMODE  (_fpscr & FP_RND_MASK)
-#endif /* !__NO_FPRS__ */
+#endif /* !__FLOAT128__ */

 /* Define ALIASNAME as a strong alias for NAME.  */
 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)


Re: [patch] libsanitizer

2016-01-14 Thread Andreas Tobler

On 13.01.16 18:39, Bernd Schmidt wrote:

On 01/11/2016 07:37 PM, Andreas Tobler wrote:


+# Do a configure time check for -ldl
+AC_CHECK_LIB(dl, dlsym,
+  [link_sanitizer_common="-lrt $link_sanitizer_common"])
+

I'll give it a test run.


If that works (with -ldl instead of -lrt) it's ok.


It does, tested on FreeBSD x86_64 and Linux/GNU x86_64.

Committed to trunk.

Note, there is a chunk in configure which is not from me.

It was a missing part from the last commit (r230739). There it was 
mentioned that configure was regenerated, but it did not get committed.


Thanks,
Andreas



Re: [patch] libsanitizer

2016-01-11 Thread Andreas Tobler

Hi Bernd,

On 11.01.16 19:28, Bernd Schmidt wrote:

On 11/10/2015 11:00 PM, Andreas Tobler wrote:

the attached patch removes the hard-coded requirement for the link
operation with -ldl. On FreeBSD we do not need that, it breaks compilation.


   # Common libraries that we need to link against for all sanitizer libs.
-link_sanitizer_common='-lpthread -ldl -lm'
+link_sanitizer_common='-lpthread -lm'

   # At least for glibc, shm_open is in librt.  But don't pull that
   # in if it still doesn't give us the function we want.  This
@@ -130,6 +130,12 @@
   # Other sanitizers do not override clock_* API
   ])

+# Do a configure time check for -ldl
+AC_CHECK_LIB(dl, dlsym,
+  [link_libasan="-ldl $link_libasan"
+link_libtsan="-ldl $link_libtsan"
+])
+


Why not add this to link_sanitizer_common, just after the similar check
for shm_open? I'm not entirely sure how libsanitizer is structured, but
I see references to dlsym inside the sanitizer_common directory.


Hm, looks simpler, yes.

@@ -104,6 +104,10 @@
 AC_CHECK_LIB(rt, shm_open,
   [link_sanitizer_common="-lrt $link_sanitizer_common"])

+# Do a configure time check for -ldl
+AC_CHECK_LIB(dl, dlsym,
+  [link_sanitizer_common="-lrt $link_sanitizer_common"])
+

I'll give it a test run.

Thanks,
Andreas



Re: [patch] libsanitizer

2016-01-11 Thread Andreas Tobler

On 11.01.16 19:57, Jakub Jelinek wrote:

On Mon, Jan 11, 2016 at 07:37:30PM +0100, Andreas Tobler wrote:

@@ -104,6 +104,10 @@
  AC_CHECK_LIB(rt, shm_open,
[link_sanitizer_common="-lrt $link_sanitizer_common"])

+# Do a configure time check for -ldl
+AC_CHECK_LIB(dl, dlsym,
+  [link_sanitizer_common="-lrt $link_sanitizer_common"])


s/-lrt/-ldl/, no?


Sicher, danke!
Andreas



Re: [patch] ARM FreeBSD fix bootstrap

2016-01-07 Thread Andreas Tobler

On 06.01.16 11:39, Richard Earnshaw (lists) wrote:

On 05/01/16 21:03, Andreas Tobler wrote:

On 05.01.16 11:32, Richard Earnshaw (lists) wrote:

On 23/12/15 19:28, Andreas Tobler wrote:



2015-12-23  Andreas Tobler  <andre...@gcc.gnu.org>

  * config/arm/freebsd.h: Rename SUBTARGET_OVERRIDE_OPTIONS to
  SUBTARGET_OVERRIDE_INTERNAL_OPTIONS. Adjust to check
  unaligned_access on the gcc_options set.
  * config/arm/arm.c (arm_option_override_internal): Use
  SUBTARGET_OVERRIDE_INTERNAL_OPTIONS.




This is OK.

One question, though, is whether you should explicitly override a user
request for unaligned accesses without at least warning that this is
being done.



Like this?

config/arm/freebsd.h:

#define SUBTARGET_OVERRIDE_INTERNAL_OPTIONS\
do {\
 if (opts_set->x_unaligned_access == 1)\
 warning (0, "target CPU does not support unaligned accesses");\
 if (opts->x_unaligned_access)\
 opts->x_unaligned_access = 0;



Something like that, but the problem is not that the CPU does not
support unaligned accesses, but that FreeBSD does not support CPUs doing
unaligned accesses.

Anyway, I'll pre-approve a patch adding a suitable warning here.


Done:
https://gcc.gnu.org/viewcvs/gcc?view=revision=232141

Thank you,
Andreas



Re: [patch] ARM FreeBSD fix bootstrap

2016-01-05 Thread Andreas Tobler

On 05.01.16 11:32, Richard Earnshaw (lists) wrote:

On 23/12/15 19:28, Andreas Tobler wrote:



2015-12-23  Andreas Tobler  <andre...@gcc.gnu.org>

 * config/arm/freebsd.h: Rename SUBTARGET_OVERRIDE_OPTIONS to
 SUBTARGET_OVERRIDE_INTERNAL_OPTIONS. Adjust to check
 unaligned_access on the gcc_options set.
 * config/arm/arm.c (arm_option_override_internal): Use
 SUBTARGET_OVERRIDE_INTERNAL_OPTIONS.




This is OK.

One question, though, is whether you should explicitly override a user
request for unaligned accesses without at least warning that this is
being done.



Like this?

config/arm/freebsd.h:

#define SUBTARGET_OVERRIDE_INTERNAL_OPTIONS \
do {\
if (opts_set->x_unaligned_access == 1)   \
warning (0, "target CPU does not support unaligned accesses");\
if (opts->x_unaligned_access)\
opts->x_unaligned_access = 0;

Thank you for the feedback.

Andreas 



Re: [patch] ARM FreeBSD fix bootstrap

2016-01-04 Thread Andreas Tobler

Ping :)

TIA,
Andreas

On 23.12.15 20:28, Andreas Tobler wrote:

On 23.12.15 11:22, Richard Earnshaw (lists) wrote:

On 22/12/15 19:53, Andreas Tobler wrote:

Hi all,

the commit for PR68617 broke boostrap on armv6*-*-freebsd*.

We still have unaligned_access = 0 on armv6 here on FreeBSD.

The commit from the above PR overrides my SUBTARGET_OVERRIDE_OPTIONS I
called in arm_option_override. And it sets the unaligned_access to 1.

The attached patch fixes this, bootstrap ongoing but passed the breaking
stage where genmddeps bus errored.

Is this patch ok for trunk once bootstrap completes?

TIA,
Andreas

2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

  * config/arm/freebsd.h (SUBTARGET_OVERRIDE_OPTIONS): Adjust to
  check unaligned_access on the gcc_options set.
  * config/arm/arm.c (arm_option_override): Move
  SUBTARGET_OVERRIDE_OPTIONS from here to
  (arm_option_override_internal).



Moving this hunk to a different place potentially affects VXWORKS (the
only other target that uses this hook).  I'd like to see confirmation
from the VxWorks maintainers (Nathan?) that this doesn't cause any
problems for them.  If it does, then I think you need to create a new
subtarget hook (SUBTARGET_OVERRIDE_INTERNAL_OPTIONS?) and change FreeBSD
to use that rather than the existing hook.


I noticed this morning that VxWorks might be affected. To be on the safe
side I'd like to propose the attached version since it makes clear where
the override belongs to and I don't think hijacking
SUBTARGET_OVERRIDE_OPTIONS is a good idea here.
I need the override in the arm_option_override_internal function after
the default has been set.

What do you think?

Thanks,

Andreas

2015-12-23  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/freebsd.h: Rename SUBTARGET_OVERRIDE_OPTIONS to
SUBTARGET_OVERRIDE_INTERNAL_OPTIONS. Adjust to check
unaligned_access on the gcc_options set.
* config/arm/arm.c (arm_option_override_internal): Use
SUBTARGET_OVERRIDE_INTERNAL_OPTIONS.





Re: [patch] Fix dynamic linker spec for FreeBSD powerpc64

2015-12-25 Thread Andreas Tobler

On 22.12.15 20:18, Andreas Tobler wrote:

Hi all,

The attached patch fixes a problem you get if you build dynamic binaries
for a 32-bit powerpc target on a 64-bit powerpc host.

At the time I did this port I didn't fully understand all the scenarios
you might run into.

The issue is this, on all FreeBSD archs the interpreter is ld-elf.so.1.
On powerpc64 we have also an ld-elf32.so.1 for 32-bit binaries. In case
we run a 32-bit binary on a 64-bit host the RTLD reroutes the call to
this ld-elf32.so.1.

Up to now this rerouting didn't happen since gcc used the ld-elf32.so.1
instead. The binary runs fine on the 64-bit host since the RTLD finds a
ld-elf32.so.1.

But now when I take this binary to a 32-bit host I can't run it since
the RTLD does not find the ld-elf32.so.1.

The patch fixes this and simplifies the LINK_OS_FREEBSD_SPEC_DEF for
FreeBSD powerpc64.

If there are no major objections I'm going to apply this patch to trunk,
gcc-5 and gcc-49 branch in the next days. It is FreeBSD powerpc64 only
and it is a bug.


Applied on the mentioned branches.

Andreas



2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

* config/rs6000/freebsd64.h: Delete FREEBSD_DYNAMIC_LINKER32/64
defines. Use FBSD_DYNAMIC_LINKER instead.
Rename and simplify LINK_OS_FREEBSD_SPEC_DEF32/64 to
LINK_OS_FREEBSD_SPEC_DEF.







Re: [patch] ARM FreeBSD fix bootstrap

2015-12-23 Thread Andreas Tobler

Hi Kyrill,

On 23.12.15 10:40, Kyrill Tkachov wrote:


On 22/12/15 19:53, Andreas Tobler wrote:

Hi all,

the commit for PR68617 broke boostrap on armv6*-*-freebsd*.

We still have unaligned_access = 0 on armv6 here on FreeBSD.

The commit from the above PR overrides my SUBTARGET_OVERRIDE_OPTIONS I called 
in arm_option_override. And it sets the unaligned_access to 1.

The attached patch fixes this, bootstrap ongoing but passed the breaking stage 
where genmddeps bus errored.

Is this patch ok for trunk once bootstrap completes?

TIA,
Andreas

2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

 * config/arm/freebsd.h (SUBTARGET_OVERRIDE_OPTIONS): Adjust to
 check unaligned_access on the gcc_options set.
 * config/arm/arm.c (arm_option_override): Move
 SUBTARGET_OVERRIDE_OPTIONS from here to
 (arm_option_override_internal).



This looks sensible to me with a couple of questions:

--- config/arm/freebsd.h(revision 231903)
+++ config/arm/freebsd.h(working copy)
@@ -122,8 +122,8 @@

   #define SUBTARGET_OVERRIDE_OPTIONS   \
   do { \
-if (unaligned_access)  \
-   unaligned_access = 0;   \
+if (opts->x_unaligned_access)   \
+   opts->x_unaligned_access = 0;\
   } while (0)

So FreeBSD doesn't have unaligned_access at all? Even for architecture 
revisions later than armv6?


No, not yet. We distinguish between arm(<armv6) armv6 and arm64.


Also, do you have access to an arm linux target? Would be nice to perform a 
bootstrap there as well
as a sanity check


I do not have linux target. But I think with my next iteration of the 
patch it is not possible to break any other target.



If that works then this patch is fine.


As Richard mentioned in a follow up mail there is an other user of 
SUBTARGET_OVERRIDE_OPTIONS. So I have to adjust. See the next mail.


Thanks,
Andreas



Re: [patch] ARM FreeBSD fix bootstrap

2015-12-23 Thread Andreas Tobler

On 23.12.15 11:22, Richard Earnshaw (lists) wrote:

On 22/12/15 19:53, Andreas Tobler wrote:

Hi all,

the commit for PR68617 broke boostrap on armv6*-*-freebsd*.

We still have unaligned_access = 0 on armv6 here on FreeBSD.

The commit from the above PR overrides my SUBTARGET_OVERRIDE_OPTIONS I
called in arm_option_override. And it sets the unaligned_access to 1.

The attached patch fixes this, bootstrap ongoing but passed the breaking
stage where genmddeps bus errored.

Is this patch ok for trunk once bootstrap completes?

TIA,
Andreas

2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

 * config/arm/freebsd.h (SUBTARGET_OVERRIDE_OPTIONS): Adjust to
 check unaligned_access on the gcc_options set.
 * config/arm/arm.c (arm_option_override): Move
 SUBTARGET_OVERRIDE_OPTIONS from here to
 (arm_option_override_internal).



Moving this hunk to a different place potentially affects VXWORKS (the
only other target that uses this hook).  I'd like to see confirmation
from the VxWorks maintainers (Nathan?) that this doesn't cause any
problems for them.  If it does, then I think you need to create a new
subtarget hook (SUBTARGET_OVERRIDE_INTERNAL_OPTIONS?) and change FreeBSD
to use that rather than the existing hook.


I noticed this morning that VxWorks might be affected. To be on the safe 
side I'd like to propose the attached version since it makes clear where 
the override belongs to and I don't think hijacking 
SUBTARGET_OVERRIDE_OPTIONS is a good idea here.
I need the override in the arm_option_override_internal function after 
the default has been set.


What do you think?

Thanks,

Andreas

2015-12-23  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/freebsd.h: Rename SUBTARGET_OVERRIDE_OPTIONS to
SUBTARGET_OVERRIDE_INTERNAL_OPTIONS. Adjust to check
unaligned_access on the gcc_options set.
* config/arm/arm.c (arm_option_override_internal): Use
SUBTARGET_OVERRIDE_INTERNAL_OPTIONS.






Index: freebsd.h
===
--- freebsd.h   (revision 231903)
+++ freebsd.h   (working copy)
@@ -120,10 +120,10 @@
 #define SUBTARGET_CPU_DEFAULT   TARGET_CPU_arm9
 #endif
 
-#define SUBTARGET_OVERRIDE_OPTIONS \
+#define SUBTARGET_OVERRIDE_INTERNAL_OPTIONS\
 do {   \
-if (unaligned_access)  \
-   unaligned_access = 0;   \
+if (opts->x_unaligned_access)  \
+   opts->x_unaligned_access = 0;   \
 } while (0)
 
 #undef MAX_SYNC_LIBFUNC_SIZE
Index: arm.c
===
--- arm.c   (revision 231903)
+++ arm.c   (working copy)
@@ -2954,6 +2954,10 @@
   /* Thumb2 inline assembly code should always use unified syntax.
  This will apply to ARM and Thumb1 eventually.  */
   opts->x_inline_asm_unified = TARGET_THUMB2_P (opts->x_target_flags);
+
+#ifdef SUBTARGET_OVERRIDE_INTERNAL_OPTIONS
+  SUBTARGET_OVERRIDE_INTERNAL_OPTIONS;
+#endif
 }
 
 /* Fix up any incompatible options that the user has specified.  */


[patch] ARM FreeBSD fix bootstrap

2015-12-22 Thread Andreas Tobler

Hi all,

the commit for PR68617 broke boostrap on armv6*-*-freebsd*.

We still have unaligned_access = 0 on armv6 here on FreeBSD.

The commit from the above PR overrides my SUBTARGET_OVERRIDE_OPTIONS I 
called in arm_option_override. And it sets the unaligned_access to 1.


The attached patch fixes this, bootstrap ongoing but passed the breaking 
stage where genmddeps bus errored.


Is this patch ok for trunk once bootstrap completes?

TIA,
Andreas

2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

* config/arm/freebsd.h (SUBTARGET_OVERRIDE_OPTIONS): Adjust to
check unaligned_access on the gcc_options set.
* config/arm/arm.c (arm_option_override): Move
SUBTARGET_OVERRIDE_OPTIONS from here to
(arm_option_override_internal).

Index: config/arm/freebsd.h
===
--- config/arm/freebsd.h(revision 231903)
+++ config/arm/freebsd.h(working copy)
@@ -122,8 +122,8 @@
 
 #define SUBTARGET_OVERRIDE_OPTIONS \
 do {   \
-if (unaligned_access)  \
-   unaligned_access = 0;   \
+if (opts->x_unaligned_access)  \
+   opts->x_unaligned_access = 0;   \
 } while (0)
 
 #undef MAX_SYNC_LIBFUNC_SIZE
Index: config/arm/arm.c
===
--- config/arm/arm.c(revision 231903)
+++ config/arm/arm.c(working copy)
@@ -2954,6 +2954,10 @@
   /* Thumb2 inline assembly code should always use unified syntax.
  This will apply to ARM and Thumb1 eventually.  */
   opts->x_inline_asm_unified = TARGET_THUMB2_P (opts->x_target_flags);
+
+#ifdef SUBTARGET_OVERRIDE_OPTIONS
+  SUBTARGET_OVERRIDE_OPTIONS;
+#endif
 }
 
 /* Fix up any incompatible options that the user has specified.  */
@@ -2976,10 +2980,6 @@
   if (global_options_set.x_arm_tune_option)
 arm_selected_tune = _cores[(int) arm_tune_option];
 
-#ifdef SUBTARGET_OVERRIDE_OPTIONS
-  SUBTARGET_OVERRIDE_OPTIONS;
-#endif
-
   if (arm_selected_arch)
 {
   if (arm_selected_cpu)


[patch] Fix dynamic linker spec for FreeBSD powerpc64

2015-12-22 Thread Andreas Tobler

Hi all,

The attached patch fixes a problem you get if you build dynamic binaries 
for a 32-bit powerpc target on a 64-bit powerpc host.


At the time I did this port I didn't fully understand all the scenarios 
you might run into.


The issue is this, on all FreeBSD archs the interpreter is ld-elf.so.1.
On powerpc64 we have also an ld-elf32.so.1 for 32-bit binaries. In case 
we run a 32-bit binary on a 64-bit host the RTLD reroutes the call to 
this ld-elf32.so.1.


Up to now this rerouting didn't happen since gcc used the ld-elf32.so.1 
instead. The binary runs fine on the 64-bit host since the RTLD finds a 
ld-elf32.so.1.


But now when I take this binary to a 32-bit host I can't run it since 
the RTLD does not find the ld-elf32.so.1.


The patch fixes this and simplifies the LINK_OS_FREEBSD_SPEC_DEF for 
FreeBSD powerpc64.


If there are no major objections I'm going to apply this patch to trunk, 
gcc-5 and gcc-49 branch in the next days. It is FreeBSD powerpc64 only 
and it is a bug.


Thanks,
Andreas

2015-12-22  Andreas Tobler  <andre...@gcc.gnu.org>

* config/rs6000/freebsd64.h: Delete FREEBSD_DYNAMIC_LINKER32/64
defines. Use FBSD_DYNAMIC_LINKER instead.
Rename and simplify LINK_OS_FREEBSD_SPEC_DEF32/64 to
LINK_OS_FREEBSD_SPEC_DEF.



Index: freebsd64.h
===
--- freebsd64.h (revision 231662)
+++ freebsd64.h (working copy)
@@ -167,10 +167,7 @@
   { "link_os_freebsd_spec32",  LINK_OS_FREEBSD_SPEC32 },   \
   { "link_os_freebsd_spec64",  LINK_OS_FREEBSD_SPEC64 },
 
-#define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1"
-#define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1"
-
-#define LINK_OS_FREEBSD_SPEC_DEF32 "\
+#define LINK_OS_FREEBSD_SPEC_DEF "\
   %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
   %{v:-V} \
   %{assert*} %{R*} %{rpath*} %{defsym*} \
@@ -178,25 +175,13 @@
   %{!shared: \
 %{!static: \
   %{rdynamic: -export-dynamic} \
-  %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER32 "}} \
+  %{!dynamic-linker:-dynamic-linker " FBSD_DYNAMIC_LINKER "}} \
 %{static:-Bstatic}} \
   %{symbolic:-Bsymbolic}"
 
-#define LINK_OS_FREEBSD_SPEC_DEF64 "\
-  %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
-  %{v:-V} \
-  %{assert*} %{R*} %{rpath*} %{defsym*} \
-  %{shared:-Bshareable %{h*} %{soname*}} \
-  %{!shared: \
-%{!static: \
-  %{rdynamic: -export-dynamic} \
-  %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER64 "}} \
-%{static:-Bstatic}} \
-  %{symbolic:-Bsymbolic}"
-
-#define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF32
+#define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF
   
-#define LINK_OS_FREEBSD_SPEC64 "-melf64ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF64
+#define LINK_OS_FREEBSD_SPEC64 "-melf64ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF
 
 #undef MULTILIB_DEFAULTS
 #define MULTILIB_DEFAULTS { "m64" }


Re: [patch] remove WCHAR_TYPE definition for FreeBSD PowerPC64

2015-12-09 Thread Andreas Tobler

On 06.12.15 23:54, Andreas Tobler wrote:

Hi,

I'm going to commit this patch to trunk, 5.4 and 4.9 branch if there are
no objections.

The redefinition of WCHAR_TYPE for PowerPC64 is wrong since its
beginning. My fault.

We use the definition from freebsd.h.



Committed to trunk. But I left the #undef WCHAR_TYPE. I deleted to fast..

For the diff see:

https://gcc.gnu.org/ml/gcc-cvs/2015-12/msg00379.html

I'll apply the same fix later to gcc-5 and gcc-4.9 tree.

Andreas


2015-12-06  Andreas Tobler  <andre...@gcc.gnu.org>

* config/rs6000/freebsd64.h: Remove the redefinition of WCHAR_TYPE.

Index: freebsd64.h
===
--- freebsd64.h (revision 231129)
+++ freebsd64.h (working copy)
@@ -316,8 +316,6 @@
   #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")

   /* rs6000.h gets this wrong for FreeBSD.  We use the GCC defaults
instead.  */
-#undef WCHAR_TYPE
-#defineWCHAR_TYPE  (TARGET_64BIT ? "int" : "long int")
   #undef  WCHAR_TYPE_SIZE
   #define WCHAR_TYPE_SIZE 32





[patch] remove WCHAR_TYPE definition for FreeBSD PowerPC64

2015-12-06 Thread Andreas Tobler

Hi,

I'm going to commit this patch to trunk, 5.4 and 4.9 branch if there are 
no objections.


The redefinition of WCHAR_TYPE for PowerPC64 is wrong since its 
beginning. My fault.


We use the definition from freebsd.h.

Thanks,
Andreas

2015-12-06  Andreas Tobler  <andre...@gcc.gnu.org>

* config/rs6000/freebsd64.h: Remove the redefinition of WCHAR_TYPE.

Index: freebsd64.h
===
--- freebsd64.h (revision 231129)
+++ freebsd64.h (working copy)
@@ -316,8 +316,6 @@
 #define PTRDIFF_TYPE   (TARGET_64BIT ? "long int" : "int")

 /* rs6000.h gets this wrong for FreeBSD.  We use the GCC defaults 
instead.  */

-#undef WCHAR_TYPE
-#defineWCHAR_TYPE  (TARGET_64BIT ? "int" : "long int")
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32



Re: [patch] add ELFv2 check to FreeBSD PowerPC64

2015-12-04 Thread Andreas Tobler

On 01.12.15 22:47, Andreas Tobler wrote:

On 29.11.15 22:15, Andreas Tobler wrote:

Hi all,

I'd like to commit this patch to trunk.

It is FreeBSD only.

If nobody objects I'll commit it within two days.

Thanks,

Andreas

2015-11-29  Andreas Tobler  <andre...@gcc.gnu.org>

* config/rs6000/freebsd64.h (ELFv2_ABI_CHECK): Add new macro.
(SUBSUBTARGET_OVERRIDE_OPTIONS): Use it to decide whether to set
rs6000_current_abi to ABI_AIX or ABI_ELFv2.




Committed to trunk. I'll wait till gcc5 opens again and then I'll
backport to gcc5 and gcc49.


Done with 231302 and 231306.

Andreas



Re: [PATCH] fix PR65726

2015-12-04 Thread Andreas Tobler

On 01.12.15 22:55, Jeff Law wrote:

On 12/01/2015 02:50 PM, Andreas Tobler wrote:

On 30.11.15 23:30, Jeff Law wrote:

On 11/26/2015 11:49 AM, Andreas Tobler wrote:

Hi all,

the attached patch fixes the build issue from this ticket if bootstrap
is disabled.

Tested on x86_64-*-linux* and on x86_64-*-freebsd* with gcc and clang.

Ok for trunk?

And 5.3?

Thanks,
Andreas

2015-11-26  Andreas Tobler  <andre...@gcc.gnu.org>

   PR libffi/65726
   * Makefile.def (lang_env_dependencies): Make libffi depend
   on cxx.
   * Makefile.in: Regenerate.


OK.



Thanks!

Committed to trunk. I'll wait till gcc5 opens again and then I commit to
gcc5 and gcc49, ok?

Seems reasonable.



Thank you!

PR closed.

Andreas



Re: [patch] RFC asan support for i?86/x86_64-*freebsd*

2015-12-01 Thread Andreas Tobler

Hi!

On 01.12.15 13:22, Uros Bizjak wrote:


2015-11-29  Andreas Tobler  <andre...@gcc.gnu.org>

* config/i386/i386.h: Define two new macros:
SUBTARGET_SHADOW_OFFSET_64 and SUBTARGET_SHADOW_OFFSET_32.
* config/i386/i386.c (ix86_asan_shadow_offset): Use these macros.
* config/i386/darwin.h: Override the SUBTARGET_SHADOW_OFFSET_64
macro.
* config/i386/freebsd.h: Override the SUBTARGET_SHADOW_OFFSET_64
and the SUBTARGET_SHADOW_OFFSET_32 macro.
* config/freebsd.h (LIBASAN_EARLY_SPEC): Define.
(LIBTSAN_EARLY_SPEC): Likewise.
(LIBLSAN_EARLY_SPEC): Likewise.


IMO, there is no compelling reason for _64 and _32 subtargets split,
especially since it depends on TARGET_LP64, not on the usual
TARGET_64BIT. Due to this, I'd rather introduce only
TARGET_SHADOW_OFFSET, like:

#define TARGET_SHADOW_OFFSET \
   (TARGET_LP64 ? HOST_WIDE_INT_C (0x7fff8000) : HOST_WIDE_INT_1 << 29)

(and similar for other targets).


Thank you for the feedback. I put your suggestion into my local tree and 
the results are equal. Thanks, diff reduced :)


Andreas



  1   2   3   >