[PATCH] dec_math.f90 needs to be xfailed

2021-01-02 Thread Steve Kargl via Gcc-patches
Can someone, anyone, please commit the following trivially patch?
gfortran.dg/dec_math.f90 will never pass on i?86-*-freebsd*.

diff --git a/gcc/testsuite/gfortran.dg/dec_math.f90 
b/gcc/testsuite/gfortran.dg/dec_math.f90
index cc141aba412..d95233a5169 100644
--- a/gcc/testsuite/gfortran.dg/dec_math.f90
+++ b/gcc/testsuite/gfortran.dg/dec_math.f90
@@ -1,5 +1,5 @@
 ! { dg-options "-cpp -std=gnu" }
-! { dg-do run }
+! { dg-do run { xfail i?86-*-freebsd* } }
 !
 ! Test extra math intrinsics formerly offered by -fdec-math,
 ! now included with -std=gnu or -std=legacy.

-- 
Steve


Re: libgo patch committed: Update to Go1.16beta1 release

2021-01-02 Thread Matthias Klose
On 1/2/21 12:11 AM, Ian Lance Taylor wrote:
> On Thu, Dec 31, 2020 at 7:40 AM Matthias Klose  wrote:
>>
>> On 12/31/20 12:14 AM, Ian Lance Taylor via Gcc-patches wrote:
>>> I've committed a patch to update libgo to the Go 1.16beta1 release.
>>>
>>> This patch does not include support for the new //go:embed directive
>>> that will be available in Go 1.16.1 (https://golang.org/issue/41191)
>>> Support for that requires compiler changes, which will come later.
>>>
>>> As usual with these big updates, I have not included the complete
>>> changes in this e-mail message, only changes that are gccgo-specific.
>>>
>>> Testing this requires some changes to gotools.
>>>
>>> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
>>> to mainline.
>>
>> also breaks the s390x 32bit multilib build (s390).
>>
>> ../../../../src/libgo/go/internal/cpu/cpu.go:123:9: error: reference to
>> undefined name 'doinit'
>>   123 | doinit()
>>   | ^
> 
> The problems building the internal/cpu and golang.org/x/sys/cpu
> packages on less common architectures should be fixed by this patch.
> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
> to mainline.

still ftbfs on power*, tested with a multilib build on powerpc64-linux-gnu.
patch attached, didn't check on aix.

../../../src/libgo/go/internal/cpu/cpu.go:123:9: error: reference to undefined
name 'doinit'
  123 | doinit()
  | ^


../../../src/libgo/go/internal/cpu/cpu_ppc64x_linux.go:26:26: error: reference
to undefined name 'isSet'
   26 | PPC64.IsPOWER9 = isSet(HWCap2, hwcap2_ARCH_3_00)
  |  ^
../../../src/libgo/go/internal/cpu/cpu_ppc64x_linux.go:27:25: error: reference
to undefined name 'isSet'
   27 | PPC64.HasDARN = isSet(HWCap2, hwcap2_DARN)
  | ^
../../../src/libgo/go/internal/cpu/cpu_ppc64x_linux.go:28:24: error: reference
to undefined name 'isSet'
   28 | PPC64.HasSCV = isSet(HWCap2, hwcap2_SCV)
  |^


Matthias
--- a/libgo/go/internal/cpu/cpu_ppc64x_aix.go
+++ b/libgo/go/internal/cpu/cpu_ppc64x_aix.go
@@ -12,10 +12,14 @@ const (
 	_IMPL_POWER9 = 0x2
 )
 
-func osinit() {
+func doinit() {
 	impl := getsystemcfg(_SC_IMPL)
 	PPC64.IsPOWER9 = isSet(impl, _IMPL_POWER9)
 }
 
+func isSet(hwc uint, value uint) bool {
+return hwc&value != 0
+}
+
 // getsystemcfg is defined in runtime/os2_aix.go
 func getsystemcfg(label uint) uint
--- a/libgo/go/internal/cpu/cpu_ppc64x_linux.go
+++ b/libgo/go/internal/cpu/cpu_ppc64x_linux.go
@@ -22,8 +22,12 @@ const (
 	hwcap2_SCV  = 0x0010
 )
 
-func osinit() {
+func doinit() {
 	PPC64.IsPOWER9 = isSet(HWCap2, hwcap2_ARCH_3_00)
 	PPC64.HasDARN = isSet(HWCap2, hwcap2_DARN)
 	PPC64.HasSCV = isSet(HWCap2, hwcap2_SCV)
 }
+
+func isSet(hwc uint, value uint) bool {
+return hwc&value != 0
+}


Re: V3 [PATCH 0/5] Support the PGO build for binutils+gdb

2021-01-02 Thread Segher Boessenkool
On Sat, Dec 19, 2020 at 10:10:31AM -0800, H.J. Lu via Gcc-patches wrote:
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:
> 
> 1. First build with -fprofile-generate.
> 2. Use "make maybe-check-*" to generate profiling data and pass -i to make
> to ignore errors when generating profiling data.
> 3. Use "make clean" to remove the previous build.
> 4. Rebuild with -fprofile-use.

Can this not use --with-build-config=?  As the user interface I mean,
you probably still need most of this code, but at least it will be more
obvious how to handle conflicts in user-specified options.


Segher


Re: V3 [PATCH 0/5] Support the PGO build for binutils+gdb

2021-01-02 Thread H.J. Lu via Gcc-patches
On Sat, Jan 2, 2021 at 11:24 AM Segher Boessenkool
 wrote:
>
> On Sat, Dec 19, 2020 at 10:10:31AM -0800, H.J. Lu via Gcc-patches wrote:
> > Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> > is not built together with GCC, --enable-pgo-build enables the PGO build:
> >
> > 1. First build with -fprofile-generate.
> > 2. Use "make maybe-check-*" to generate profiling data and pass -i to make
> > to ignore errors when generating profiling data.
> > 3. Use "make clean" to remove the previous build.
> > 4. Rebuild with -fprofile-use.
>
> Can this not use --with-build-config=?  As the user interface I mean,
> you probably still need most of this code, but at least it will be more
> obvious how to handle conflicts in user-specified options.
>
>
> Segher

--with-build-config= is more or less for bootstrapping GCC.   In case
of binutils, we don't build GCC.  We only train GCC with binutils/GDB
testsuites.

-- 
H.J.


[pushed] Darwin : Adjust defaults for current bootstrap constraints.

2021-01-02 Thread Iain Sandoe
Hi,

Part of fixing up headers to handle Darwin20.

The toolchain now requires a C++11 compiler to bootstrap and
none of the older Darwin toolchains which were based on stabs
debugging are suitable.  We can simplify the debug setup now.

tested on darwin8, 9, 16, 18, 20 x86_64-linux-gnu
pushed to master
thanks
Iain

gcc/ChangeLog:

* config/darwin.h (DSYMUTIL_SPEC): Default to DWARF
(ASM_DEBUG_SPEC):Only define if the assembler supports
stabs.
(PREFERRED_DEBUGGING_TYPE): Default to DWARF.
(DARWIN_PREFER_DWARF): Define.
* config/darwin9.h (PREFERRED_DEBUGGING_TYPE): Remove.
(DARWIN_PREFER_DWARF): Likewise
(DSYMUTIL_SPEC): Likewise.
(COLLECT_RUN_DSYMUTIL): Likewise.
(ASM_DEBUG_SPEC): Likewise.
(ASM_DEBUG_OPTION_SPEC): Likewise.
---
 gcc/config/darwin.h  | 37 ++---
 gcc/config/darwin9.h | 26 --
 2 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index da40a08443e..93e7796e850 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -241,12 +241,18 @@ extern GTY(()) int darwin_ms_struct;
 
 #define DSYMUTIL "\ndsymutil"
 
+/* Spec that controls whether the debug linker is run automatically for
+   a link step.  This needs to be done if there is a source file on the
+   command line which will result in a temporary object (and debug is
+   enabled).  */
+
 #define DSYMUTIL_SPEC \
"%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
 %{v} \
-%{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\
-%{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \
-%{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}"
+%{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\
+%{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\
+  .f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \
+%{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}"
 
 #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC
 
@@ -472,22 +478,31 @@ extern GTY(()) int darwin_ms_struct;
   %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
   %{static}" ASM_MMACOSX_VERSION_MIN_SPEC
 
-/* Default ASM_DEBUG_SPEC.  Darwin's as cannot currently produce dwarf
-   debugging data.  */
-
+#ifdef HAVE_AS_STABS_DIRECTIVE
+/* We only pass a debug option to the assembler if that supports stabs, since
+   dwarf is not uniformly supported in the assemblers.  */
 #define ASM_DEBUG_SPEC  "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}"
-#define ASM_DEBUG_OPTION_SPEC ""
+#else
+#define ASM_DEBUG_SPEC  ""
+#endif
+
+#undef  ASM_DEBUG_OPTION_SPEC
+#define ASM_DEBUG_OPTION_SPEC  ""
+
 #define ASM_FINAL_SPEC \
   "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} 
%http://www.gnu.org/licenses/>.  */
 
-/* Prefer DWARF2.  */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-#define DARWIN_PREFER_DWARF
-
-/* Since DWARF2 is default, conditions for running dsymutil are different.  */
-#undef DSYMUTIL_SPEC
-#define DSYMUTIL_SPEC \
-   "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
-%{v} \
-%{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\
-
%{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|.f95|.f03|.f77|.for|.F|.F90|.F95|.F03:
 \
-%{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}"
-
-/* Tell collect2 to run dsymutil for us as necessary.  */
-#define COLLECT_RUN_DSYMUTIL 1
-
-/* Only ask as for debug data if the debug style is stabs (since as doesn't
-   yet generate dwarf.)  */
-
-#undef  ASM_DEBUG_SPEC
-#define ASM_DEBUG_SPEC  "%{g*:%{%:debug-level-gt(0):%{gstabs:--gstabs}}}"
-
-#undef  ASM_DEBUG_OPTION_SPEC
-#define ASM_DEBUG_OPTION_SPEC  ""
-
 #undef  ASM_OUTPUT_ALIGNED_COMMON
 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
   do { \
-- 
2.24.1




[pushed] Darwin, Simplify headers 0/5 : Move spec for Darwin 10 unwind stub [NFC].

2021-01-02 Thread Iain Sandoe
Hi,

The darwinN.h headers were (presumably) introduced to allow specs to be
adjusted when there was no mmacosx-version-min handling, or that was
considered unreliable.

We have version-specific specs for the values that have configuration
data, and the version is set in the driver (so may be considered
reliably present).

Some of the 'darwinN.h' content has become dead code, and the reminder
is either conditionalised on version information (or is setting values
used as fall-backs in cross-compilations).

With the changes needed for Darwin20 / macOS 11 the 'darwnN.h' headers
are now too unwieldy to be useful - so this series moves the relevant
specs definitons to the common 'darwin.h' header and then finally uses
the config.gcc script to supply the fall-back defaults for cross-
compilations.

We can then delete all but the main header, since the darwinN.h are
unused.

This change moves a spec from darwin10.h to the main darwin.h
target header.

tested on darwin8, 9, 16, 19, 20, x86_64-linux-gnu
pushed,
thanks
Iain


gcc/ChangeLog:

* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move the spec
for the Darwin10 unwinder stub from here ...
* config/darwin.h (LINK_COMMAND_SPEC_A): ... to here.
---
 gcc/config/darwin.h   | 1 +
 gcc/config/darwin10.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 93e7796e850..a3b439487e8 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -230,6 +230,7 @@ extern GTY(()) int darwin_ms_struct;
   %{%:sanitize(address): -lasan } \
   %{%:sanitize(undefined): -lubsan } \
   %(link_ssp) \
+  %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef.o) \
   %(link_gcc_c_sequence) \
 }}}\
 %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} %{F*} "\
diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h
index d1a33a3017e..f1395954453 100644
--- a/gcc/config/darwin10.h
+++ b/gcc/config/darwin10.h
@@ -24,7 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_GCC_C_SEQUENCE_SPEC \
 "%{!static:%{!static-libgcc: \
 %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
- %{!nostdlib:%:version-compare(>< 10.6 10.7 mmacosx-version-min= 
-ld10-uwfef.o)} \
   %G %{!nolibc:%L}"
 
 #undef DEF_MIN_OSX_VERSION
-- 
2.24.1



[pushed] Darwin, Simplify headers 1/5 : Move LINK_GCC_C_SEQUENCE_SPEC [NFC].

2021-01-02 Thread Iain Sandoe
Hi,

There is no need to make the LINK_GCC_C_SEQUENCE_SPEC conditional on
configuration parameters, it is adequately conditionalized on the
macosx-version-min.

tested as per part 0,
pushed to master
Iain

gcc/ChangeLog:

* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move from
here...
* config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): ... to here.
---
 gcc/config/darwin.h   | 10 +++---
 gcc/config/darwin10.h |  8 
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index a3b439487e8..524a9c9e170 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -260,10 +260,14 @@ extern GTY(()) int darwin_ms_struct;
 /* Tell collect2 to run dsymutil for us as necessary.  */
 #define COLLECT_RUN_DSYMUTIL 1
 
-/* We only want one instance of %G, since libSystem (Darwin's -lc) does not 
depend
-   on libgcc.  */
+/* Fix PR47558 by linking against libSystem ahead of libgcc. See also
+   PR 80556 and the fallout from this.  */
+
 #undef  LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L}"
+#define LINK_GCC_C_SEQUENCE_SPEC \
+"%{!static:%{!static-libgcc: \
+%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
+  %G %{!nolibc:%L}"
 
 /* ld64 supports a sysroot, it just has a different name and there's no easy
way to check for it at config time.  */
diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h
index f1395954453..88b1fd061bb 100644
--- a/gcc/config/darwin10.h
+++ b/gcc/config/darwin10.h
@@ -18,14 +18,6 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 .  */
 
-/* Fix PR47558 by linking against libSystem ahead of libgcc_ext. */
-
-#undef  LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC \
-"%{!static:%{!static-libgcc: \
-%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
-  %G %{!nolibc:%L}"
-
 #undef DEF_MIN_OSX_VERSION
 #define DEF_MIN_OSX_VERSION "10.6"
 
-- 
2.24.1




[pushed] Darwin, Simplify headers 1/5 : Move LINK_GCC_C_SEQUENCE_SPEC [NFC].

2021-01-02 Thread Iain Sandoe
Hi

There is no need to make the LINK_GCC_C_SEQUENCE_SPEC conditional on
configuration parameters, it is adequately conditionalized on the
macosx-version-min.

tested as per pwert 0,
pushed to master
Iain

gcc/ChangeLog:

* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move from
here...
* config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): ... to here.
---
 gcc/config/darwin.h   | 10 +++---
 gcc/config/darwin10.h |  8 
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index a3b439487e8..524a9c9e170 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -260,10 +260,14 @@ extern GTY(()) int darwin_ms_struct;
 /* Tell collect2 to run dsymutil for us as necessary.  */
 #define COLLECT_RUN_DSYMUTIL 1
 
-/* We only want one instance of %G, since libSystem (Darwin's -lc) does not 
depend
-   on libgcc.  */
+/* Fix PR47558 by linking against libSystem ahead of libgcc. See also
+   PR 80556 and the fallout from this.  */
+
 #undef  LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L}"
+#define LINK_GCC_C_SEQUENCE_SPEC \
+"%{!static:%{!static-libgcc: \
+%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
+  %G %{!nolibc:%L}"
 
 /* ld64 supports a sysroot, it just has a different name and there's no easy
way to check for it at config time.  */
diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h
index f1395954453..88b1fd061bb 100644
--- a/gcc/config/darwin10.h
+++ b/gcc/config/darwin10.h
@@ -18,14 +18,6 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 .  */
 
-/* Fix PR47558 by linking against libSystem ahead of libgcc_ext. */
-
-#undef  LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC \
-"%{!static:%{!static-libgcc: \
-%:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
-  %G %{!nolibc:%L}"
-
 #undef DEF_MIN_OSX_VERSION
 #define DEF_MIN_OSX_VERSION "10.6"
 
-- 
2.24.1



[pushed] Darwin, Simplify headers 2/5 : Move spec for STACK_CHECK_STATIC_BUILTIN.

2021-01-02 Thread Iain Sandoe
Hi

We now need a modern (C++11) toolchain to bootstrap GCC, so there's no
need to skip the stack protect for Darwin < 9.

tested as per part 0,
pushed to master
Iain

gcc/ChangeLog:

* config/darwin9.h (STACK_CHECK_STATIC_BUILTIN): Move from here..
* config/darwin.h (STACK_CHECK_STATIC_BUILTIN): .. to here.
---
 gcc/config/darwin.h  | 3 +++
 gcc/config/darwin9.h | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 524a9c9e170..0eabd3f19eb 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1080,6 +1080,9 @@ extern void darwin_driver_init (unsigned int *,struct 
cl_decoded_option **);
 #undef SUPPORTS_INIT_PRIORITY
 #define SUPPORTS_INIT_PRIORITY 0
 
+#undef STACK_CHECK_STATIC_BUILTIN
+#define STACK_CHECK_STATIC_BUILTIN 1
+
 /* When building cross-compilers (and native crosses) we shall default to 
providing an osx-version-min of this unless overridden by the User.
10.5 is the only version that fully supports all our archs so that's the
diff --git a/gcc/config/darwin9.h b/gcc/config/darwin9.h
index 6576d386c12..125a35e7fc7 100644
--- a/gcc/config/darwin9.h
+++ b/gcc/config/darwin9.h
@@ -31,6 +31,3 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef DEF_MIN_OSX_VERSION
 #define DEF_MIN_OSX_VERSION "10.5"
-
-#undef STACK_CHECK_STATIC_BUILTIN
-#define STACK_CHECK_STATIC_BUILTIN 1
-- 
2.24.1




[pushed] Darwin, Simplify headers 3/5 : Delete dead code.

2021-01-02 Thread Iain Sandoe
Hi,

Darwin defines ASM_OUTPUT_ALIGNED_DECL_COMMON which is used in
preference to ASM_OUTPUT_ALIGNED_COMMON, which makes the latter
definition dead code.  Remove this.

tested as part 0
pushed to master
Iain

gcc/ChangeLog:

* config/darwin9.h (ASM_OUTPUT_ALIGNED_COMMON): Delete.
---
gcc/config/darwin9.h | 11 ---
1 file changed, 11 deletions(-)

diff --git a/gcc/config/darwin9.h b/gcc/config/darwin9.h
index 125a35e7fc7..92a77eeec71 100644
--- a/gcc/config/darwin9.h
+++ b/gcc/config/darwin9.h
@@ -18,16 +18,5 @@ You should have received a copy of the GNU General Public 
License
along with GCC; see the file COPYING3.  If not see
.  */
-#undef  ASM_OUTPUT_ALIGNED_COMMON
-#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
-  do { \
-unsigned HOST_WIDE_INT _new_size = (SIZE); \
-fprintf ((FILE), "\t.comm ");  
\
-assemble_name ((FILE), (NAME));\
-if (_new_size == 0) _new_size = 1; \
-fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
-_new_size, floor_log2 ((ALIGN) / BITS_PER_UNIT));  \
-  } while (0)
-
#undef DEF_MIN_OSX_VERSION
#define DEF_MIN_OSX_VERSION "10.5"
-- 
2.24.1




[pushed] Darwin, Simplify headers 4/5 : Remove redundant headers.

2021-01-02 Thread Iain Sandoe
Hi

The darwinN.h headers (with the sole exception of darwin7.h,
which contains a target macro definition) now only contain
values that set fall-backs for cross-compilations, these can
be provided from the config.gcc script which means we no longer
need the darwinN.h - so delete them.

tested as per part0,
pushed to master
Iain

gcc/ChangeLog:

* config.gcc: Compute default version information
from the configured target.  Likewise defaults for
ld64.
* config/darwin10.h: Removed.
* config/darwin12.h: Removed.
* config/darwin9.h: Removed.
* config/rs6000/darwin8.h: Removed.
---
 gcc/config.gcc  | 48 ++---
 gcc/config/darwin10.h   | 27 -
 gcc/config/darwin12.h   | 27 -
 gcc/config/darwin9.h| 22 -
 gcc/config/rs6000/darwin8.h | 21 
 5 files changed, 39 insertions(+), 106 deletions(-)
 delete mode 100644 gcc/config/darwin10.h
 delete mode 100644 gcc/config/darwin12.h
 delete mode 100644 gcc/config/darwin9.h
 delete mode 100644 gcc/config/rs6000/darwin8.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 70ecc51c1cf..b942e9700d6 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -685,17 +685,47 @@ case ${target} in
 *-*-darwin*)
   tmake_file="t-darwin "
   tm_file="${tm_file} darwin.h"
+  darwin_os=`echo ${target} | sed 's/.*darwin\([0-9.]*\).*$/\1/'`
+  darwin_maj=`expr "$darwin_os" : '\([0-9]*\).*'`
+  macos_min=`expr "$darwin_os" : '[0-9]*\.\([0-9]*\).*'`
+  macos_maj=10
+  if test x"${macos_min}" = x; then
+macos_min=0
+  fi
+  def_ld64=85.2
   case ${target} in
-  *-*-darwin9*)
-tm_file="${tm_file} darwin9.h"
-;;
-  *-*-darwin[1][01]*)
-tm_file="${tm_file} darwin9.h darwin10.h"
-;;
-  *-*-darwin[1][2-9]* | *-*-darwin[2][0-9]*)
-tm_file="${tm_file} darwin9.h darwin10.h darwin12.h"
-;;
+  # Darwin 4 to 19 correspond to macOS 10.0 to 10.15
+  *-*-darwin[4-9]* | *-*-darwin1[0-9]*)
+macos_min=`expr $darwin_maj - 4`
+;;
+  *-*-darwin20*)
+# Darwin 20 corresponds to macOS 11.
+macos_maj=11
+def_ld64=609.0
+;;
+  *-*-darwin)
+case ${cpu_type} in
+  aarch64) macos_maj=11 ;;
+  x86_64) macos_min=6 ;;
+  *)  macos_min=5 ;;
+  esac
+  case ${host} in
+*-*-darwin*) tm_defines="$tm_defines DARWIN_USE_KERNEL_VERS" ;;
+*)
+  # If configuring a cross-compiler then we will have set some
+  # default above, but it is probably not what was intended.
+  echo "Warning: Using ${target} is only suitable for Darwin 
hosts" 1>&2
+  echo "configure with an explicit target version" 1>&2
+  ;;
+  esac
+;;
+  *)
+echo "Error: configuring for an unreleased macOS version ${target}" 
1>&2
+exit 1
+;;
   esac
+  tm_defines="$tm_defines 
DEF_MIN_OSX_VERSION=\\\"${macos_maj}.${macos_min}\\\""
+  tm_defines="$tm_defines DEF_LD64=\\\"${def_ld64}\\\""
   tm_file="${tm_file} ${cpu_type}/darwin.h"
   tm_p_file="${tm_p_file} darwin-protos.h"
   target_gtfiles="$target_gtfiles \$(srcdir)/config/darwin.c"
diff --git a/gcc/config/darwin10.h b/gcc/config/darwin10.h
deleted file mode 100644
index 88b1fd061bb..000
--- a/gcc/config/darwin10.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Target definitions for Darwin (Mac OS X) systems.
-   Copyright (C) 2009-2020 Free Software Foundation, Inc.
-   Contributed by Jack Howarth .
-
-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
-.  */
-
-#undef DEF_MIN_OSX_VERSION
-#define DEF_MIN_OSX_VERSION "10.6"
-
-#ifndef LD64_VERSION
-#undef DEF_LD64
-#define DEF_LD64 "97.7"
-#endif
diff --git a/gcc/config/darwin12.h b/gcc/config/darwin12.h
deleted file mode 100644
index b397703dc78..000
--- a/gcc/config/darwin12.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Target definitions for Darwin (Mac OS X) systems.
-   Copyright (C) 2009-2020 Free Software Foundation, Inc.
-   Contributed by Jack Howarth .
-
-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 usef

[pushed] Darwin : Adjust defaults for the linker.

2021-01-02 Thread Iain Sandoe
Hi,

Ideally, the linker will be queried for its version and that will be
used to determine capabilities that cannot be discovered from
reasonable configuration testing.

When building cross tools, this might not be possible, and we have
strategies for providing useful defaults.  These are adjusted here to
refect current choices.

tested on dariwn8, 9, 18, 20, x86_64-linux-gnu
pushed to master
Iain

gcc/ChangeLog:

* config/darwin.h (MIN_LD64_NO_COAL_SECTS): Adjust.
Amend handling for LD64_VERSION fallback defaults.
---
 gcc/config/darwin.h | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 0eabd3f19eb..e40a98394d3 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1094,16 +1094,20 @@ extern void darwin_driver_init (unsigned int *,struct 
cl_decoded_option **);
 /* Later versions of ld64 support coalescing weak code/data without requiring
that they be placed in specially identified sections.  This is the earliest
_tested_ version known to support this so far.  */
-#define MIN_LD64_NO_COAL_SECTS "236.4"
+#define MIN_LD64_NO_COAL_SECTS "236.3"
 
 /* From at least version 62.1, ld64 can build symbol indirection stubs as
needed, and there is no need for the compiler to emit them.  */
 #define MIN_LD64_OMIT_STUBS "62.1"
 
+/* If we have no definition for the linker version, pick the minimum version
+   that will bootstrap the compiler.  */
 #ifndef LD64_VERSION
-#define LD64_VERSION "62.1"
-#else
-#define DEF_LD64 LD64_VERSION
+# ifndef  DEF_LD64
+#  define LD64_VERSION "85.2.1"
+# else
+#  define LD64_VERSION DEF_LD64
+# endif
 #endif
 
 #endif /* CONFIG_DARWIN_H */
-- 
2.24.1




[PATCH v3] handle MEM_REF with void* arguments (PR c++/95768)

2021-01-02 Thread Martin Sebor via Gcc-patches

Attached is another revision of a patch I posted last July to keep
the pretty-printer from crashing on MEM_REFs with void* arguments:
  https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549746.html

Besides avoiding the ICE and enhancing the MEM_REF detail and
improving its format, this revision implements the suggestions
in that discussion.  To avoid code duplication it moves
the handling to the C pretty-printer and changes the C++ front
end to delegate to it.  In addition, it includes a cast to
the accessed type if it's different from/incompatible with
(according to GIMPLE) that of the dereferenced pointer, or if
the object is typeless.  Lastly, it replaces the  in
the output with either VLA names or the RHS of the GIMPLE
expression (this improves the output when for dynamically
allocated objects).

As an aside, In my experience, MEM_REFs in warnings are limited
to -Wuninitialized.  I think other middle end warnings tend to
avoid them.  Those that involve invalid/out-of-bounds accesses
replace them with either the target DECL (e.g., local variable,
or FIELD_DECL), the allocation call (e.g., malloc), or the DECL
of the pointer (e.g., PARM_DECL), followed by a note mentioning
the offset into the object.  I'd like to change -Wuninitialized
at some point to follow the same style.  So I see the value of
the MEM_REF formatting enhancement mainly as a transient solution
until that happens.

Martin
PR c++/95768 - pretty-printer ICE on -Wuninitialized with allocated storage

gcc/c-family/ChangeLog:

	PR c++/95768
	* c-pretty-print.c (c_pretty_printer::primary_expression): For
	SSA_NAMEs print VLA names and GIMPLE defining statements.
	(print_mem_ref): New function.
	(c_pretty_printer::unary_expression): Call it.

gcc/cp/ChangeLog:

	PR c++/95768
	* error.c (dump_expr): Call c_pretty_printer::unary_expression.

gcc/testsuite/ChangeLog:

	PR c++/95768
	* g++.dg/pr95768.C: New test.
	* g++.dg/warn/Wuninitialized-12.C: New test.
	* gcc.dg/uninit-38.c: New test.

diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 3027703056b..3a3f2f7bdcc 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "c-pretty-print.h"
+#include "gimple-pretty-print.h"
 #include "diagnostic.h"
 #include "stor-layout.h"
 #include "stringpool.h"
@@ -1334,6 +1335,34 @@ c_pretty_printer::primary_expression (tree e)
   pp_c_right_paren (this);
   break;
 
+case SSA_NAME:
+  if (SSA_NAME_VAR (e))
+	{
+	  tree var = SSA_NAME_VAR (e);
+	  const char *name = IDENTIFIER_POINTER (SSA_NAME_IDENTIFIER (e));
+	  const char *dot;
+	  if (DECL_ARTIFICIAL (var) && (dot = strchr (name, '.')))
+	{
+	  /* Print the name without the . suffix (such as in VLAs).
+		 Use pp_c_identifier so that it can be converted into
+		 the appropriate encoding.  */
+	  size_t size = dot - name;
+	  char *ident = XALLOCAVEC (char, size + 1);
+	  memcpy (ident, name, size);
+	  ident[size] = '\0';
+	  pp_c_identifier (this, ident);
+	}
+	  else
+	primary_expression (var);
+	}
+  else
+	{
+	  /* Print only the right side of the GIMPLE assignment.  */
+	  gimple *def_stmt = SSA_NAME_DEF_STMT (e);
+	  pp_gimple_stmt_1 (this, def_stmt, 0, TDF_RHS_ONLY);
+	}
+  break;
+
 default:
   /* FIXME:  Make sure we won't get into an infinite loop.  */
   if (location_wrapper_p (e))
@@ -1780,6 +1809,139 @@ pp_c_call_argument_list (c_pretty_printer *pp, tree t)
   pp_c_right_paren (pp);
 }
 
+/* Print the MEM_REF expression REF, including its type and offset.
+   Apply casts as necessary if the type of the access is different
+   from the type of the accessed object.  Produce compact output
+   designed to include both the element index as well as any
+   misalignment by preferring
+ ((int*)((char*)p + 1))[2]
+   over
+ *(int*)((char*)p + 9)
+   The former is more verbose but makes it clearer that the access
+   to the third element of the array is misaligned by one byte.  */
+
+static void
+print_mem_ref (c_pretty_printer *pp, tree e)
+{
+  tree arg = TREE_OPERAND (e, 0);
+
+  /* The byte offset.  Initially equal to the MEM_REF offset, then
+ adjusted to the remainder of the division by the byte size of
+ the access.  */
+  offset_int byte_off = wi::to_offset (TREE_OPERAND (e, 1));
+  /* The result of dividing BYTE_OFF by the size of the access.  */
+  offset_int elt_idx = 0;
+  /* True to include a cast to char* (for a nonzero final BYTE_OFF).  */
+  bool char_cast = false;
+  const bool addr = TREE_CODE (arg) == ADDR_EXPR;
+  if (addr)
+{
+  arg = TREE_OPERAND (arg, 0);
+  if (byte_off == 0)
+	{
+	  pp->expression (arg);
+	  return;
+	}
+}
+
+  const tree access_type = TREE_TYPE (e);
+  tree arg_type = TREE_TYPE (TREE_TYPE (arg));
+  if (TREE_CODE (arg_type) == ARRAY_TYPE)
+arg_type = TREE_TYPE (arg_type);
+
+