[PATCH] Drop unused enum vrp_mode.

2023-08-16 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Follow removal of EVRP and clean up unused defines.

gcc/
* flag-types.h (vrp_mode): Remove unused.
---
 gcc/flag-types.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 36305de589e..7466c1106f2 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -478,13 +478,6 @@ enum threader_debug
   THREADER_DEBUG_ALL = 1
 };
 
-/* VRP modes.  */
-enum vrp_mode
-{
-  VRP_MODE_VRP,
-  VRP_MODE_RANGER
-};
-
 /* Modes of OpenACC 'kernels' constructs handling.  */
 enum openacc_kernels
 {
-- 
2.41.0



[PATCH] mh-mingw: drop unused BOOT_CXXFLAGS variable

2023-07-21 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc's build system has BOOT_CFLAGS and various STAGE_C{,XX}FLAGS
variables. BOOT_CXXFLAGS is not handled anywhere.

config/

* mh-mingw: Drop assignment of unused BOOT_CXXFLAGS variable.
---
 config/mh-mingw | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config/mh-mingw b/config/mh-mingw
index e91367a7112..f5fb064813f 100644
--- a/config/mh-mingw
+++ b/config/mh-mingw
@@ -1,7 +1,6 @@
 # Add -D__USE_MINGW_ACCESS to enable the built compiler to work on Windows
 # Vista (see PR33281 for details).
 BOOT_CFLAGS += -D__USE_MINGW_ACCESS -Wno-pedantic-ms-format
-BOOT_CXXFLAGS += -D__USE_MINGW_ACCESS -Wno-pedantic-ms-format
 CFLAGS += -D__USE_MINGW_ACCESS
 CXXFLAGS += -D__USE_MINGW_ACCESS
 STAGE1_CXXFLAGS += -D__USE_MINGW_ACCESS
-- 
2.41.0



PING [PATCH] gcc/config/t-i386: add build dependencies on i386-builtin-types.inc

2022-10-03 Thread Sergei Trofimovich via Gcc-patches
On Thu, 22 Sep 2022 22:07:52 +0100
Sergei Trofimovich  wrote:

> On Fri, 16 Sept 2022 at 19:49, Sergei Trofimovich  wrote:
> >
> > From: Sergei Trofimovich 
> >
> > i386-builtin-types.inc is included indirectly via i386-builtins.h
> > into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc
> >
> > Only i386.cc dependency was present in gcc/config/t-i386 makefile.
> >
> > As a result parallel builds occasionally fail as:
> >
> > g++ ... -o i386-builtins.o ... 
> > ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
> > In file included from 
> > ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
> > ../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
> >  fatal error: i386-builtin-types.inc: No such file or directory
> >25 | #include "i386-builtin-types.inc"
> >   |  ^~~~
> > compilation terminated.
> > make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: 
> > i386-builtins.o]
> >   Error 1 shuffle=1663349189
> >
> > gcc/
> > * config/i386/t-i386: Add build-time dependencies against
> > i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
> > i386-features.o.
> > ---
> >  gcc/config/i386/t-i386 | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
> > index 4e2a0efc615..ffdbbdfe8ce 100644
> > --- a/gcc/config/i386/t-i386
> > +++ b/gcc/config/i386/t-i386
> > @@ -62,7 +62,12 @@ i386-features.o: $(srcdir)/config/i386/i386-features.cc
> > $(COMPILE) $<
> > $(POSTCOMPILE)
> >
> > +# i386-builtin-types.inc is included into i386-builtins.h.
> > +# Below are direct users of i386-builtins.h:
> >  i386.o: i386-builtin-types.inc
> > +i386-builtins.o: i386-builtin-types.inc
> > +i386-expand.o: i386-builtin-types.inc
> > +i386-features.o: i386-builtin-types.inc
> >
> >  i386-builtin-types.inc: s-i386-bt ; @true
> >  s-i386-bt: $(srcdir)/config/i386/i386-builtin-types.awk \
> > --
> > 2.37.2
> >  
> 
> Is it a reasonable approach? Maybe gcc has an equivalent of automake's
> BUILT_SOURCES to avoid explicit tracking of such dependencies?
> 
> -- 
> Sergei


-- 

  Sergei


Re: [PATCH] gcc/config/t-i386: add build dependencies on i386-builtin-types.inc

2022-09-22 Thread Sergei Trofimovich via Gcc-patches
On Fri, 16 Sept 2022 at 19:49, Sergei Trofimovich  wrote:
>
> From: Sergei Trofimovich 
>
> i386-builtin-types.inc is included indirectly via i386-builtins.h
> into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc
>
> Only i386.cc dependency was present in gcc/config/t-i386 makefile.
>
> As a result parallel builds occasionally fail as:
>
> g++ ... -o i386-builtins.o ... 
> ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
> In file included from 
> ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
> ../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
>  fatal error: i386-builtin-types.inc: No such file or directory
>25 | #include "i386-builtin-types.inc"
>   |  ^~~~
> compilation terminated.
> make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: 
> i386-builtins.o]
>   Error 1 shuffle=1663349189
>
> gcc/
> * config/i386/t-i386: Add build-time dependencies against
> i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
> i386-features.o.
> ---
>  gcc/config/i386/t-i386 | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
> index 4e2a0efc615..ffdbbdfe8ce 100644
> --- a/gcc/config/i386/t-i386
> +++ b/gcc/config/i386/t-i386
> @@ -62,7 +62,12 @@ i386-features.o: $(srcdir)/config/i386/i386-features.cc
> $(COMPILE) $<
> $(POSTCOMPILE)
>
> +# i386-builtin-types.inc is included into i386-builtins.h.
> +# Below are direct users of i386-builtins.h:
>  i386.o: i386-builtin-types.inc
> +i386-builtins.o: i386-builtin-types.inc
> +i386-expand.o: i386-builtin-types.inc
> +i386-features.o: i386-builtin-types.inc
>
>  i386-builtin-types.inc: s-i386-bt ; @true
>  s-i386-bt: $(srcdir)/config/i386/i386-builtin-types.awk \
> --
> 2.37.2
>

Is it a reasonable approach? Maybe gcc has an equivalent of automake's
BUILT_SOURCES to avoid explicit tracking of such dependencies?

-- 
Sergei


[PATCH] gcc/config/t-i386: add build dependencies on i386-builtin-types.inc

2022-09-16 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

i386-builtin-types.inc is included indirectly via i386-builtins.h
into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc

Only i386.cc dependency was present in gcc/config/t-i386 makefile.

As a result parallel builds occasionally fail as:

g++ ... -o i386-builtins.o ... 
../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
In file included from 
../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
 fatal error: i386-builtin-types.inc: No such file or directory
   25 | #include "i386-builtin-types.inc"
  |  ^~~~
compilation terminated.
make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: 
i386-builtins.o]
  Error 1 shuffle=1663349189

gcc/
* config/i386/t-i386: Add build-time dependencies against
i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
i386-features.o.
---
 gcc/config/i386/t-i386 | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
index 4e2a0efc615..ffdbbdfe8ce 100644
--- a/gcc/config/i386/t-i386
+++ b/gcc/config/i386/t-i386
@@ -62,7 +62,12 @@ i386-features.o: $(srcdir)/config/i386/i386-features.cc
$(COMPILE) $<
$(POSTCOMPILE)
 
+# i386-builtin-types.inc is included into i386-builtins.h.
+# Below are direct users of i386-builtins.h:
 i386.o: i386-builtin-types.inc
+i386-builtins.o: i386-builtin-types.inc
+i386-expand.o: i386-builtin-types.inc
+i386-features.o: i386-builtin-types.inc
 
 i386-builtin-types.inc: s-i386-bt ; @true
 s-i386-bt: $(srcdir)/config/i386/i386-builtin-types.awk \
-- 
2.37.2



[PATCH] Makefile.def: drop remnants of unused libelf

2022-08-18 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Use of libelf was removed from gcc in
misc/cutover-cvs2svn-32781-g48215350c24 ("re PR lto/46273 (Failed to
bootstrap)") around 2010, before gcc-4.6.0.

This change removes unused references to libelf from top-level condifure
and Makefile.

/
* Makefile.def: Drop libelf module and gcc-configure dependency
on it.
* Makefile.in: Regenerate with 'autogen Makefile.def'.
* Makefile.tpl (HOST_EXPORTS): Drop unused LIBELFLIBS and
LIBELFINC.
* configure: Regenrate.
* configure.ac (host_libs): Drop unused libelf.
---
 Makefile.def |4 -
 Makefile.in  | 1288 +-
 Makefile.tpl |6 -
 configure|2 +-
 configure.ac |2 +-
 5 files changed, 3 insertions(+), 1299 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 11e9f23dc42..3291b126b26 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -70,9 +70,6 @@ host_modules= { module= isl; lib_path=.libs; bootstrap=true;
extra_configure_flags='--disable-shared 
@extra_isl_gmp_configure_flags@';
extra_make_flags='V=1';
no_install= true; };
-host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
-   extra_configure_flags='--disable-shared';
-   no_install= true; };
 host_modules= { module= gold; bootstrap=true; };
 host_modules= { module= gprof; };
 host_modules= { module= intl; bootstrap=true; };
@@ -353,7 +350,6 @@ dependencies = { module=configure-gcc; on=all-binutils; };
 dependencies = { module=configure-gcc; on=all-gas; };
 dependencies = { module=configure-gcc; on=all-ld; };
 dependencies = { module=configure-gcc; on=all-gold; };
-dependencies = { module=configure-gcc; on=all-libelf; };
 dependencies = { module=configure-gcc; on=all-libiconv; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
 dependencies = { module=all-gcc; on=all-intl; };
diff --git a/Makefile.in b/Makefile.in
index 60077a6aa36..1919dfee829 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -236,8 +236,6 @@ HOST_EXPORTS = \
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
ISLLIBS="$(HOST_ISLLIBS)"; export ISLLIBS; \
ISLINC="$(HOST_ISLINC)"; export ISLINC; \
-   LIBELFLIBS="$(HOST_LIBELFLIBS)"; export LIBELFLIBS; \
-   LIBELFINC="$(HOST_LIBELFINC)"; export LIBELFINC; \
XGCC_FLAGS_FOR_TARGET="$(XGCC_FLAGS_FOR_TARGET)"; export 
XGCC_FLAGS_FOR_TARGET; \
 @if gcc-bootstrap
$(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 
's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
@@ -343,10 +341,6 @@ HOST_GMPINC = @gmpinc@
 HOST_ISLLIBS = @isllibs@
 HOST_ISLINC = @islinc@
 
-# Where to find libelf
-HOST_LIBELFLIBS = @libelflibs@
-HOST_LIBELFINC = @libelfinc@
-
 # --
 # Programs producing files for the BUILD machine
 # --
@@ -754,7 +748,7 @@ TARGET_LIB_PATH_libatomic = 
$$r/$(TARGET_SUBDIR)/libatomic/.libs:
 
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that programs built for the host machine work.
-HOST_LIB_PATH = 
$(HOST_LIB_PATH_gmp)$(HOST_LIB_PATH_mpfr)$(HOST_LIB_PATH_mpc)$(HOST_LIB_PATH_isl)$(HOST_LIB_PATH_libelf)
+HOST_LIB_PATH = 
$(HOST_LIB_PATH_gmp)$(HOST_LIB_PATH_mpfr)$(HOST_LIB_PATH_mpc)$(HOST_LIB_PATH_isl)
 
 # Define HOST_LIB_PATH_gcc here, for the sake of TARGET_LIB_PATH, ouch
 @if gcc
@@ -782,11 +776,6 @@ HOST_LIB_PATH_isl = \
   $$r/$(HOST_SUBDIR)/isl/.libs:$$r/$(HOST_SUBDIR)/prev-isl/.libs:
 @endif isl
 
-@if libelf
-HOST_LIB_PATH_libelf = \
-  $$r/$(HOST_SUBDIR)/libelf/.libs:$$r/$(HOST_SUBDIR)/prev-libelf/.libs:
-@endif libelf
-
 
 CXX_FOR_TARGET_FLAG_TO_PASS = \
"CXX_FOR_TARGET=$(CXX_FOR_TARGET)"
@@ -1078,7 +1067,6 @@ configure-host:  \
 maybe-configure-mpfr \
 maybe-configure-mpc \
 maybe-configure-isl \
-maybe-configure-libelf \
 maybe-configure-gold \
 maybe-configure-gprof \
 maybe-configure-intl \
@@ -1229,9 +1217,6 @@ all-host: maybe-all-mpc
 @if isl-no-bootstrap
 all-host: maybe-all-isl
 @endif isl-no-bootstrap
-@if libelf-no-bootstrap
-all-host: maybe-all-libelf
-@endif libelf-no-bootstrap
 @if gold-no-bootstrap
 all-host: maybe-all-gold
 @endif gold-no-bootstrap
@@ -1370,7 +1355,6 @@ info-host: maybe-info-gmp
 info-host: maybe-info-mpfr
 info-host: maybe-info-mpc
 info-host: maybe-info-isl
-info-host: maybe-info-libelf
 info-host: maybe-info-gold
 info-host: maybe-info-gprof
 info-host: maybe-info-intl
@@ -1460,7 +1444,6 @@ dvi-host: maybe-dvi-gmp
 dvi-host: maybe-dvi-mpfr
 dvi-host: maybe-dvi-mpc
 dvi-host: maybe-dvi-isl
-dvi-host: maybe-dvi-libelf
 dvi-host: maybe-dvi-gold
 dvi-host: maybe-dvi-gprof
 dvi-host: maybe-dvi-intl
@@ -1550,7 +1533,6 @@ pdf-host: maybe-pdf-gmp
 pdf-host: maybe-pdf-mpfr
 pdf-host: maybe-pdf-mpc
 pdf-host: maybe-pdf-isl
-pdf-host: maybe-pdf-libelf
 pdf-host: maybe-pdf-gold
 pdf-host: maybe-pdf-gprof
 pdf-host

[PATCH] Add libgo dependency on libbacktrace.

2022-08-18 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Noticed missing dependency when regenerated Makefile.in for unrelated
change with 'autoget Makefile.def'.

The change was lost in basepoints/gcc-12-6861-gaeac414923a
("Revert "Fix PR 67102: Add libstdc++ dependancy to libffi" [PR67102]").

/
Makefile.in: Regenerate.
---
 Makefile.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.in b/Makefile.in
index 13ee95a2602..60077a6aa36 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -66523,6 +66523,7 @@ all-target-liboffloadmic: maybe-all-target-libgomp
 configure-target-newlib: maybe-all-binutils
 configure-target-newlib: maybe-all-ld
 configure-target-libgfortran: maybe-all-target-libbacktrace
+configure-target-libgo: maybe-all-target-libbacktrace
 @endunless gcc-bootstrap
 
 # Dependencies for target modules on other target modules are
-- 
2.37.1



[PATCH] driver: fix environ corruption after putenv() [PR106624]

2022-08-16 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

The bug appeared afte r13-2010-g1270ccda70ca09 "Factor out
jobserver_active_p" slightly changed `putenv()` use from allocating
to non-allocating:

-xputenv (concat ("MAKEFLAGS=", dup, NULL));
+xputenv (jinfo.skipped_makeflags.c_str ());

`xputenv()` (and `putenv()`) don't copy strings and only store the
pointer in the `environ` global table. As a result `environ` got
corrupted as soon as `jinfo.skipped_makeflags` store got deallocated.

This started causing bootstrap crashes in `execv()` calls:

xgcc: fatal error: cannot execute '/build/build/./prev-gcc/collect2': 
execv: Bad address

The change restores memory allocation for `xputenv()` argument.

gcc/

PR driver/106624
* gcc (driver::detect_jobserver): Allocate storage xputenv()
argument using xstrdup().
---
 gcc/gcc.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index cac11c1a117..75ca0ece1a4 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -9182,7 +9182,7 @@ driver::detect_jobserver () const
 {
   jobserver_info jinfo;
   if (!jinfo.is_active && !jinfo.skipped_makeflags.empty ())
-xputenv (jinfo.skipped_makeflags.c_str ());
+xputenv (xstrdup (jinfo.skipped_makeflags.c_str ()));
 }
 
 /* Determine what the exit code of the driver should be.  */
-- 
2.37.1



[PATCH v2] jit: avoid calloc() poisoning on musl [PR106102]

2022-06-28 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

On musl  uses calloc() (via ). jit/ includes
it directly and exposes use of poisoned calloc():

/build/build/./prev-gcc/xg++ ... 
../../gcc-13-20220626/gcc/jit/jit-playback.cc
make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
make[3]: *** Waiting for unfinished jobs
In file included from /<>/musl-1.2.3-dev/include/pthread.h:30,
 from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:
/<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use 
poisoned "calloc"
   84 | void *calloc(size_t, size_t);
  |   ^
/<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use 
poisoned "calloc"
  124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
  |^

The change moves  inclusion to "system.h" under new
INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit.

gcc/

PR c++/106102
* system.h: Introduce INCLUDE_PTHREAD_H macros to include .

gcc/jit/

PR c++/106102
* jit-playback.cc: Include  via "system.h" to avoid calloc()
poisoning.
* jit-recording.cc: Ditto.
* libgccjit.cc: Ditto.
---
 gcc/jit/jit-playback.cc  | 3 +--
 gcc/jit/jit-recording.cc | 2 +-
 gcc/jit/libgccjit.cc | 2 +-
 gcc/system.h | 4 
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 6be6bdf8dea..79714132b91 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_PTHREAD_H
 #include "system.h"
 #include "coretypes.h"
 #include "target.h"
@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "stmt.h"
 
-#include 
-
 #include "jit-playback.h"
 #include "jit-result.h"
 #include "jit-builtins.h"
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index 697dee66e73..f78daed2d71 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_PTHREAD_H
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
 #include "pretty-print.h"
 #include "toplev.h"
 
-#include 
 
 #include "jit-builtins.h"
 #include "jit-recording.h"
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index 0e76097b4ba..ca862662777 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_PTHREAD_H
 #include "system.h"
 #include "coretypes.h"
 #include "timevar.h"
 #include "typed-splay-tree.h"
 #include "cppbuiltin.h"
-#include 
 
 #include "libgccjit.h"
 #include "jit-recording.h"
diff --git a/gcc/system.h b/gcc/system.h
index 67158b70c78..f8d42ff6815 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -753,6 +753,10 @@ extern int vsnprintf (char *, size_t, const char *, 
va_list);
 #endif
 #endif
 
+#ifdef INCLUDE_PTHREAD_H
+#include 
+#endif
+
 #ifdef INCLUDE_ISL
 #ifdef HAVE_isl
 #include 
-- 
2.36.1



[PATCH] jit: avoid calloc() poisoning on musl [PR106102]

2022-06-27 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

On musl  uses calloc() (via ). jit/ includes
it directly and exposes use of poisoned calloc():

/build/build/./prev-gcc/xg++ ... 
../../gcc-13-20220626/gcc/jit/jit-playback.cc
make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1
make[3]: *** Waiting for unfinished jobs
In file included from /<>/musl-1.2.3-dev/include/pthread.h:30,
 from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44:
/<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use 
poisoned "calloc"
   84 | void *calloc(size_t, size_t);
  |   ^
/<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use 
poisoned "calloc"
  124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
  |^

The change moves sys-specific header before "system.h" inclusion
to evade poisoning.

gcc/jit/

PR c++/106102
* jit-playback.cc: Include  before "system.h" to avoid 
calloc()
poisoning.
* jit-recording.cc: Ditto.
* libgccjit.cc: Ditto.
---
 gcc/jit/jit-playback.cc  | 5 +++--
 gcc/jit/jit-recording.cc | 4 +++-
 gcc/jit/libgccjit.cc | 4 +++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 6be6bdf8dea..4ab7b59cab9 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -19,6 +19,9 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+/*  has to go before "system.h" as it pull in to-be-poisoned
+   symbols on musl like calloc().  */
+#include 
 #include "system.h"
 #include "coretypes.h"
 #include "target.h"
@@ -41,8 +44,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "stmt.h"
 
-#include 
-
 #include "jit-playback.h"
 #include "jit-result.h"
 #include "jit-builtins.h"
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index 697dee66e73..9505ed3b279 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -19,13 +19,15 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+/*  has to go before "system.h" as it pull in to-be-poisoned
+   symbols on musl like calloc().  */
+#include 
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
 #include "pretty-print.h"
 #include "toplev.h"
 
-#include 
 
 #include "jit-builtins.h"
 #include "jit-recording.h"
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index 0e76097b4ba..6a0ac8aaba2 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -19,12 +19,14 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+/*  has to go before "system.h" as it pull in to-be-poisoned
+   symbols on musl like calloc().  */
+#include 
 #include "system.h"
 #include "coretypes.h"
 #include "timevar.h"
 #include "typed-splay-tree.h"
 #include "cppbuiltin.h"
-#include 
 
 #include "libgccjit.h"
 #include "jit-recording.h"
-- 
2.36.1



[PATCH] c++: avoid poisoning on musl [PR106102]

2022-06-27 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

On musl  uses calloc() (via ).  includes
it indirectly and exposes use of poisoned calloc() when module code
is built:

/build/build/./prev-gcc/xg++ ... 
../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
In file included from /<>/musl-1.2.3-dev/include/pthread.h:30,
 from 
/build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
 
 from 
/build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
 from 
../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
/<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use 
poisoned "calloc"
   84 | void *calloc(size_t, size_t);
  |   ^
/<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use 
poisoned "calloc"
  124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
  |^

gcc/cp/
* mapper-client.cc: Include  via "system.h".
* mapper-resolver.cc: Ditto.
* module.cc: Ditto.

libcc1/
* libcc1plugin.cc: Ditto.
* libcp1plugin.cc: Ditto.
---
 gcc/cp/mapper-client.cc   | 1 +
 gcc/cp/mapper-resolver.cc | 1 +
 gcc/cp/module.cc  | 1 +
 libcc1/libcc1plugin.cc| 1 +
 libcc1/libcp1plugin.cc| 1 +
 5 files changed, 5 insertions(+)

diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc
index 8603a886a09..fe9544b5ba4 100644
--- a/gcc/cp/mapper-client.cc
+++ b/gcc/cp/mapper-client.cc
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #define INCLUDE_STRING
 #define INCLUDE_VECTOR
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #include "system.h"
 
 #include "line-map.h"
diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc
index e3d29fb5ada..e70d1b4ae2c 100644
--- a/gcc/cp/mapper-resolver.cc
+++ b/gcc/cp/mapper-resolver.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #define INCLUDE_VECTOR
 #define INCLUDE_ALGORITHM
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #include "system.h"
 
 // We don't want or need to be aware of networking
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index e7ce40ef464..99f10733d4b 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -206,6 +206,7 @@ Classes used:
 
 #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available.  */
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #define INCLUDE_VECTOR
 #include "system.h"
diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc
index 12ab5a57c8d..bdd0bdabe77 100644
--- a/libcc1/libcc1plugin.cc
+++ b/libcc1/libcc1plugin.cc
@@ -31,6 +31,7 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
+#define INCLUDE_MEMORY
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc
index 83dab7f58b1..e2d5039a0a1 100644
--- a/libcc1/libcp1plugin.cc
+++ b/libcc1/libcp1plugin.cc
@@ -32,6 +32,7 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
+#define INCLUDE_MEMORY
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"
-- 
2.36.1



[PATCH, gcc-11 backport] gcov-profile: Allow negative counts of indirect calls [PR105282]

2022-04-19 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

TOPN metrics are histograms that contain overall count and per-bucket
count. Overall count can be negative when two profiles merge and some
of per-bucket metrics are disacarded.

Noticed as an ICE on python PGO build where gcc crashes as:

during IPA pass: modref
a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340
   36 | }
  | ^
stream_out_histogram_value(output_block*, histogram_value_t*)
gcc/value-prof.cc:340

gcc/ChangeLog:

PR gcov-profile/105282
* value-prof.cc (stream_out_histogram_value): Allow negative counts
on HIST_TYPE_INDIR_CALL.

(cherry picked from commit 90a29845bfe7d6002e6c2fd49a97820b00fbc4a3)
---
 gcc/value-prof.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 42748771192..688089b04d2 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -336,6 +336,10 @@ stream_out_histogram_value (struct output_block *ob, 
histogram_value hist)
/* Note that the IOR counter tracks pointer values and these can have
   sign bit set.  */
;
+  else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0)
+   /* 'all' counter overflow is stored as a negative value. Individual
+  counters and values are expected to be non-negative.  */
+   ;
   else
gcc_assert (value >= 0);
 
-- 
2.35.1



[PATCH] gcov-profile: Allow negavive counts of indirect calls [PR105282]

2022-04-15 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

TOPN metrics are histograms that contain overall count and per-bucket
count. Overall count can be nevative when two profiles merge and some
of per-bucket metrics are dropped.

Noticed as an ICE on python PGO build where gcc crashes as:

during IPA pass: modref
a.c:36:1: ICE: in stream_out_histogram_value, at value-prof.cc:340
   36 | }
  | ^
stream_out_histogram_value(output_block*, histogram_value_t*)
gcc/value-prof.cc:340

gcc/ChangeLog:

PR gcov-profile/105282
* value-prof.cc (stream_out_histogram_value): Allow negavive counts
on HIST_TYPE_INDIR_CALL.
---
 gcc/value-prof.cc | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index 9785c7a03ea..4927d119aa0 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -319,40 +319,44 @@ stream_out_histogram_value (struct output_block *ob, 
histogram_value hist)
   streamer_write_bitpack (&bp);
   switch (hist->type)
 {
 case HIST_TYPE_INTERVAL:
   streamer_write_hwi (ob, hist->hdata.intvl.int_start);
   streamer_write_uhwi (ob, hist->hdata.intvl.steps);
   break;
 default:
   break;
 }
   for (i = 0; i < hist->n_counters; i++)
 {
   /* When user uses an unsigned type with a big value, constant converted
 to gcov_type (a signed type) can be negative.  */
   gcov_type value = hist->hvalue.counters[i];
   if (hist->type == HIST_TYPE_TOPN_VALUES
  || hist->type == HIST_TYPE_IOR)
/* Note that the IOR counter tracks pointer values and these can have
   sign bit set.  */
;
+  else if (hist->type == HIST_TYPE_INDIR_CALL && i == 0)
+   /* 'all' counter overflow is stored as a negative value. Individual
+  counters and values are expected to be non-negative.  */
+   ;
   else
gcc_assert (value >= 0);
 
   streamer_write_gcov_count (ob, value);
 }
   if (hist->hvalue.next)
 stream_out_histogram_value (ob, hist->hvalue.next);
 }
 
 /* Dump information about HIST to DUMP_FILE.  */
 
 void
 stream_in_histogram_value (class lto_input_block *ib, gimple *stmt)
 {
   enum hist_type type;
   unsigned int ncounters = 0;
   struct bitpack_d bp;
   unsigned int i;
   histogram_value new_val;
   bool next;
-- 
2.35.1



[PATCH] libgcc: IA64: don't compile glibc-based unwinder without libc headers

2022-04-07 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In --without-headers mode gcc fails to bootstrap on libgcc as:

/build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c 
fde-glibc.c
../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10:
fatal error: stdlib.h: No such file or directory

Most other linux targets are able to build the --without-headers
compiler without additional effort. This change adds IA64 to the fold.

The change drops part of the code that relies on DYNAMIC glibc
section traversal for backtraces.

Tested bootstrap of ia64-unknown-linux-gnu with and without libc
headers present.

libgcc/
* config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode.
---
 libgcc/config/ia64/fde-glibc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libgcc/config/ia64/fde-glibc.c b/libgcc/config/ia64/fde-glibc.c
index 9caac2bca24..bd74847fa85 100644
--- a/libgcc/config/ia64/fde-glibc.c
+++ b/libgcc/config/ia64/fde-glibc.c
@@ -22,20 +22,21 @@
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
.  */
 
 /* Locate the FDE entry for a given address, using glibc ld.so routines
to avoid register/deregister calls at DSO load/unload.  */
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
 #include "config.h"
+#ifndef inhibit_libc
 #include 
 #include 
 #include 
 #include "unwind-ia64.h"
 
 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \
 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && !defined(DT_CONFIG))
 # error You need GLIBC 2.2.4 or later on IA-64 Linux
 #endif
 
@@ -152,10 +153,11 @@ _Unwind_FindTableEntry (void *pc, unw_word *segment_base, 
unw_word *gp,
   data.pc = (Elf64_Addr) pc;
   data.segment_base = segment_base;
   data.gp = gp;
   data.ret = NULL;
 
   if (dl_iterate_phdr (_Unwind_IteratePhdrCallback, &data) < 0)
 return NULL;
 
   return data.ret;
 }
+#endif
-- 
2.35.1



[PATCH v2] Fortran manual: extend deprecated BOZ examples with X'ABC'

2021-11-21 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc/fortran/
* gfortran.texi (BOZ literal constants): add X'ABC' to the list
of valid examples.
---
 gcc/fortran/gfortran.texi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 326470964b0..f7184147a82 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -1465,10 +1465,10 @@ dependent.  Gfortran interprets the sign bit as a user 
would expect.
 As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal
 constants to be specified using the @code{X} prefix.  That the BOZ literal
 constant can also be specified by adding a suffix to the string, for
-example, @code{Z'ABC'} and @code{'ABC'X} are equivalent.  Additionally,
-as extension, BOZ literals are permitted in some contexts outside of
-@code{DATA} and the intrinsic functions listed in the Fortran standard.
-Use @option{-fallow-invalid-boz} to enable the extension.
+example, @code{Z'ABC'}, @code{'ABC'X} and @code{X'ABC'} are equivalent.
+Additionally, as extension, BOZ literals are permitted in some contexts
+outside of @code{DATA} and the intrinsic functions listed in the Fortran
+standard. Use @option{-fallow-invalid-boz} to enable the extension.
 
 @node Real array indices
 @subsection Real array indices
-- 
2.33.1



[PATCH] Fortran manual: fix invalid BOZ 'ABC'X example to be X'ABC'.

2021-11-21 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc/fortran/
* gfortran.texi (BOZ literal constants): fix invalid BOZ 'ABC'X
example to be X'ABC'.
---
 gcc/fortran/gfortran.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 326470964b0..f01a49c47cc 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -1465,7 +1465,7 @@ dependent.  Gfortran interprets the sign bit as a user 
would expect.
 As a deprecated extension, GNU Fortran allows hexadecimal BOZ literal
 constants to be specified using the @code{X} prefix.  That the BOZ literal
 constant can also be specified by adding a suffix to the string, for
-example, @code{Z'ABC'} and @code{'ABC'X} are equivalent.  Additionally,
+example, @code{Z'ABC'} and @code{X'ABC'} are equivalent.  Additionally,
 as extension, BOZ literals are permitted in some contexts outside of
 @code{DATA} and the intrinsic functions listed in the Fortran standard.
 Use @option{-fallow-invalid-boz} to enable the extension.
-- 
2.33.1



Re: [PATCH] libbacktrace: fix fd leak tests on systems with extra descriptors

2021-08-13 Thread Sergei Trofimovich via Gcc-patches
On Fri, 13 Aug 2021 09:52:53 -0700
Ian Lance Taylor  wrote:

> On Fri, Aug 13, 2021 at 12:05 AM Sergei Trofimovich  wrote:
> >
> > On Thu, 12 Aug 2021 16:16:04 -0700
> > Ian Lance Taylor  wrote:
> >  
> > > On Thu, Aug 12, 2021 at 3:34 PM Sergei Trofimovich via Gcc-patches
> > >  wrote:  
> > > >
> > > > From: Sergei Trofimovich 
> > > >
> > > > I noticed test failures when ran gcc test suite from under mc shell.
> > > > mc opens fd=9 and exposes it to child processes. As a result a few
> > > > tests failes:
> > > > FAIL: b2test_buildid
> > > > FAIL: btest_gnudebuglink
> > > > FAIL: btest
> > > > FAIL: btest_lto
> > > > FAIL: btest_alloc
> > > > FAIL: ctestg
> > > > FAIL: ctesta
> > > > FAIL: ctestg_alloc
> > > > FAIL: ctesta_alloc
> > > > FAIL: dwarf5
> > > > FAIL: dwarf5_alloc
> > > >
> > > > Instead of trying to close file descripts in range test polls for
> > > > first available file descriptor by creating it via dup(1).
> > > >
> > > > libbacktrace/
> > > >
> > > > * btest.c (check_open_files): Use last free file descriptor as a
> > > > signal for flie descriptor leak.  
> > >
> > > This isn't a useful replacement, as this will pass as long as
> > > libbacktrace closes the first file descriptor that it opens.  It won't
> > > check whether libbacktrace left any other file descriptors open.
> > >
> > > Perhaps at program startup we could fstat descriptors up to 10 and
> > > record whether they are valid, and then skip those files in
> > > check_open_files.  
> >
> > Oh, great point! Completely missed it. Changed the patch to poll for present
> > file descriptors with fcntl(fd, F_GETFD) to compare before/after.  
> 
> I believe that we currently run some of the tests on Windows systems.
> Do you know if fcntl(fd, F_GETFD) will work there?

Ah, it does not. At least mingw does not expose fcntl. I'll look
at possible equivalent on it and send another version.

-- 

  Sergei


Re: [PATCH] libbacktrace: fix fd leak tests on systems with extra descriptors

2021-08-13 Thread Sergei Trofimovich via Gcc-patches
On Thu, 12 Aug 2021 16:16:04 -0700
Ian Lance Taylor  wrote:

> On Thu, Aug 12, 2021 at 3:34 PM Sergei Trofimovich via Gcc-patches
>  wrote:
> >
> > From: Sergei Trofimovich 
> >
> > I noticed test failures when ran gcc test suite from under mc shell.
> > mc opens fd=9 and exposes it to child processes. As a result a few
> > tests failes:
> > FAIL: b2test_buildid
> > FAIL: btest_gnudebuglink
> > FAIL: btest
> > FAIL: btest_lto
> > FAIL: btest_alloc
> > FAIL: ctestg
> > FAIL: ctesta
> > FAIL: ctestg_alloc
> > FAIL: ctesta_alloc
> > FAIL: dwarf5
> > FAIL: dwarf5_alloc
> >
> > Instead of trying to close file descripts in range test polls for
> > first available file descriptor by creating it via dup(1).
> >
> > libbacktrace/
> >
> > * btest.c (check_open_files): Use last free file descriptor as a
> > signal for flie descriptor leak.  
> 
> This isn't a useful replacement, as this will pass as long as
> libbacktrace closes the first file descriptor that it opens.  It won't
> check whether libbacktrace left any other file descriptors open.
> 
> Perhaps at program startup we could fstat descriptors up to 10 and
> record whether they are valid, and then skip those files in
> check_open_files.

Oh, great point! Completely missed it. Changed the patch to poll for present
file descriptors with fcntl(fd, F_GETFD) to compare before/after.

-- 

  Sergei
From dba67cc728d6be521f59a4c0d3abe7879de2db4c Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich 
Date: Thu, 12 Aug 2021 23:27:00 +0100
Subject: [PATCH v2] libbacktrace: fix fd leak tests on systems with extra
 descriptors

I noticed test failures when ran gcc test suite from under mc shell.
mc opens fd=9 and exposes it to child processes. As a result a few
tests failes:
FAIL: b2test_buildid
FAIL: btest_gnudebuglink
FAIL: btest
FAIL: btest_lto
FAIL: btest_alloc
FAIL: ctestg
FAIL: ctesta
FAIL: ctestg_alloc
FAIL: ctesta_alloc
FAIL: dwarf5
FAIL: dwarf5_alloc

Instead of trying to close file descripts in range test polls for
their presence with with fcntl(fd, F_GETFD) before and after test.

libbacktrace/

	* btest.c (check_open_files): Use fcntl to poll for file
	descriptor presence.
---
 libbacktrace/btest.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index 9f9c03babf3..c08c1540fa6 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.  */
libbacktrace library.  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -458,6 +459,18 @@ test5 (void)
   return failures;
 }
 
+#define MAX_FDS 10
+static int fd_states[MAX_FDS];
+
+static void
+store_open_files (void)
+{
+  int i;
+
+  for (i = 0; i < MAX_FDS; i++)
+fd_states[i] = fcntl (i, F_GETFD);
+}
+
 /* Check that are no files left open.  */
 
 static void
@@ -465,9 +478,9 @@ check_open_files (void)
 {
   int i;
 
-  for (i = 3; i < 10; i++)
+  for (i = 0; i < MAX_FDS; i++)
 {
-  if (close (i) == 0)
+  if (fcntl (i, F_GETFD) != fd_states[i])
 	{
 	  fprintf (stderr,
 		   "ERROR: descriptor %d still open after tests complete\n",
@@ -484,6 +497,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
 {
   state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
   error_callback_create, NULL);
+  store_open_files ();
 
 #if BACKTRACE_SUPPORTED
   test1 ();
-- 
2.32.0



pgpWbxhsEY6HB.pgp
Description: Цифровая подпись OpenPGP


[PATCH] libbacktrace: fix b2test_buildid test on non-english locales

2021-08-12 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

On LANG=ru_RU.UTF-8 'b2test_buildid' test fails due to localized readelf
output:

$ LANG=ru_RU.UTF-8 readelf -n b2test | fgrep 4e37e8f
ID сборки: 4e37e8fead8d6e8b0a9dc95ea25cd784dff3a393
$ LANG=C readelf -n b2test | fgrep 4e37e8f
Build ID: 4e37e8fead8d6e8b0a9dc95ea25cd784dff3a393

libbacktrace/

* install-debuginfo-for-buildid.sh.in: Force non-localized readelf
output with LANG=C.
---
 libbacktrace/install-debuginfo-for-buildid.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbacktrace/install-debuginfo-for-buildid.sh.in 
b/libbacktrace/install-debuginfo-for-buildid.sh.in
index 1364779d703..91dfdfe89a4 100644
--- a/libbacktrace/install-debuginfo-for-buildid.sh.in
+++ b/libbacktrace/install-debuginfo-for-buildid.sh.in
@@ -47,7 +47,7 @@ mkdir_p="@MKDIR_P@"
 build_id_dir="$1"
 src="$2"
 
-buildid=$($readelf -n $src \
+buildid=$(LANG=C $readelf -n $src \
  | $grep "Build ID" \
  | $awk '{print $3}')
 
-- 
2.32.0



[PATCH] libbacktrace: fix fd leak tests on systems with extra descriptors

2021-08-12 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

I noticed test failures when ran gcc test suite from under mc shell.
mc opens fd=9 and exposes it to child processes. As a result a few
tests failes:
FAIL: b2test_buildid
FAIL: btest_gnudebuglink
FAIL: btest
FAIL: btest_lto
FAIL: btest_alloc
FAIL: ctestg
FAIL: ctesta
FAIL: ctestg_alloc
FAIL: ctesta_alloc
FAIL: dwarf5
FAIL: dwarf5_alloc

Instead of trying to close file descripts in range test polls for
first available file descriptor by creating it via dup(1).

libbacktrace/

* btest.c (check_open_files): Use last free file descriptor as a
signal for flie descriptor leak.
---
 libbacktrace/btest.c | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c
index 9f9c03babf3..d5cf321640c 100644
--- a/libbacktrace/btest.c
+++ b/libbacktrace/btest.c
@@ -458,22 +458,32 @@ test5 (void)
   return failures;
 }
 
+/* Peek at first free flie descriptior.  */
+
+static int probe_first_dree_fd (void) {
+  int fd;
+
+  fd = dup(1);
+  close(fd);
+
+  return fd;
+}
+
 /* Check that are no files left open.  */
 
 static void
-check_open_files (void)
+check_open_files (int last_free_fd)
 {
-  int i;
+  int fd;
+
+  fd = probe_first_dree_fd();
 
-  for (i = 3; i < 10; i++)
+  if (fd != last_free_fd)
 {
-  if (close (i) == 0)
-   {
- fprintf (stderr,
-  "ERROR: descriptor %d still open after tests complete\n",
-  i);
- ++failures;
-   }
+  fprintf (stderr,
+  "ERROR: descriptor %d still open after tests complete\n",
+  last_free_fd);
+  ++failures;
 }
 }
 
@@ -482,8 +492,11 @@ check_open_files (void)
 int
 main (int argc ATTRIBUTE_UNUSED, char **argv)
 {
+  int first_free_fd;
+
   state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
  error_callback_create, NULL);
+  first_free_fd = probe_first_dree_fd ();
 
 #if BACKTRACE_SUPPORTED
   test1 ();
@@ -495,7 +508,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
 #endif
 #endif
 
-  check_open_files ();
+  check_open_files (first_free_fd);
 
   exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
 }
-- 
2.32.0



Re: [PATCH] c++: suppress all warnings on memper pointers to work around dICE [PR101219]

2021-08-11 Thread Sergei Trofimovich via Gcc-patches
On Wed, 11 Aug 2021 15:19:58 -0400
Jason Merrill  wrote:

> On 8/6/21 11:34 AM, Sergei Trofimovich wrote:
> > On Thu, 29 Jul 2021 11:41:39 -0400
> > Jason Merrill  wrote:
> >   
> >> On 7/22/21 7:15 PM, Sergei Trofimovich wrote:  
> >>> From: Sergei Trofimovich 
> >>>
> >>> r12-1804 ("cp: add support for per-location warning groups.") among other
> >>> things removed warning suppression from a few places including 
> >>> ptrmemfuncs.
> >>>
> >>> Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs
> >>> in access checks:
> >>>
> >>>   crash_signal
> >>>   gcc/toplev.c:328
> >>>   perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, 
> >>> int, access_failure_info*)
> >>>   gcc/cp/semantics.c:490
> >>>   finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
> >>>   gcc/cp/semantics.c:2208
> >>>   ...
> >>>
> >>> The change suppresses warnings again until we provide BINFOs for 
> >>> ptrmemfuncs.  
> >>
> >> We don't need BINFOs for PMFs, we need to avoid paths that expect them.
> >>
> >> It looks like the problem is with tsubst_copy_and_build calling
> >> finish_non_static_data_member instead of build_ptrmemfunc_access_expr.  
> > 
> > Sounds good. I'm not sure what would be the best way to match it. Here is
> > my attempt seems to survive all regtests:
> > 
> > --- a/gcc/cp/pt.c
> > +++ b/gcc/cp/pt.c
> > @@ -20530,7 +20530,13 @@ tsubst_copy_and_build (tree t,
> >  if (member == error_mark_node)
> >RETURN (error_mark_node);
> > 
> > -   if (TREE_CODE (member) == FIELD_DECL)
> > +   if (object_type && TYPE_PTRMEMFUNC_P(object_type)
> > +   && TREE_CODE (member) == FIELD_DECL)
> > + {
> > +   r = build_ptrmemfunc_access_expr (object, DECL_NAME(member));
> > +   RETURN (r);
> > + }
> > +   else if (TREE_CODE (member) == FIELD_DECL)
> >{
> >  r = finish_non_static_data_member (member, object, NULL_TREE);
> >  if (TREE_CODE (r) == COMPONENT_REF)
> >   
> >>>   PR c++/101219
> >>>
> >>> gcc/cp/ChangeLog:
> >>>
> >>>   * typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings
> >>>   to avoid ICE.
> >>>
> >>> gcc/testsuite/ChangeLog:
> >>>
> >>>   * g++.dg/torture/pr101219.C: New test.  
> >>
> >> This doesn't need to be in torture; it has nothing to do with 
> >> optimization.  
> > 
> > Aha, moved to gcc/testsuite/g++.dg/warn/pr101219.C.
> > 
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/warn/pr101219.C
> > @@ -0,0 +1,11 @@
> > +/* PR c++/101219 - ICE on use of uninitialized memfun pointer
> > +   { dg-do compile }
> > +   { dg-options "-Wall" } */
> > +
> > +struct S { void m(); };
> > +
> > +template  bool f() {
> > +  void (S::*mp)();
> > +
> > +  return &S::m == mp; // no warning emitted here (no instantiation)
> > +}
> > 
> > Another question: Is it expected that gcc generates no warnings here?
> > It's an uninstantiated function (-1 for warn), but from what I
> > understand it's guaranteed to generate comparison with uninitialized
> > data if it ever gets instantiated. Given that we used to ICE in
> > warning code gcc could possibly flag it? (+1 for warn)  
> 
> Generally it's desirable to diagnose templates for which no valid 
> instantiation is possible.  It seems reasonable in most cases to also 
> warn about templates for which all instantiations would warn.
> 
> But uninitialized warnings rely on flow analysis that we only do on 
> instantiated functions, and in any case the ICE doesn't depend on mp 
> being uninitialized; I get the same crash if I add = 0 to the declaration.

Aha. That makes sense. Let's just fix ICE then.

> > +   if (object_type && TYPE_PTRMEMFUNC_P(object_type)  
> 
> Missing space before (.
> 
> > +   && TREE_CODE (member) == FIELD_DECL)
> > + {
> > +   r = build_ptrmemfunc_access_expr (object, DECL_NAME(member));  
> 
> And here.

Added both. Attached as v3.

-- 

  Sergei
>From dbb17a22383faa7837bdd2ea9c902bfab53fa8f2 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich 
Date: Fri, 6 Aug 2021 16:14:16 +0100
Subject: [PATCH v3] c++: fix ptrmemfunc template instantiation [PR101219]

r12-1804 ("cp: add support for per-location warning groups.") among other
things removed warning suppression from a few places including ptrmemfuncs.

This exposed a bug in warning detection code as a reference to missing
BINFO (it's intentionally missing for ptrmemfunc types):

crash_signal
gcc/toplev.c:328
perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, access_failure_info*)
gcc/cp/semantics.c:490
finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
gcc/cp/semantics.c:2208
...

The change special cases ptrmemfuncs in templace substitution by using
build_ptrmemfunc_access_expr() instead of finish_non_static_data_member().

PR c++/101219

gcc/cp/ChangeLog:

* pt.c (tsubst_copy_and_build): Use build_ptrme

Re: [PATCH] c++: suppress all warnings on memper pointers to work around dICE [PR101219]

2021-08-06 Thread Sergei Trofimovich via Gcc-patches
On Thu, 29 Jul 2021 11:41:39 -0400
Jason Merrill  wrote:

> On 7/22/21 7:15 PM, Sergei Trofimovich wrote:
> > From: Sergei Trofimovich 
> > 
> > r12-1804 ("cp: add support for per-location warning groups.") among other
> > things removed warning suppression from a few places including ptrmemfuncs.
> > 
> > Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs
> > in access checks:
> > 
> >  crash_signal
> >  gcc/toplev.c:328
> >  perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, 
> > access_failure_info*)
> >  gcc/cp/semantics.c:490
> >  finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
> >  gcc/cp/semantics.c:2208
> >  ...
> > 
> > The change suppresses warnings again until we provide BINFOs for 
> > ptrmemfuncs.  
> 
> We don't need BINFOs for PMFs, we need to avoid paths that expect them.
> 
> It looks like the problem is with tsubst_copy_and_build calling 
> finish_non_static_data_member instead of build_ptrmemfunc_access_expr.

Sounds good. I'm not sure what would be the best way to match it. Here is
my attempt seems to survive all regtests:

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20530,7 +20530,13 @@ tsubst_copy_and_build (tree t,
if (member == error_mark_node)
  RETURN (error_mark_node);

-   if (TREE_CODE (member) == FIELD_DECL)
+   if (object_type && TYPE_PTRMEMFUNC_P(object_type)
+   && TREE_CODE (member) == FIELD_DECL)
+ {
+   r = build_ptrmemfunc_access_expr (object, DECL_NAME(member));
+   RETURN (r);
+ }
+   else if (TREE_CODE (member) == FIELD_DECL)
  {
r = finish_non_static_data_member (member, object, NULL_TREE);
if (TREE_CODE (r) == COMPONENT_REF)

> > PR c++/101219
> > 
> > gcc/cp/ChangeLog:
> > 
> > * typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings
> > to avoid ICE.
> > 
> > gcc/testsuite/ChangeLog:
> > 
> > * g++.dg/torture/pr101219.C: New test.  
> 
> This doesn't need to be in torture; it has nothing to do with optimization.

Aha, moved to gcc/testsuite/g++.dg/warn/pr101219.C.

--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr101219.C
@@ -0,0 +1,11 @@
+/* PR c++/101219 - ICE on use of uninitialized memfun pointer
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+struct S { void m(); };
+
+template  bool f() {
+  void (S::*mp)();
+
+  return &S::m == mp; // no warning emitted here (no instantiation)
+}

Another question: Is it expected that gcc generates no warnings here?
It's an uninstantiated function (-1 for warn), but from what I
understand it's guaranteed to generate comparison with uninitialized
data if it ever gets instantiated. Given that we used to ICE in
warning code gcc could possibly flag it? (+1 for warn)

Attached full patch as well. Full 'make check' shows no regressions on
x86_64-linux.

-- 

  Sergei
>From 9c51dbc598d8633167729de9637c8cdb5f3089fe Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich 
Date: Fri, 6 Aug 2021 16:14:16 +0100
Subject: [PATCH v2] c++: fix ptrmemfunc template instantiation [PR101219]

r12-1804 ("cp: add support for per-location warning groups.") among other
things removed warning suppression from a few places including ptrmemfuncs.

This exposed a bug in warning detection code as a reference to missing
BINFO (it's intentionally missing for ptrmemfunc types):

crash_signal
gcc/toplev.c:328
perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, access_failure_info*)
gcc/cp/semantics.c:490
finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
gcc/cp/semantics.c:2208
...

The change special cases ptrmemfuncs in templace substitution by using
build_ptrmemfunc_access_expr() instead of finish_non_static_data_member().

PR c++/101219

gcc/cp/ChangeLog:

* pt.c (tsubst_copy_and_build): Use build_ptrmemfunc_access_expr
to construct ptrmemfunc expression instantiation.

gcc/testsuite/ChangeLog:

* g++.dg/warn/pr101219.C: New test.

Signed-off-by: Sergei Trofimovich 
---
 gcc/cp/pt.c  |  8 +++-
 gcc/testsuite/g++.dg/warn/pr101219.C | 11 +++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/warn/pr101219.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b396ddd0089..c7a0317cbfb 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20530,7 +20530,13 @@ tsubst_copy_and_build (tree t,
 	if (member == error_mark_node)
 	  RETURN (error_mark_node);
 
-	if (TREE_CODE (member) == FIELD_DECL)
+	if (object_type && TYPE_PTRMEMFUNC_P(object_type)
+	&& TREE_CODE (member) == FIELD_DECL)
+	  {
+	r = build_ptrmemfunc_access_expr (object, DECL_NAME(member));
+	RETURN (r);
+	  }
+	else if (TREE_CODE (member) == FIELD_DECL)
 	  {
 	r = finish_non_static_data_member (member, object, NULL_TREE);
 	if (TREE_CODE (r) == COMPONENT_REF)
diff --git a/gcc/testsuite/g++.dg/w

Re: [PATCH] c++: suppress all warnings on memper pointers to work around dICE [PR101219]

2021-07-23 Thread Sergei Trofimovich via Gcc-patches
On Fri, 23 Jul 2021 10:33:09 -0600
Jeff Law  wrote:

> On 7/22/2021 5:15 PM, Sergei Trofimovich via Gcc-patches wrote:
> > From: Sergei Trofimovich 
> >
> > r12-1804 ("cp: add support for per-location warning groups.") among other
> > things removed warning suppression from a few places including ptrmemfuncs.
> >
> > Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs
> > in access checks:
> >
> >  crash_signal
> >  gcc/toplev.c:328
> >  perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, 
> > access_failure_info*)
> >  gcc/cp/semantics.c:490
> >  finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
> >  gcc/cp/semantics.c:2208
> >  ...
> >
> > The change suppresses warnings again until we provide BINFOs for 
> > ptrmemfuncs.
> >
> > PR c++/101219
> >
> > gcc/cp/ChangeLog:
> >
> > * typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings
> > to avoid ICE.
> >
> > gcc/testsuite/ChangeLog:
> >
> > * g++.dg/torture/pr101219.C: New test.  
> The C++ maintainers have the final say here, but ISTM that warning 
> suppression shouldn't be used to avoid an ICE, even an ICE within the 
> warning or diagnostic code itself.

Sounds good. I agree fixing it correctly is preferable and should improve
diagnostic on this very test case compared to gcc-11.

I'll need some help plumbing TYPE_BINFO() around build_ptrmemfunc_type().
My attempts to use `xref_basetypes (t, NULL_TREE);` to derive it for a
fresh expression only shuffles ICEs around.

-- 

  Sergei


[PATCH] c++: suppress all warnings on memper pointers to work around dICE [PR101219]

2021-07-22 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

r12-1804 ("cp: add support for per-location warning groups.") among other
things removed warning suppression from a few places including ptrmemfuncs.

Currently ptrmemfuncs don't have valid BINFO attached which causes ICEs
in access checks:

crash_signal
gcc/toplev.c:328
perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, 
access_failure_info*)
gcc/cp/semantics.c:490
finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
gcc/cp/semantics.c:2208
...

The change suppresses warnings again until we provide BINFOs for ptrmemfuncs.

PR c++/101219

gcc/cp/ChangeLog:

* typeck.c (build_ptrmemfunc_access_expr): Suppress all warnings
to avoid ICE.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr101219.C: New test.
---
 gcc/cp/typeck.c |  6 +-
 gcc/testsuite/g++.dg/torture/pr101219.C | 10 ++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/torture/pr101219.C

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a483e1f988d..aa91fd21c7b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3326,7 +3326,11 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree 
member_name)
member = DECL_CHAIN (member))
 if (DECL_NAME (member) == member_name)
   break;
-  return build_simple_component_ref (ptrmem, member);
+  tree r = build_simple_component_ref (ptrmem, member);
+  /* Suppress warning to avoid exposing missing BINFO for ptrmem
+ synthetic structs: PR101219.  */
+  suppress_warning(r);
+  return r;
 }
 
 /* Given an expression PTR for a pointer, return an expression
diff --git a/gcc/testsuite/g++.dg/torture/pr101219.C 
b/gcc/testsuite/g++.dg/torture/pr101219.C
new file mode 100644
index 000..c8d30448187
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr101219.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wall" } */
+struct S { void m(); };
+
+template  bool f() {
+  /* In PR101219 gcc used to ICE in warning code. */
+  void (S::*mp)();
+
+  return &S::m == mp;
+}
-- 
2.32.0



[PATCH] musl: always use 'lib' directory for all x86_64 ABIs [PR90077]

2021-07-05 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

musl library intentionally does not support glibc-style multilib layout
and usually assumes --libdir=lib (Gentoo and Alpine Linux both use it).

Before the change --disable-multilib x86_64-gentoo-linux-musl returned:

$ gcc -print-multi-os-directory
../lib64
$ gcc -print-multi-os-directory -m32
../lib32
$ gcc -print-multi-os-directory -mx32
../libx32

After the change the layout is always the same:

$ gcc -print-multi-os-directory
../lib
$ gcc -print-multi-os-directory -m32
../lib
$ gcc -print-multi-os-directory -mx32
../lib

The discrepancy was noticed in meson build system which uses
-print-multi-os-directory to find out target directory.

Debian's multi-arch setup should not change.

PR target/90077

gcc/ChangeLog

* gcc/config.gcc: Specal case musl to t-linux64-musl.

* gcc/config/i386/t-linux64-musl: New file based on t-linux64
that pins MULTILIB_OSDIRNAMES to lib.
---
 gcc/config.gcc | 10 --
 gcc/config/i386/t-linux64-musl | 28 
 2 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 gcc/config/i386/t-linux64-musl

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 0230bb88861..a87a59c9403 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1923,7 +1923,10 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
i[34567]86-*-gnu* | i[34567]8
if test x$enable_targets = xall; then
tm_file="${tm_file} i386/x86-64.h 
i386/gnu-user-common.h i386/gnu-user64.h i386/linux-common.h i386/linux64.h"
tm_defines="${tm_defines} TARGET_BI_ARCH=1"
-   tmake_file="${tmake_file} i386/t-linux64"
+   case $target in
+   *-*-*musl*) tmake_file="${tmake_file} 
i386/t-linux64-musl";;
+   *) tmake_file="${tmake_file} i386/t-linux64";;
+   esac
x86_multilibs="${with_multilib_list}"
if test "$x86_multilibs" = "default"; then
x86_multilibs="m64,m32"
@@ -1983,7 +1986,10 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu)
tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu64.h"
;;
esac
-   tmake_file="${tmake_file} i386/t-linux64"
+   case $target in
+   *-*-*musl*) tmake_file="${tmake_file} i386/t-linux64-musl";;
+   *) tmake_file="${tmake_file} i386/t-linux64";;
+   esac
x86_multilibs="${with_multilib_list}"
if test "$x86_multilibs" = "default"; then
case ${with_abi} in
diff --git a/gcc/config/i386/t-linux64-musl b/gcc/config/i386/t-linux64-musl
new file mode 100644
index 000..58e23c3c7dc
--- /dev/null
+++ b/gcc/config/i386/t-linux64-musl
@@ -0,0 +1,28 @@
+# Copyright (C) 2002-2021 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
+# .
+
+# musl explicitly does not support lib/lib32/lib64 layouts and always
+# uses lib layout. On debian full arch suffix is used. Thus we populate
+# all the m32/m64/mx32 with the same lib and apply multiarch suffix.
+
+comma=,
+MULTILIB_OPTIONS= $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu)
+MULTILIB_OSDIRNAMES+= m32=../lib$(call if_multiarch,:i386-linux-gnu)
+MULTILIB_OSDIRNAMES+= mx32=../lib$(call if_multiarch,:x86_64-linux-gnux32)
-- 
2.32.0



[PATCH] docs: drop unbalanced parenthesis in rtl.texi

2021-06-21 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc/ChangeLog:

* doc/rtl.texi: drop unbalanced parenthesis.
---
 gcc/doc/rtl.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index 5af71137a87..e1e76a93a8b 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -144,7 +144,7 @@ Currently, @file{rtl.def} defines these classes:
 @item RTX_OBJ
 An RTX code that represents an actual object, such as a register
 (@code{REG}) or a memory location (@code{MEM}, @code{SYMBOL_REF}).
-@code{LO_SUM}) is also included; instead, @code{SUBREG} and
+@code{LO_SUM} is also included; instead, @code{SUBREG} and
 @code{STRICT_LOW_PART} are not in this class, but in class
 @code{RTX_EXTRA}.
 
-- 
2.32.0



[PATCH] tree-optimization/98499 - fix modref analysis on RVO statements

2021-01-30 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Before the change RVO gimple statements were treated as local
stores by modres analysis. But in practice RVO escapes target.

2021-01-30  Sergei Trofimovich  

gcc/ChangeLog:

PR tree-optimization/98499
* ipa-modref.c: treat RVO conservatively and assume
all possible side-effects.

gcc/testsuite/ChangeLog:

PR tree-optimization/98499
* g++.dg/pr98499.C: new test.
---
 gcc/ipa-modref.c   | 14 --
 gcc/testsuite/g++.dg/pr98499.C | 31 +++
 2 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr98499.C

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index b362de77e74..7aaf53be8f4 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1621,9 +1621,19 @@ analyze_ssa_name_flags (tree name, vec 
&lattice, int depth,
   else if (gcall *call = dyn_cast  (use_stmt))
{
  tree callee = gimple_call_fndecl (call);
-
+ /* Return slot optiomization would require bit of propagation;
+give up for now.  */
+ if (gimple_call_return_slot_opt_p (call)
+ && gimple_call_lhs (call) != NULL_TREE
+ && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (call
+   {
+ if (dump_file)
+   fprintf (dump_file, "%*s  Unhandled return slot opt\n",
+depth * 4, "");
+ lattice[index].merge (0);
+   }
  /* Recursion would require bit of propagation; give up for now.  */
- if (callee && !ipa && recursive_call_p (current_function_decl,
+ else if (callee && !ipa && recursive_call_p (current_function_decl,
  callee))
lattice[index].merge (0);
  else
diff --git a/gcc/testsuite/g++.dg/pr98499.C b/gcc/testsuite/g++.dg/pr98499.C
new file mode 100644
index 000..ace088aeed9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr98499.C
@@ -0,0 +1,31 @@
+/* PR tree-optimization/98499.  */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct string {
+  // pointer to local store
+  char * _M_buf;
+  // local store
+  char _M_local_buf[16];
+
+  __attribute__((noinline)) string() : _M_buf(_M_local_buf) {}
+
+  ~string() {
+if (_M_buf != _M_local_buf)
+  __builtin_trap();
+  }
+
+  string(const string &__str); // no copies
+};
+
+__attribute__((noinline)) static string dir_name() { return string(); }
+class Importer {
+  string base_path;
+
+public:
+  __attribute__((noinline)) Importer() : base_path (dir_name()) {}
+};
+
+int main() {
+  Importer imp;
+}
-- 
2.30.0



[PATCH] ipa-modref: avoid linebreak split in debug print

2021-01-07 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

* ipa-modref.c (merge_call_side_effects): Fix
linebreak split by reordering two print calls.
---
 gcc/ipa-modref.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index fcc676d25e4..04613201f1f 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -835,10 +835,6 @@ merge_call_side_effects (modref_summary *cur_summary,
   auto_vec  parm_map;
   bool changed = false;
 
-  if (dump_file)
-fprintf (dump_file, " - Merging side effects of %s with parm map:",
-callee_node->dump_name ());
-
   /* We can not safely optimize based on summary of callee if it does
  not always bind to current def: it is possible that memory load
  was optimized out earlier which may not happen in the interposed
@@ -850,6 +846,10 @@ merge_call_side_effects (modref_summary *cur_summary,
   cur_summary->loads->collapse ();
 }
 
+  if (dump_file)
+fprintf (dump_file, " - Merging side effects of %s with parm map:",
+callee_node->dump_name ());
+
   parm_map.safe_grow_cleared (gimple_call_num_args (stmt), true);
   for (unsigned i = 0; i < gimple_call_num_args (stmt); i++)
 {
-- 
2.30.0



Re: [PATCH] PR preprocessor/94657: use $AR, not 'ar',

2020-11-13 Thread Sergei Trofimovich via Gcc-patches
On Fri, 13 Nov 2020 11:45:56 -0700
Jeff Law  wrote:

> 
> On 4/22/20 4:05 PM, Sergei Trofimovich wrote:
> > From: Sergei Trofimovich 
> >
> > On system with 'ar' and '${CHOST}-ar' the latter is preferred.
> > as it might not match default 'ar'.
> >
> > Bug is initially reported downstream as https://bugs.gentoo.org/718004.
> >
> > libcpp/ChangeLog:
> >
> > PR libcpp/94657
> > * Makefile.in: use @AR@ placeholder
> > * configure.ac: use AC_CHECK_TOOL to find 'ar'
> > * configure: regenerate
> 
> This was subsumed by David Edelsohn's patch to libcpp and libdecnumber
> which does effectively the same thing.

Agreed. It was also mentioned in
  https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546756.html
Probably should not have changed the topic to be mre visible.

-- 

  Sergei


[PATCH gcc-10] gcov: fix TOPN streaming from shared libraries

2020-09-25 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

PR gcov-profile/96913
* libgcov-driver.c (write_one_data): Avoid function pointer
comparison in TOP streaming decision.

(backported commit 4ecf368f4b4223fb2df4f3887429dfbb48852e38)
---
 libgcc/libgcov-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index fb320738e1e..37438883d37 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -242,7 +242,7 @@ prune_counters (struct gcov_info *gi)
  if (gi->merge[j] == NULL)
continue;
 
- if (gi->merge[j] == __gcov_merge_topn)
+ if (j == GCOV_COUNTER_V_TOPN || j == GCOV_COUNTER_V_INDIR)
{
  gcc_assert (!(ci->num % GCOV_TOPN_VALUES_COUNTERS));
  for (unsigned k = 0; k < (ci->num / GCOV_TOPN_VALUES_COUNTERS);
-- 
2.28.0



Re: [PATCH] gcov: fix TOPN streaming from shared libraries

2020-09-21 Thread Sergei Trofimovich via Gcc-patches
On Mon, 21 Sep 2020 20:38:07 +0300 (MSK)
Alexander Monakov  wrote:

> On Mon, 21 Sep 2020, Martin Liška wrote:
> 
> > On 9/6/20 1:24 PM, Sergei Trofimovich wrote:  
> > > From: Sergei Trofimovich 
> > > 
> > > Before the change gcc did not stream correctly TOPN counters
> > > if counters belonged to a non-local shared object.
> > > 
> > > As a result zero-section optimization generated TOPN sections
> > > in a form not recognizable by '__gcov_merge_topn'.
> > > 
> > > The problem happens because in a case of multiple shared objects
> > > '__gcov_merge_topn' function is present in address space multiple
> > > times (once per each object).
> > > 
> > > The fix is to never rely on function address and predicate on TOPN
> > > counter types.  
> > 
> > Hello.
> > 
> > Thank you for the analysis! I think it's the correct fix and it's probably
> > similar to what we used to see for indirect_call_tuple.
> > 
> > @Alexander: Am I right?  
> 
> Yes, analysis presented by Sergei in Bugzilla looks correct. Pedantically I
> wouldn't say the indirect call issue was similar: it's a different gotcha
> arising from mixing static and dynamic linking. There we had some symbols
> preempted by the main executable (but not all symbols), here we have lack
> of preemption/unification as relevant libgcov symbol is hidden.
> 
> I cannot judge if the fix is correct (don't know the code that well) but it
> looks reasonable. If you could come up with a clearer wording for the new
> comment it would be nice, I struggled to understand it.

Yeah, I agree the comment is very misleading. The code is already very clear
about special casing of TOPN counters. How about dropping the comment?

v2:

From 300585164f0a719a3a283c8da3a4061615f6da3a Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich 
Date: Sun, 6 Sep 2020 12:13:54 +0100
Subject: [PATCH v2] gcov: fix TOPN streaming from shared libraries

Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

PR gcov-profile/96913
* libgcov-driver.c (write_one_data): Avoid function pointer
comparison in TOP streaming decision.
---
 libgcc/libgcov-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 58914268d4e..e53e4dc392a 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -424,7 +424,7 @@ write_one_data (const struct gcov_info *gi_ptr,

  n_counts = ci_ptr->num;

- if (gi_ptr->merge[t_ix] == __gcov_merge_topn)
+ if (t_ix == GCOV_COUNTER_V_TOPN || t_ix == GCOV_COUNTER_V_INDIR)
write_top_counters (ci_ptr, t_ix, n_counts);
  else
{
-- 

  Sergei
>From 300585164f0a719a3a283c8da3a4061615f6da3a Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich 
Date: Sun, 6 Sep 2020 12:13:54 +0100
Subject: [PATCH v2] gcov: fix TOPN streaming from shared libraries

Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

	PR gcov-profile/96913
	* libgcov-driver.c (write_one_data): Avoid function pointer
	comparison in TOP streaming decision.
---
 libgcc/libgcov-driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 58914268d4e..e53e4dc392a 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -424,7 +424,7 @@ write_one_data (const struct gcov_info *gi_ptr,
 
 	  n_counts = ci_ptr->num;
 
-	  if (gi_ptr->merge[t_ix] == __gcov_merge_topn)
+	  if (t_ix == GCOV_COUNTER_V_TOPN || t_ix == GCOV_COUNTER_V_INDIR)
 	write_top_counters (ci_ptr, t_ix, n_counts);
 	  else
 	{
-- 
2.28.0



Re: [PATCH] -fprofile-reproducible: fix option value handling

2020-09-14 Thread Sergei Trofimovich via Gcc-patches
On Mon, 14 Sep 2020 09:34:08 +0200
Richard Biener  wrote:

> On Fri, Sep 11, 2020 at 11:56 PM Sergei Trofimovich via Gcc-patches
>  wrote:
> >
> > From: Sergei Trofimovich 
> >
> > Before the change option handling did not accept an argument:
> >   xgcc: error: unknown profile reproducibility method '=serial'
> >   xgcc: note: valid arguments to '-fprofile-reproducible' are: 
> > multithreaded parallel-runs serial; did you mean 'serial'?
> >
> > The change also includes trailing '=' as part of option prefix.  
> 
> Does it still work without an option then?

'-fprofile-reproducible' seems to be unacceptable value.

Initially when I sent the patch I though there was no way to pass
the option to gcc. But now I understand how to do it (case 4):

Before:
  1 $ gcc-11.0.0 -c -fprofile-reproducible a.c -o a
  gcc-11.0.0: error: missing argument to '-fprofile-reproducible'
  2 $ gcc-11.0.0 -c -fprofile-reproducible= a.c -o a
  gcc-11.0.0: error: unknown profile reproducibility method '='
  gcc-11.0.0: note: valid arguments to '-fprofile-reproducible' are: 
multithreaded parallel-runs serial
  3 $ gcc-11.0.0 -c -fprofile-reproducible=serial a.c -o a
  gcc-11.0.0: error: unknown profile reproducibility method '=serial'
  gcc-11.0.0: note: valid arguments to '-fprofile-reproducible' are: 
multithreaded parallel-runs serial; did you mean 'serial'?
  4 $ gcc-11.0.0 -c -fprofile-reproducibleserial a.c -o a
  # ok

Note: case 4 was a way to pass the option.

After:
  1 $ ./xgcc -B. -c -fprofile-reproducible a.c -o a.o
  xgcc: error: unrecognized command-line option '-fprofile-reproducible'; did 
you mean '-fprofile-reproducible='?
  2 $ ./xgcc -B. -c -fprofile-reproducible= a.c -o a.o
  xgcc: error: missing argument to '-fprofile-reproducible='
  3 $ ./xgcc -B. -c -fprofile-reproducible=serial a.c -o a.o
  # ok
  4 $ ./xgcc -B. -c -fprofile-reproducibleserial a.c -o a.o
  xgcc: error: unrecognized command-line option '-fprofile-reproducibleserial'; 
did you mean '-fprofile-reproducible=serial'?

Note: two problems here:
a) case 2 got worse diagnostic
b) case 4 broke something that worked before

I'll look at "a)" to check if it can be easily fixed. Is "b)" worth handling as 
well?
I'll need a hint or example how to handle an alias like that.

> OK if so.
> 
> > gcc/ChangeLog:
> >
> > * common.opt: Fix handling of '-fprofile-reproducible' option.
> > ---
> >  gcc/common.opt | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/gcc/common.opt b/gcc/common.opt
> > index dd68c61ae1d..84bf521128d 100644
> > --- a/gcc/common.opt
> > +++ b/gcc/common.opt
> > @@ -2228,7 +2228,7 @@ Enum(profile_reproducibility) String(parallel-runs) 
> > Value(PROFILE_REPRODUCIBILIT
> >  EnumValue
> >  Enum(profile_reproducibility) String(multithreaded) 
> > Value(PROFILE_REPRODUCIBILITY_MULTITHREADED)
> >
> > -fprofile-reproducible
> > +fprofile-reproducible=
> >  Common Joined RejectNegative Var(flag_profile_reproducible) 
> > Enum(profile_reproducibility) Init(PROFILE_REPRODUCIBILITY_SERIAL)
> >  -fprofile-reproducible=[serial|parallel-runs|multithreaded]Control 
> > level of reproducibility of profile gathered by -fprofile-generate.
> >
> > --
> > 2.28.0
> >  


-- 

  Sergei


[PATCH] doc: use @code{} instead of @samp{@command{}} around 'date %s'

2020-09-11 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Before the change 'man gcc' rendered "SOURCE_DATE_EPOCH" section as:
... the output of @command{date +%s} on GNU/Linux ...
After the change it renders as:
... the output of "date +%s" on GNU/Linux ...

gcc/ChangeLog:

* doc/cppenv.texi: Use @code{} instead of @samp{@command{}}
around 'date %s'.
---
 gcc/doc/cppenv.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/cppenv.texi b/gcc/doc/cppenv.texi
index 123df5c464c..e1e408a2974 100644
--- a/gcc/doc/cppenv.texi
+++ b/gcc/doc/cppenv.texi
@@ -89,7 +89,7 @@ reproducible.
 The value of @env{SOURCE_DATE_EPOCH} must be a UNIX timestamp,
 defined as the number of seconds (excluding leap seconds) since
 01 Jan 1970 00:00:00 represented in ASCII; identical to the output of
-@samp{@command{date +%s}} on GNU/Linux and other systems that support the
+@code{date +%s} on GNU/Linux and other systems that support the
 @code{%s} extension in the @code{date} command.
 
 The value should be a known timestamp such as the last modification
-- 
2.28.0



[PATCH] doc: fix spelling of -fprofile-reproducibility

2020-09-11 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc/ChangeLog:

* doc/invoke.texi: fix '-fprofile-reproducibility' option
spelling in maunal.
---
 gcc/doc/invoke.texi | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index bca8c856dc8..183ce7715d1 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -557,7 +557,8 @@ Objective-C and Objective-C++ Dialects}.
 -fprofile-dir=@var{path}  -fprofile-generate  -fprofile-generate=@var{path} 
@gol
 -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
 -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
--fprofile-exclude-files=@var{regex} -fprofile-reproducibility @gol
+-fprofile-exclude-files=@var{regex} @gol
+-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} 
@gol
 -fsanitize=@var{style}  -fsanitize-recover  -fsanitize-recover=@var{style} @gol
 -fasan-shadow-offset=@var{number}  -fsanitize-sections=@var{s1},@var{s2},... 
@gol
 -fsanitize-undefined-trap-on-error  -fbounds-check @gol
@@ -13889,14 +13890,14 @@ any of the regular expressions (separated by 
semi-colons).
 For example, @option{-fprofile-exclude-files=/usr/.*} will prevent 
instrumentation
 of all files that are located in the @file{/usr/} folder.
 
-@item -fprofile-reproducible
+@item 
-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
 @opindex fprofile-reproducible
 Control level of reproducibility of profile gathered by
 @code{-fprofile-generate}.  This makes it possible to rebuild program
 with same outcome which is useful, for example, for distribution
 packages.
 
-With @option{-fprofile-reproducibility=serial} the profile gathered by
+With @option{-fprofile-reproducible=serial} the profile gathered by
 @option{-fprofile-generate} is reproducible provided the trained program
 behaves the same at each invocation of the train run, it is not
 multi-threaded and profile data streaming is always done in the same
@@ -13911,7 +13912,7 @@ Such non-reproducible part of programs may be annotated 
by
 @option{-l} can be used to dump gathered data and verify that they are
 indeed reproducible.
 
-With @option{-fprofile-reproducibility=parallel-runs} collected profile
+With @option{-fprofile-reproducible=parallel-runs} collected profile
 stays reproducible regardless the order of streaming of the data into
 gcda files.  This setting makes it possible to run multiple instances of
 instrumented program in parallel (such as with @code{make -j}). This
-- 
2.28.0



[PATCH] -fprofile-reproducible: fix option value handling

2020-09-11 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Before the change option handling did not accept an argument:
  xgcc: error: unknown profile reproducibility method '=serial'
  xgcc: note: valid arguments to '-fprofile-reproducible' are: multithreaded 
parallel-runs serial; did you mean 'serial'?

The change also includes trailing '=' as part of option prefix.

gcc/ChangeLog:

* common.opt: Fix handling of '-fprofile-reproducible' option.
---
 gcc/common.opt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index dd68c61ae1d..84bf521128d 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2228,7 +2228,7 @@ Enum(profile_reproducibility) String(parallel-runs) 
Value(PROFILE_REPRODUCIBILIT
 EnumValue
 Enum(profile_reproducibility) String(multithreaded) 
Value(PROFILE_REPRODUCIBILITY_MULTITHREADED)
 
-fprofile-reproducible
+fprofile-reproducible=
 Common Joined RejectNegative Var(flag_profile_reproducible) 
Enum(profile_reproducibility) Init(PROFILE_REPRODUCIBILITY_SERIAL)
 -fprofile-reproducible=[serial|parallel-runs|multithreaded]Control level 
of reproducibility of profile gathered by -fprofile-generate.
 
-- 
2.28.0



[PATCH] gcov: fix TOPN streaming from shared libraries

2020-09-06 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

Before the change gcc did not stream correctly TOPN counters
if counters belonged to a non-local shared object.

As a result zero-section optimization generated TOPN sections
in a form not recognizable by '__gcov_merge_topn'.

The problem happens because in a case of multiple shared objects
'__gcov_merge_topn' function is present in address space multiple
times (once per each object).

The fix is to never rely on function address and predicate on TOPN
counter types.

libgcc/ChangeLog:

PR gcov-profile/96913
* libgcov-driver.c (write_one_data): Avoid function pointer
comparison in TOP streaming decision.
---
 libgcc/libgcov-driver.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 58914268d4e..86a6b5ad68a 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -424,10 +424,15 @@ write_one_data (const struct gcov_info *gi_ptr,
 
  n_counts = ci_ptr->num;
 
- if (gi_ptr->merge[t_ix] == __gcov_merge_topn)
+ /* Do not zero-compress top counters because:
+  * - __gcv_merge_topn does not handle such sections
+  * - GCOV_COUNTER_V_INDIR contains non-zero keys
+  */
+ if (t_ix == GCOV_COUNTER_V_TOPN || t_ix == GCOV_COUNTER_V_INDIR)
write_top_counters (ci_ptr, t_ix, n_counts);
  else
{
+
  /* Do not stream when all counters are zero.  */
  int all_zeros = 1;
  for (unsigned i = 0; i < n_counts; i++)
-- 
2.28.0



[PATCH] profile: clarify comment around histogram format

2020-09-04 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

gcc/ChangeLog:

* gcc/profile.c (sort_hist_values): Clarify hist format:
start with a value, not counter.
---
 gcc/profile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/profile.c b/gcc/profile.c
index f5c206813c7..fe8963cc9e9 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -771,7 +771,7 @@ sort_hist_values (histogram_value hist)
   int counters = hist->hvalue.counters[1];
   for (int i = 0; i < counters - 1; i++)
   /* Hist value is organized as:
- [total_executions, N, counter1, ..., valueN, counterN]
+ [total_executions, N, value1, counter1, ..., valueN, counterN]
  Use decrease bubble sort to rearrange it.  The sort starts from  and compares counter first.  If counter is same, compares the
  value, exchange it if small to keep stable.  */
-- 
2.28.0



[PATCH] var-tracking: fix uninitialised use of 'in_pending' [PR96404]

2020-08-02 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

r11-2447-g:1212cfad093 ("Improve var-tracking dataflow
iteration order") changed 'in_pending' initialization
from:

in_pending = sbitmap_alloc (last_basic_block_for_fn (cfun));
bitmap_ones (in_pending);

to more complex partial bit population algorithm. Due to presence
of uninitialized bits gcc started injecting extra debug entries
in seemigly arbitrary locations and started failing stage2/stage3
bootstrap comparison.

valgrind detected unilitialized bits as:

  Conditional jump or move depends on uninitialised value(s)
 at 0xDBED3B: vt_find_locations() (var-tracking.c:7230)
 by 0xDBF2FB: variable_tracking_main_1() (var-tracking.c:10519)
 ...
   Uninitialised value was created by a heap allocation
 at 0x483779F: malloc (vg_replace_malloc.c:307)
 by 0x14EE80B: xmalloc (xmalloc.c:147)
 by 0x14911F9: sbitmap_alloc(unsigned int) (sbitmap.c:51)
 ...

The fix explicitly initializes 'in_pending' bitmap with zeros.

gcc:

2020-08-02  Sergei Trofimovich  

PR bootstrap96404
* var-tracking.c (vt_find_locations): Fully initialize
all 'in_pending' bits.

Signed-off-by: Sergei Trofimovich 
---
 gcc/var-tracking.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 743f5dcecf6..52aea47a053 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -7096,6 +7096,7 @@ vt_find_locations (void)
   in_worklist = sbitmap_alloc (last_basic_block_for_fn (cfun));
   in_pending = sbitmap_alloc (last_basic_block_for_fn (cfun));
   bitmap_clear (in_worklist);
+  bitmap_clear (in_pending);
 
   /* We're performing the dataflow iteration independently over the
  toplevel SCCs plus leading non-cyclic entry blocks and separately
-- 
2.28.0



Re: [PATCH] ipa/96291: don't crash on unoptimized lto functions

2020-07-27 Thread Sergei Trofimovich via Gcc-patches
On Mon, 27 Jul 2020 14:41:14 +0200
Martin Jambor  wrote:

> Hi,
> 
> On Mon, Jul 27 2020, Richard Biener via Gcc-patches wrote:
> > On Sat, Jul 25, 2020 at 8:35 PM Sergei Trofimovich via Gcc-patches
> >  wrote:  
> >>
> >> From: Sergei Trofimovich 
> >>
> >> In PR ipa/96291 the test contained an SCC with one
> >> unoptimized function. This tricked ipa-cp into NULL dereference.
> >>
> >> has_undead_caller_from_outside_scc_p() did not take into account
> >> that unoptimized funtions don't have IPA summary analysis. and
> >> dereferenced NULL pointer causing an ICE.  
> >
> > Can you create a single-unit testcase with a SCC with one function
> > having the no_ipa attribute?  
> 
> This bug is LTO specific because otherwise a summary (although marked as
> quite useless) will be left over from the summary building stage.

Yeah, I was not able to shrink the example even down to 2 files.

> So Sergei, if you can afford to spend an extra while providing a
> testcase, you'll need to add three files into gcc/testsuite/gcc.dg/lto,
> with either the second or third (numbered _1 or _2)) having

Sounds good! I tried is as:
https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550817.html

> /* { dg-lto-options { { -flto -O0 } } } */

I used "/* { dg-options {-O0} } */" looking at pr88077_1.c which uses
"/* { dg-options {-fcommon} } */".  But only now looked closer at your
suggestion.

Should I resend with "/* { dg-lto-options { { -flto -O0 } } } */"? I need
a bit or help to understand the difference :)

-- 

  Sergei


[PATCH v2] ipa/96291: don't crash on unoptimized lto functions

2020-07-27 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In PR ipa/96291 the test contained an SCC with one
unoptimized function. This tricked ipa-cp into NULL dereference.

has_undead_caller_from_outside_scc_p() did not take into account
that unoptimized funtions don't have IPA summary analysis. And
dereferenced NULL pointer causing an ICE.

gcc/
PR ipa/96291
* ipa-cp.c (has_undead_caller_from_outside_scc_p): Consider
unoptimized callers as undead.

gcc/testsuite/
PR ipa/96291
* gcc.dg/lto/pr96291_0.c: New testcase.
* gcc.dg/lto/pr96291_1.c: Support file.
* gcc.dg/lto/pr96291_2.c: Likewise.
* gcc.dg/lto/pr96291.h: Likewise.
---
 gcc/ipa-cp.c |  5 +++--
 gcc/testsuite/gcc.dg/lto/pr96291.h   |  4 
 gcc/testsuite/gcc.dg/lto/pr96291_0.c | 11 +++
 gcc/testsuite/gcc.dg/lto/pr96291_1.c |  3 +++
 gcc/testsuite/gcc.dg/lto/pr96291_2.c |  7 +++
 5 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr96291.h
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr96291_0.c
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr96291_1.c
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr96291_2.c

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index b0c8f405260..fe010ff457c 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -5667,8 +5667,9 @@ has_undead_caller_from_outside_scc_p (struct cgraph_node 
*node,
  (has_undead_caller_from_outside_scc_p, NULL, true))
   return true;
 else if (!ipa_edge_within_scc (cs)
-&& !IPA_NODE_REF (cs->caller)->node_dead)
-  return true;
+&& (!IPA_NODE_REF (cs->caller) /* Unoptimized caller.  */
+|| !IPA_NODE_REF (cs->caller)->node_dead))
+ return true;
   return false;
 }
 
diff --git a/gcc/testsuite/gcc.dg/lto/pr96291.h 
b/gcc/testsuite/gcc.dg/lto/pr96291.h
new file mode 100644
index 000..70eb3cb71b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr96291.h
@@ -0,0 +1,4 @@
+void e(void);
+void f(void);
+void a(void *, void *);
+void c(int);
diff --git a/gcc/testsuite/gcc.dg/lto/pr96291_0.c 
b/gcc/testsuite/gcc.dg/lto/pr96291_0.c
new file mode 100644
index 000..07e63038e03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr96291_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-do link } */
+
+#include "pr96291.h"
+
+static void * b;
+void c(int d) {
+  f();
+  a(b, b);
+}
+
+void e(void) { c(0); }
diff --git a/gcc/testsuite/gcc.dg/lto/pr96291_1.c 
b/gcc/testsuite/gcc.dg/lto/pr96291_1.c
new file mode 100644
index 000..44744a94941
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr96291_1.c
@@ -0,0 +1,3 @@
+#include "pr96291.h"
+
+void f(void) { c(0); }
diff --git a/gcc/testsuite/gcc.dg/lto/pr96291_2.c 
b/gcc/testsuite/gcc.dg/lto/pr96291_2.c
new file mode 100644
index 000..5febffbb00c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr96291_2.c
@@ -0,0 +1,7 @@
+/* { dg-options {-O0} } */
+
+#include "pr96291.h"
+
+void a(void * a1, void * a2) { e(); }
+
+int main(){}
-- 
2.27.0



[PATCH] ipa/96291: don't crash on unoptimized lto functions

2020-07-25 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In PR ipa/96291 the test contained an SCC with one
unoptimized function. This tricked ipa-cp into NULL dereference.

has_undead_caller_from_outside_scc_p() did not take into account
that unoptimized funtions don't have IPA summary analysis. and
dereferenced NULL pointer causing an ICE.

PR ipa/96291
* ipa-cp.c (has_undead_caller_from_outside_scc_p): Consider
unoptimized callers as undead.
---
 gcc/ipa-cp.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index b0c8f405260..d5082576962 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -5666,9 +5666,15 @@ has_undead_caller_from_outside_scc_p (struct cgraph_node 
*node,
&& cs->caller->call_for_symbol_thunks_and_aliases
  (has_undead_caller_from_outside_scc_p, NULL, true))
   return true;
-else if (!ipa_edge_within_scc (cs)
-&& !IPA_NODE_REF (cs->caller)->node_dead)
-  return true;
+else if (!ipa_edge_within_scc (cs))
+  {
+   /* Unoptimized callers don't have IPA information.
+  Conservatively assume callers are undead.  */
+   if (!IPA_NODE_REF (cs->caller))
+ return true;
+   if (!IPA_NODE_REF (cs->caller)->node_dead)
+ return true;
+  }
   return false;
 }
 
-- 
2.27.0



Re: [PATCH v2] sparc/sparc64: use crtendS.o for default-pie executables [PR96190]

2020-07-20 Thread Sergei Trofimovich via Gcc-patches
On Fri, 17 Jul 2020 10:19:41 +0200
Eric Botcazou  wrote:

> > Oh! Sent out v3 with tweaked description as
> > https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550168.html  
> 
> Thanks.
> 
> > I don't have a push access to gcc tree. Should I request one via
> > https://sourceware.org/cgi-bin/pdw/ps_form.cgi ?  
> 
> Sure, you can put me (ebotca...@libertysurf.fr) as sponsor if need be.

Got access and pushed as https://gcc.gnu.org/g:87891d5eafe8
Will cherry-pick it to gcc-10 as well after 10.2 release.

Thank you!

-- 

  Sergei


Re: [PATCH v2] sparc/sparc64: use crtendS.o for default-pie executables [PR96190]

2020-07-16 Thread Sergei Trofimovich via Gcc-patches
On Wed, 15 Jul 2020 13:46:12 +0200
Eric Botcazou  wrote:

> > This should be:
> > 
> > PR target/96190
> > * config/sparc/linux.h (ENDFILE_SPEC): Use GNU_USER_TARGET_ENDFILE_SPEC
> > to get crtendS.o for !no-pie mode.
> > * config/sparc/linux64.h(ENDFILE_SPEC): Ditto.  
> 
>   * config/sparc/linux64.h (ENDFILE_SPEC): Ditto.
> 
> > OK for mainline with this change.  You can also put it on the 10 branch
> > after the 10.1 release is out if this is deemed necessary.  
> 
> 10.2

Oh! Sent out v3 with tweaked description as
https://gcc.gnu.org/pipermail/gcc-patches/2020-July/550168.html

I don't have a push access to gcc tree. Should I request one via
https://sourceware.org/cgi-bin/pdw/ps_form.cgi ?

-- 

  Sergei


[PATCH v3] sparc/sparc64: use crtendS.o for default-pie executables [PR96190]

2020-07-16 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In --enable-default-pie mode compiler should switch from
using crtend.o to crtendS.o. On sparc it is especially important
because crtend.o contains PIC-unfriendly code.

We use GNU_USER_TARGET_ENDFILE_SPEC as a baseline spec to get
crtendS.o instead of crtend.o in !no-pie mode.

gcc:

2020-07-14  Sergei Trofimovich  

PR target/96190
* config/sparc/linux.h (ENDFILE_SPEC): Use GNU_USER_TARGET_ENDFILE_SPEC
to get crtendS.o for !no-pie mode.
* config/sparc/linux64.h (ENDFILE_SPEC): Ditto.
---
 gcc/config/sparc/linux.h   | 10 ++
 gcc/config/sparc/linux64.h | 10 ++
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 81201e67a2f..63853e60c03 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -27,16 +27,10 @@ along with GCC; see the file COPYING3.  If not see
 }  \
   while (0)
 
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
-   the GNU/Linux magical crtend.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main', followed by a normal
-   GNU/Linux "finalizer" file, `crtn.o'.  */
-
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
-   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* -mcpu=native handling only makes sense with compiler running on
a SPARC chip.  */
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index a1a0efd8f28..19ce84d7adb 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -44,16 +44,10 @@ along with GCC; see the file COPYING3.  If not see
 #undef ASM_CPU64_DEFAULT_SPEC
 #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
 
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
-   the GNU/Linux magical crtend.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main', followed by a normal
-   GNU/Linux "finalizer" file, `crtn.o'.  */
-
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
-   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* The default code model.  */
 #undef SPARC_DEFAULT_CMODEL
-- 
2.27.0



[PATCH v2] sparc/sparc64: use crtendS.o for default-pie executables [PR96190]

2020-07-14 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In --enable-default-pie mode compiler should switch from
using crtend.o to crtendS.o. On sparc it is especially important
because crtend.o contains PIC-unfriendly code.

We use GNU_USER_TARGET_ENDFILE_SPEC as a baseline spec to get
crtendS.o instead of crtend.o in !no-pie mode.

gcc:

2020-07-14  Sergei Trofimovich  

PR target/96190
* config/sparc/linux.h: Extend GNU_USER_TARGET_ENDFILE_SPEC
to get crtendS.o for !no-pie mode.
* config/sparc/linux64.h: Ditto.
---
 gcc/config/sparc/linux.h   | 10 ++
 gcc/config/sparc/linux64.h | 10 ++
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 81201e67a2f..63853e60c03 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -27,16 +27,10 @@ along with GCC; see the file COPYING3.  If not see
 }  \
   while (0)
 
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
-   the GNU/Linux magical crtend.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main', followed by a normal
-   GNU/Linux "finalizer" file, `crtn.o'.  */
-
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
-   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* -mcpu=native handling only makes sense with compiler running on
a SPARC chip.  */
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index a1a0efd8f28..19ce84d7adb 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -44,16 +44,10 @@ along with GCC; see the file COPYING3.  If not see
 #undef ASM_CPU64_DEFAULT_SPEC
 #define ASM_CPU64_DEFAULT_SPEC "-Av9a"
 
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
-   the GNU/Linux magical crtend.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main', followed by a normal
-   GNU/Linux "finalizer" file, `crtn.o'.  */
-
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
-   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* The default code model.  */
 #undef SPARC_DEFAULT_CMODEL
-- 
2.27.0



[PATCH] sparc/sparc64: use PIE_SPEC to select crtendS.o [PR96190]

2020-07-14 Thread Sergei Trofimovich via Gcc-patches
From: Sergei Trofimovich 

In --enable-default-pie mode compiler should switch from
using crtend.o to crtendS.o. On sparc it is especially visible
because crtend.o contains PIC-unfriendly code.

gcc:

2020-07-14  Sergei Trofimovich  

PR driver/96190
* config/sparc/linux.h: Use PIE_SPEC to select crtendS.o.
* config/sparc/linux64.h: ditto
---
 gcc/config/sparc/linux.h   | 2 +-
 gcc/config/sparc/linux64.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 81201e67a2f..13d1d60 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
+  "%{shared|" PIE_SPEC ":crtendS.o%s;:crtend.o%s} crtn.o%s\
%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* -mcpu=native handling only makes sense with compiler running on
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index a1a0efd8f28..be937dbaaf6 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -52,7 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
+  "%{shared|" PIE_SPEC ":crtendS.o%s;:crtend.o%s} crtn.o%s\
%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* The default code model.  */
-- 
2.27.0



[OBSOLETE][PATCH] PR preprocessor/94657: use $AR, not 'ar',

2020-05-28 Thread Sergei Trofimovich via Gcc-patches
On Thu, 7 May 2020 08:18:31 +0100
Sergei Trofimovich via Gcc-patches  wrote:

> On Wed, 22 Apr 2020 23:05:38 +0100
> Sergei Trofimovich  wrote:
> 
> > From: Sergei Trofimovich 
> > 
> > On system with 'ar' and '${CHOST}-ar' the latter is preferred.
> > as it might not match default 'ar'.
> > 
> > Bug is initially reported downstream as https://bugs.gentoo.org/718004.
> > 
> > libcpp/ChangeLog:
> > 
> > PR libcpp/94657
> > * Makefile.in: use @AR@ placeholder
> > * configure.ac: use AC_CHECK_TOOL to find 'ar'
> > * configure: regenerate
> > ---
> >  libcpp/ChangeLog|  7 
> >  libcpp/Makefile.in  |  2 +-
> >  libcpp/configure| 94 +
> >  libcpp/configure.ac |  1 +
> >  4 files changed, 103 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
> > index 307cf3add94..77145768a3d 100644
> > --- a/libcpp/ChangeLog
> > +++ b/libcpp/ChangeLog
> > @@ -1,3 +1,10 @@
> > +2020-04-22  Sergei Trofimovich  
> > +
> > +   PR preprocessor/94657: use $AR, not 'ar'
> > +   * Makefile.in: use @AR@ placeholder
> > +   * configure.ac: use AC_CHECK_TOOL to find 'ar'
> > +   * configure: regenerate
> > +
> >  2020-02-14  Jakub Jelinek  
> >  
> > Partially implement P1042R1: __VA_OPT__ wording clarifications
> > diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
> > index 8f8c8f65eb3..af7a0c6f73e 100644
> > --- a/libcpp/Makefile.in
> > +++ b/libcpp/Makefile.in
> > @@ -25,7 +25,7 @@ srcdir = @srcdir@
> >  top_builddir = .
> >  VPATH = @srcdir@
> >  INSTALL = @INSTALL@
> > -AR = ar
> > +AR = @AR@
> >  ARFLAGS = cru
> >  ACLOCAL = @ACLOCAL@
> >  AUTOCONF = @AUTOCONF@
> > diff --git a/libcpp/configure b/libcpp/configure
> > index 11da199083b..a6dcf5dcb61 100755
> > --- a/libcpp/configure
> > +++ b/libcpp/configure
> > @@ -657,6 +657,7 @@ ACLOCAL
> >  EGREP
> >  GREP
> >  CPP
> > +AR
> >  RANLIB
> >  ac_ct_CXX
> >  CXXFLAGS
> > @@ -1039,6 +1040,7 @@ do
> >| -silent | --silent | --silen | --sile | --sil)
> >  silent=yes ;;
> >  
> > +
> >-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
> >  ac_prev=sbindir ;;
> >-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
> > @@ -4008,6 +4010,98 @@ else
> >RANLIB="$ac_cv_prog_RANLIB"
> >  fi
> >  
> > +if test -n "$ac_tool_prefix"; then
> > +  # Extract the first word of "${ac_tool_prefix}ar", so it can be a 
> > program name with args.
> > +set dummy ${ac_tool_prefix}ar; ac_word=$2
> > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> > +$as_echo_n "checking for $ac_word... " >&6; }
> > +if ${ac_cv_prog_AR+:} false; then :
> > +  $as_echo_n "(cached) " >&6
> > +else
> > +  if test -n "$AR"; then
> > +  ac_cv_prog_AR="$AR" # Let the user override the test.
> > +else
> > +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> > +for as_dir in $PATH
> > +do
> > +  IFS=$as_save_IFS
> > +  test -z "$as_dir" && as_dir=.
> > +for ac_exec_ext in '' $ac_executable_extensions; do
> > +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> > +ac_cv_prog_AR="${ac_tool_prefix}ar"
> > +$as_echo "$as_me:${as_lineno-$LINENO}: found 
> > $as_dir/$ac_word$ac_exec_ext" >&5
> > +break 2
> > +  fi
> > +done
> > +  done
> > +IFS=$as_save_IFS
> > +
> > +fi
> > +fi
> > +AR=$ac_cv_prog_AR
> > +if test -n "$AR"; then
> > +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
> > +$as_echo "$AR" >&6; }
> > +else
> > +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> > +$as_echo "no" >&6; }
> > +fi
> > +
> > +
> > +fi
> > +if test -z "$ac_cv_prog_AR"; then
> > +  ac_ct_AR=$AR
> > +  # Extract the first word of "ar", so it can be a program name with args.
> > +set dummy ar; ac_word=$2
> > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> > +$as_echo_n "checking for $ac_word... " >&6; }
> > +if ${ac_cv_prog_ac_ct_AR+:} false; the

Re: [PATCH] PR preprocessor/94657: use $AR, not 'ar',

2020-05-07 Thread Sergei Trofimovich via Gcc-patches
On Wed, 22 Apr 2020 23:05:38 +0100
Sergei Trofimovich  wrote:

> From: Sergei Trofimovich 
> 
> On system with 'ar' and '${CHOST}-ar' the latter is preferred.
> as it might not match default 'ar'.
> 
> Bug is initially reported downstream as https://bugs.gentoo.org/718004.
> 
> libcpp/ChangeLog:
> 
>   PR libcpp/94657
>   * Makefile.in: use @AR@ placeholder
>   * configure.ac: use AC_CHECK_TOOL to find 'ar'
>   * configure: regenerate
> ---
>  libcpp/ChangeLog|  7 
>  libcpp/Makefile.in  |  2 +-
>  libcpp/configure| 94 +
>  libcpp/configure.ac |  1 +
>  4 files changed, 103 insertions(+), 1 deletion(-)
> 
> diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
> index 307cf3add94..77145768a3d 100644
> --- a/libcpp/ChangeLog
> +++ b/libcpp/ChangeLog
> @@ -1,3 +1,10 @@
> +2020-04-22  Sergei Trofimovich  
> +
> + PR preprocessor/94657: use $AR, not 'ar'
> + * Makefile.in: use @AR@ placeholder
> + * configure.ac: use AC_CHECK_TOOL to find 'ar'
> + * configure: regenerate
> +
>  2020-02-14  Jakub Jelinek  
>  
>   Partially implement P1042R1: __VA_OPT__ wording clarifications
> diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
> index 8f8c8f65eb3..af7a0c6f73e 100644
> --- a/libcpp/Makefile.in
> +++ b/libcpp/Makefile.in
> @@ -25,7 +25,7 @@ srcdir = @srcdir@
>  top_builddir = .
>  VPATH = @srcdir@
>  INSTALL = @INSTALL@
> -AR = ar
> +AR = @AR@
>  ARFLAGS = cru
>  ACLOCAL = @ACLOCAL@
>  AUTOCONF = @AUTOCONF@
> diff --git a/libcpp/configure b/libcpp/configure
> index 11da199083b..a6dcf5dcb61 100755
> --- a/libcpp/configure
> +++ b/libcpp/configure
> @@ -657,6 +657,7 @@ ACLOCAL
>  EGREP
>  GREP
>  CPP
> +AR
>  RANLIB
>  ac_ct_CXX
>  CXXFLAGS
> @@ -1039,6 +1040,7 @@ do
>| -silent | --silent | --silen | --sile | --sil)
>  silent=yes ;;
>  
> +
>-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
>  ac_prev=sbindir ;;
>-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
> @@ -4008,6 +4010,98 @@ else
>RANLIB="$ac_cv_prog_RANLIB"
>  fi
>  
> +if test -n "$ac_tool_prefix"; then
> +  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program 
> name with args.
> +set dummy ${ac_tool_prefix}ar; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_AR+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$AR"; then
> +  ac_cv_prog_AR="$AR" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +ac_cv_prog_AR="${ac_tool_prefix}ar"
> +$as_echo "$as_me:${as_lineno-$LINENO}: found 
> $as_dir/$ac_word$ac_exec_ext" >&5
> +break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +AR=$ac_cv_prog_AR
> +if test -n "$AR"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
> +$as_echo "$AR" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +
> +fi
> +if test -z "$ac_cv_prog_AR"; then
> +  ac_ct_AR=$AR
> +  # Extract the first word of "ar", so it can be a program name with args.
> +set dummy ar; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_ac_ct_AR+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$ac_ct_AR"; then
> +  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +ac_cv_prog_ac_ct_AR="ar"
> +$as_echo "$as_me:${as_lineno-$LINENO}: found 
> $as_dir/$ac_word$ac_exec_ext" >&5
> +break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +ac_ct_AR=$ac_cv_prog_ac_ct_AR
> +if test -n "$ac_ct_AR"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
> +$as_echo "$ac_ct_AR" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +  if test "x$ac_ct_AR" = x; then
> +AR=""
> +  else
> +case $cross_compiling:$ac_tool_warned in
> +yes:)
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not 
> prefixed with host triplet" >&5
> +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" 
> >&2;}
> +ac_tool_warned=yes ;;
> +esac
> +AR=$ac_ct_AR
> +  fi
> +else
> +  AR="$ac_cv_prog_AR"
> +fi
> +
>  
>  
>  ac_ext=c
> diff --git a/libcpp/configure.ac b/libcpp/configure.ac
> index 1779562a3a7..9ccf

Re: [PATCH] asan_test.C: disable -Wstringop-overflow, PR/93058

2020-01-24 Thread Sergei Trofimovich via gcc-patches
On Fri, 24 Jan 2020 22:20:43 +0100
Jakub Jelinek  wrote:

> On Fri, Jan 24, 2020 at 07:57:22AM +, slyfox.inbox.ru via gcc-patches 
> wrote:
> > From: Sergei Trofimovich 
> > 
> > From: Sergei Trofimovich 
> > 
> > asan's test allocates 2 pages via pvalloc(kPageSize + 100)
> > and makes sure dereference of 'kPageSize + 101' does not
> > trigger asan checks.
> > 
> > glibc's and gcc's malloc-like attribute checkers trigger
> > a warning:
> > asan_test.cc:129:22: error: writing 1 byte into a region
> > of size 0 [-Werror=stringop-overflow=]
> > 
> > As there is no easy way to convey pvalloc()'s granularity
> > to gcc let's just disable the warning for this test.
> > 
> > * g++.dg/asan/asan_test.C: disable -Wstringop-overflow.  
> 
> No.  That is a glibc bug and it has been fixed in glibc already, if we
> disabled this, we might never discovered it.

Aha, I assume it was fixed by 
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=768c83b7f60d82db6677e19dc51be9f341e0f3fc

I'll close gcc PR as invalid then.

Thank you!

-- 

  Sergei


pgpvHeT_dmPCm.pgp
Description: Цифровая подпись OpenPGP


Re: [PATCH v2] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-09-17 Thread Sergei Trofimovich via gcc-patches
On Mon, 17 Sep 2018 15:29:08 -0600
Jeff Law  wrote:

> On 9/17/18 3:18 PM, Sergei Trofimovich wrote:
> > On Sat, 28 Jul 2018 20:42:02 +0100
> > "slyfox.inbox.ru via gcc-patches"  wrote:
> >   
> >> From: Sergei Trofimovich 
> >>
> >> Cc: Ian Lance Taylor 
> >> Cc: Jeff Law 
> >> Cc: Andreas Schwab 
> >> Signed-off-by: Sergei Trofimovich 
> >> ---
> >>  libgcc/config/m68k/lb1sf68.S | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
> >> index 325a7c17d9b..d5240d4aa55 100644
> >> --- a/libgcc/config/m68k/lb1sf68.S
> >> +++ b/libgcc/config/m68k/lb1sf68.S
> >> @@ -435,6 +435,7 @@ $_exception_handler:
> >>.text
> >>FUNC(__mulsi3)
> >>.globl  SYM (__mulsi3)
> >> +  .hidden SYM (__mulsi3)
> >>  SYM (__mulsi3):
> >>movew   sp@(4), d0  /* x0 -> d0 */
> >>muluw   sp@(10), d0 /* x0*y1 */
> >> @@ -458,6 +459,7 @@ SYM (__mulsi3):
> >>.text
> >>FUNC(__udivsi3)
> >>.globl  SYM (__udivsi3)
> >> +  .hidden SYM (__udivsi3)
> >>  SYM (__udivsi3):
> >>  #ifndef __mcoldfire__
> >>movel   d2, sp@-
> >> @@ -534,6 +536,7 @@ L2:subql   IMM (1),d4
> >>.text
> >>FUNC(__divsi3)
> >>.globl  SYM (__divsi3)
> >> +  .hidden SYM (__divsi3)
> >>  SYM (__divsi3):
> >>movel   d2, sp@-
> >>  
> >> -- 
> >> 2.18.0
> >>  
> > 
> > Patch ping. Not sure which is preferable v1 (as other targets do) or v2.  
> Hmm, I thought Andreas NAK'd V1.  And I think Rich's comments
> essentially NAK'd V2.

Aha. I'm trying to clarify the desired state then to try to tweak
patch properly:

Current:
  - static library:
* global public __divsi3
  - shared library: 
* global public __divsi3

Desired:
  - static library:
* global hidden __divsi3 [ABI change:public->hidden]
  - shared library: 
* global public __divsi3 [no change]
* global hidden __divsi3_internal [change:new symbol for internal 
references]

Does that sound reasonable?
Should all targets follow the same pattern? I think they don't today.

v1 was a step in desired direction but without user-visible ABI change.

-- 

  Sergei


pgppmyTjSoYAk.pgp
Description: Цифровая подпись OpenPGP


Re: [PATCH v2] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-09-17 Thread Sergei Trofimovich via gcc-patches
On Sat, 28 Jul 2018 20:42:02 +0100
"slyfox.inbox.ru via gcc-patches"  wrote:

> From: Sergei Trofimovich 
> 
> Cc: Ian Lance Taylor 
> Cc: Jeff Law 
> Cc: Andreas Schwab 
> Signed-off-by: Sergei Trofimovich 
> ---
>  libgcc/config/m68k/lb1sf68.S | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
> index 325a7c17d9b..d5240d4aa55 100644
> --- a/libgcc/config/m68k/lb1sf68.S
> +++ b/libgcc/config/m68k/lb1sf68.S
> @@ -435,6 +435,7 @@ $_exception_handler:
>   .text
>   FUNC(__mulsi3)
>   .globl  SYM (__mulsi3)
> + .hidden SYM (__mulsi3)
>  SYM (__mulsi3):
>   movew   sp@(4), d0  /* x0 -> d0 */
>   muluw   sp@(10), d0 /* x0*y1 */
> @@ -458,6 +459,7 @@ SYM (__mulsi3):
>   .text
>   FUNC(__udivsi3)
>   .globl  SYM (__udivsi3)
> + .hidden SYM (__udivsi3)
>  SYM (__udivsi3):
>  #ifndef __mcoldfire__
>   movel   d2, sp@-
> @@ -534,6 +536,7 @@ L2:   subql   IMM (1),d4
>   .text
>   FUNC(__divsi3)
>   .globl  SYM (__divsi3)
> + .hidden SYM (__divsi3)
>  SYM (__divsi3):
>   movel   d2, sp@-
>  
> -- 
> 2.18.0
> 

Patch ping. Not sure which is preferable v1 (as other targets do) or v2.

-- 

  Sergei


pgpLNOtBofVZq.pgp
Description: Цифровая подпись OpenPGP


Re: [PATCH] libgcc: m68k: avoid TEXTRELs in shared library (PR 86224)

2018-07-29 Thread Sergei Trofimovich via gcc-patches
On Sat, 28 Jul 2018 21:11:22 -0400
Rich Felker  wrote:

> On Sat, Jul 28, 2018 at 08:47:33PM +0200, Andreas Schwab wrote:
> > On Jul 28 2018, sly...@inbox.ru wrote:
> >   
> > > From: Sergei Trofimovich 
> > >
> > > Cc: Ian Lance Taylor 
> > > Cc: Jeff Law 
> > > Cc: Andreas Schwab 
> > > Signed-off-by: Sergei Trofimovich 
> > > ---
> > >  libgcc/config/m68k/lb1sf68.S | 19 ++-
> > >  1 file changed, 14 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libgcc/config/m68k/lb1sf68.S b/libgcc/config/m68k/lb1sf68.S
> > > index 325a7c17d9b..16c6dc3f5a7 100644
> > > --- a/libgcc/config/m68k/lb1sf68.S
> > > +++ b/libgcc/config/m68k/lb1sf68.S
> > > @@ -435,7 +435,10 @@ $_exception_handler:
> > >   .text
> > >   FUNC(__mulsi3)
> > >   .globl  SYM (__mulsi3)
> > > + .globl  SYM (__mulsi3_internal)
> > > + .hidden SYM (__mulsi3_internal)  
> > 
> > No need for extra entry symbols, just mark the real entry point as
> > hidden, like in the static library.  
> 
> That's clearly not correct or valid, as these are public interfaces.
> If you make them hidden they'll be dropped from the dynamic symbol
> table of libgcc_s.so.
> 
> Of course for libgcc.a they need to be hidden (it's an ABI bug if
> they're not hidden there already but I think there's a separate layer
> of the build system that forces them to be hidden).
> 
> Rich

Oh, that's a good point! gcc/doc/libgcc.texi also suggests __
is the libgcc_s API. Would it make sense for gcc/doc/libgcc.texi to be
expanded to more explicitly articulate expectation of symbol visibility
on ELF platforms?

-- 

  Sergei


pgpFr9m_8Gb8s.pgp
Description: Цифровая подпись OpenPGP


[PATCH] gcc/configure.ac: add --disable-systemtap switch

2018-05-12 Thread Sergei Trofimovich via gcc-patches
From: Sergei Trofimovich 

Before the change systemtap probes were enabled
if target headers had sys/sdt.h at ./configure time.

After the change explicitly ask to enable or disable
for probe support and not rely on automagic dependency
discovery.

Bug: https://bugs.gentoo.org/654748
Bug: https://gcc.gnu.org/bugzilla/PR61257
Signed-off-by: Sergei Trofimovich 
---
 gcc/configure| 34 ++
 gcc/configure.ac | 30 ++
 2 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 7d69faf549d..5e96c4f99fc 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -946,6 +946,7 @@ enable_gnu_unique_object
 enable_linker_build_id
 enable_libssp
 enable_default_ssp
+enable_systemtap
 with_long_double_128
 with_long_double_format
 with_gc
@@ -1688,6 +1689,7 @@ Optional Features:
   compiler will always pass --build-id to linker
   --enable-libssp enable linking against libssp
   --enable-default-sspenable Stack Smashing Protection as default
+  --disable-systemtap enable systemtap static probe points [default=auto]
   --enable-maintainer-mode
   enable make rules and dependencies not useful (and
   sometimes confusing) to the casual installer
@@ -18448,7 +18450,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18451 "configure"
+#line 18453 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18554,7 +18556,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18557 "configure"
+#line 18559 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -29297,17 +29299,33 @@ fi
 
 # Test for  on the target.
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C 
library" >&5
+
+# Check whether --enable-systemtap was given.
+if test "${enable_systemtap+set}" = set; then :
+  enableval=$enable_systemtap; enable_systemtap=$enableval
+else
+  enable_systemtap=auto
+fi
+
+
+if test x$enable_systemtap != xno; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C 
library" >&5
 $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
-have_sys_sdt_h=no
-if test -f $target_header_dir/sys/sdt.h; then
-  have_sys_sdt_h=yes
+  have_sys_sdt_h=no
+  if test -f $target_header_dir/sys/sdt.h ; then
+have_sys_sdt_h=yes
 
 $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
 $as_echo "$have_sys_sdt_h" >&6; }
+  if test x$enable_systemtap = xyes ; then
+if test x$have_sys_sdt_h = xno ; then
+  as_fn_error "sys/sdt.h was not found" "$LINENO" 5
+fi
+  fi
+fi
 
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 36124b8ce90..8356e579a20 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5965,14 +5965,28 @@ AC_SUBST([enable_default_ssp])
 
 # Test for  on the target.
 GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
-AC_MSG_CHECKING(sys/sdt.h in the target C library)
-have_sys_sdt_h=no
-if test -f $target_header_dir/sys/sdt.h; then
-  have_sys_sdt_h=yes
-  AC_DEFINE(HAVE_SYS_SDT_H, 1,
-[Define if your target C library provides sys/sdt.h])
-fi
-AC_MSG_RESULT($have_sys_sdt_h)
+
+AC_ARG_ENABLE(systemtap,
+[AS_HELP_STRING([--disable-systemtap],
+  [enable systemtap static probe points [default=auto]])],
+  enable_systemtap=$enableval,
+  enable_systemtap=auto)
+
+if test x$enable_systemtap != xno; then
+  AC_MSG_CHECKING(sys/sdt.h in the target C library)
+  have_sys_sdt_h=no
+  if test -f $target_header_dir/sys/sdt.h ; then
+have_sys_sdt_h=yes
+AC_DEFINE(HAVE_SYS_SDT_H, 1,
+  [Define if your target C library provides sys/sdt.h])
+  fi
+  AC_MSG_RESULT($have_sys_sdt_h)
+  if test x$enable_systemtap = xyes ; then
+if test x$have_sys_sdt_h = xno ; then
+  AC_MSG_ERROR([sys/sdt.h was not found])
+fi
+  fi
+fi
 
 # Check if TFmode long double should be used by default or not.
 # Some glibc targets used DFmode long double, but with glibc 2.4
-- 
2.17.0