public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks
@ 2022-12-22 20:24 Tankut Baris Aktemur
  2022-12-22 20:24 ` [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given Tankut Baris Aktemur
  2023-01-05 19:57 ` [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Tankut Baris Aktemur @ 2022-12-22 20:24 UTC (permalink / raw)
  To: gdb-patches

From: Nils-Christian Kempke <nils-christian.kempke@intel.com>

Starting with icc/icpc version 2021.7.0 and higher both compilers emit a
deprecation remark when used.  E.g.

  >> icc --version
  icc: remark #10441: The Intel(R) C++ Compiler Classic (ICC) is
  deprecated and will be removed from product release in the second half
  of 2023. The Intel(R) oneAPI DPC++/C++ Compiler (ICX) is the recommended
  compiler moving forward. Please transition to use this compiler. Use
  '-diag-disable=10441' to disable this message.
  icc (ICC) 2021.7.0 20220713
  Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

  >> icpc --version
  icpc: remark #10441: The Intel(R) C++ Compiler Classic (ICC) is
  deprecated ...
  icpc (ICC) 2021.7.0 20220720
  Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

As the testsuite compile fails when unexpected output by the compiler is
seen this change in the compiler breaks all existing icc and icpc tests.
This patch makes the gdb testsuite more forgiving by a) allowing the
output of the remark when trying to figure out the compiler version
and by b) adding '-diag-disable=10441' to the compile command whenever
gdb_compile is called without the intention to detect the compiler.
---
 gdb/testsuite/lib/gdb.exp | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 132d538957c..39de114aab2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4715,24 +4715,36 @@ proc gdb_compile {source dest type options} {
 	set new_options [universal_compile_options]
     }
 
-    # Some C/C++ testcases unconditionally pass -Wno-foo as additional
-    # options to disable some warning.  That is OK with GCC, because
-    # by design, GCC accepts any -Wno-foo option, even if it doesn't
-    # support -Wfoo.  Clang however warns about unknown -Wno-foo by
-    # default, unless you pass -Wno-unknown-warning-option as well.
-    # We do that here, so that individual testcases don't have to
-    # worry about it.
+    # C/C++ specific settings.
     if {!$getting_compiler_info
 	&& [lsearch -exact $options rust] == -1
 	&& [lsearch -exact $options ada] == -1
 	&& [lsearch -exact $options f90] == -1
 	&& [lsearch -exact $options go] == -1} {
+
+	# Some C/C++ testcases unconditionally pass -Wno-foo as additional
+	# options to disable some warning.  That is OK with GCC, because
+	# by design, GCC accepts any -Wno-foo option, even if it doesn't
+	# support -Wfoo.  Clang however warns about unknown -Wno-foo by
+	# default, unless you pass -Wno-unknown-warning-option as well.
+	# We do that here, so that individual testcases don't have to
+	# worry about it.
 	if {[test_compiler_info "clang-*"] || [test_compiler_info "icx-*"]} {
 	    lappend new_options "additional_flags=-Wno-unknown-warning-option"
 	} elseif {[test_compiler_info "icc-*"]} {
 	    # This is the equivalent for the icc compiler.
 	    lappend new_options "additional_flags=-diag-disable=10148"
 	}
+
+	# Starting with 2021.7.0 (recognized as icc-20-21-7 by GDB) icc and
+	# icpc are marked as deprecated and both compilers emit the remark
+	# #10441.  To let GDB still compile successfully, we disable these
+	# warnings here.
+	if {([lsearch -exact $options c++] != -1
+	     && [test_compiler_info {icc-20-21-[7-9]} c++])
+	    || [test_compiler_info {icc-20-21-[7-9]}]} {
+	    lappend new_options "additional_flags=-diag-disable=10441"
+	}
     }
 
     # If the 'build-id' option is used, then ensure that we generate a
@@ -5002,6 +5014,17 @@ proc gdb_compile {source dest type options} {
     # Prune uninteresting compiler (and linker) output.
     regsub "Creating library file: \[^\r\n\]*\[\r\n\]+" $result "" result
 
+    # Starting with 2021.7.0 icc and icpc are marked as deprecated and both
+    # compilers emit a remark #10441.  To let GDB still compile successfully,
+    # we disable these warnings.  When $getting_compiler_info is true however,
+    # we do not yet know the compiler (nor its version) and instead prune these
+    # lines from the compiler output to let the get_compiler_info pass.
+    if {$getting_compiler_info} {
+	regsub \
+	    "(icc|icpc): remark #10441: The Intel\\(R\\) C\\+\\+ Compiler Classic \\(ICC\\) is deprecated\[^\r\n\]*" \
+	    "$result" "" result
+    }
+
     regsub "\[\r\n\]*$" "$result" "" result
     regsub "^\[\r\n\]*" "$result" "" result
     
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given
  2022-12-22 20:24 [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tankut Baris Aktemur
@ 2022-12-22 20:24 ` Tankut Baris Aktemur
  2023-01-05 19:59   ` Tom Tromey
  2023-01-05 19:57 ` [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Tankut Baris Aktemur @ 2022-12-22 20:24 UTC (permalink / raw)
  To: gdb-patches

icpx/icx give the following warning if '-g' is used without '-O'.

   icpx: remark: Note that use of '-g' without any optimization-level
   option will turn off most compiler optimizations similar to use of
   '-O0'; use '-Rno-debug-disables-optimization' to disable this
   remark [-Rdebug-disables-optimization]

The warning makes dejagnu think that compilation has failed.  E.g.:

  $ make check TESTS="gdb.cp/local.exp" RUNTESTFLAGS="CXX_FOR_TARGET='icpx' CC_FOR_TARGET=icx"
  ...
  gdb compile failed, icpx: remark: Note that use of '-g' without any optimization-level option will turn off most compiler optimizations similar to use of '-O0'; use '-Rno-debug-disables-optimization' to disable this remark [-Rdebug-disables-optimization]

                  === gdb Summary ===

  # of untested testcases         1

Furthermore, if no -O flag is passed, icx/icc optimize
the code by default.  This breaks assumptions in many GDB tests
that the code is unoptimized by default.  E.g.:

  $ make check TESTS="gdb.cp/cmpd-minsyms.exp" RUNTESTFLAGS="CXX_FOR_TARGET='icpx' CC_FOR_TARGET=icx"
  ...
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB<int>::a() const'
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB<int>::b() volatile'
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB<int>::c() const volatile'
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<int>::operator ==
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<int>::operator==(GDB<int> const&)
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<char>::harder(char)
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<int>::harder(int)
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at "int GDB<char>::even_harder<int>(char)"
  FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<int>::simple()

                  === gdb Summary ===

  # of expected passes            1
  # of unexpected failures        9

To fix both problems, pass the -O0 flag explicitly, if no optimization
option is given.

With this patch we get, e.g.:

  $ make check TESTS="gdb.cp/cmpd-minsyms.exp gdb.cp/local.exp" RUNTESTFLAGS="CXX_FOR_TARGET='icpx' CC_FOR_TARGET=icx"
  ...
                  === gdb Summary ===

  # of expected passes            19
  # of known failures             1
---
 gdb/testsuite/lib/gdb.exp | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 39de114aab2..ee9d9d14bac 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4736,6 +4736,27 @@ proc gdb_compile {source dest type options} {
 	    lappend new_options "additional_flags=-diag-disable=10148"
 	}
 
+	# icpx/icx give the following warning if '-g' is used without '-O'.
+	#
+	#   icpx: remark: Note that use of '-g' without any
+	#   optimization-level option will turn off most compiler
+	#   optimizations similar to use of '-O0'
+	#
+	# The warning makes dejagnu think that compilation has failed.
+	#
+	# Furthermore, if no -O flag is passed, icx and icc optimize
+	# the code by default.  This breaks assumptions in many GDB
+	# tests that the code is unoptimized by default.
+	#
+	# To fix both problems, pass the -O0 flag explicitly, if no
+	# optimization option is given.
+	if {[test_compiler_info "icx-*"] || [test_compiler_info "icc-*"]} {
+	    if {[lsearch $options optimize=*] == -1
+		&& [lsearch $options additional_flags=-O*] == -1} {
+		lappend new_options "optimize=-O0"
+	    }
+	}
+
 	# Starting with 2021.7.0 (recognized as icc-20-21-7 by GDB) icc and
 	# icpc are marked as deprecated and both compilers emit the remark
 	# #10441.  To let GDB still compile successfully, we disable these
@@ -4780,6 +4801,21 @@ proc gdb_compile {source dest type options} {
     # option is not supported so instead use the -module flag.
     # Additionally, Intel compilers need the -debug-parameters flag set to
     # emit debug info for all parameters in modules.
+    #
+    # ifx gives the following warning if '-g' is used without '-O'.
+    #
+    #   ifx: remark #10440: Note that use of a debug option
+    #   without any optimization-level option will turnoff most
+    #   compiler optimizations similar to use of '-O0'
+    #
+    # The warning makes dejagnu think that compilation has failed.
+    #
+    # Furthermore, if no -O flag is passed, Intel compilers optimize
+    # the code by default.  This breaks assumptions in many GDB
+    # tests that the code is unoptimized by default.
+    #
+    # To fix both problems, pass the -O0 flag explicitly, if no
+    # optimization option is given.
     if { !$getting_compiler_info && [lsearch -exact $options f90] != -1 } {
 	# Fortran compile.
 	set mod_path [standard_output_file ""]
@@ -4789,6 +4825,11 @@ proc gdb_compile {source dest type options} {
 		   || [test_compiler_info {ifx-*} f90] } {
 	    lappend new_options "additional_flags=-module ${mod_path}"
 	    lappend new_options "additional_flags=-debug-parameters all"
+
+	    if {[lsearch $options optimize=*] == -1
+		&& [lsearch $options additional_flags=-O*] == -1} {
+		lappend new_options "optimize=-O0"
+	    }
 	}
     }
 
-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks
  2022-12-22 20:24 [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tankut Baris Aktemur
  2022-12-22 20:24 ` [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given Tankut Baris Aktemur
@ 2023-01-05 19:57 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2023-01-05 19:57 UTC (permalink / raw)
  To: Tankut Baris Aktemur via Gdb-patches; +Cc: Tankut Baris Aktemur

>>>>> Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes:

> From: Nils-Christian Kempke <nils-christian.kempke@intel.com>
> Starting with icc/icpc version 2021.7.0 and higher both compilers emit a
> deprecation remark when used.  E.g.
...
> As the testsuite compile fails when unexpected output by the compiler is
> seen this change in the compiler breaks all existing icc and icpc tests.
> This patch makes the gdb testsuite more forgiving by a) allowing the
> output of the remark when trying to figure out the compiler version
> and by b) adding '-diag-disable=10441' to the compile command whenever
> gdb_compile is called without the intention to detect the compiler.

Thank you.  This looks good to me.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given
  2022-12-22 20:24 ` [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given Tankut Baris Aktemur
@ 2023-01-05 19:59   ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2023-01-05 19:59 UTC (permalink / raw)
  To: Tankut Baris Aktemur via Gdb-patches; +Cc: Tankut Baris Aktemur

>>>>> Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> writes:

> icpx/icx give the following warning if '-g' is used without '-O'.
>    icpx: remark: Note that use of '-g' without any optimization-level
>    option will turn off most compiler optimizations similar to use of
>    '-O0'; use '-Rno-debug-disables-optimization' to disable this
>    remark [-Rdebug-disables-optimization]

...

> To fix both problems, pass the -O0 flag explicitly, if no optimization
> option is given.

Thank you.  This is ok.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-05 19:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 20:24 [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tankut Baris Aktemur
2022-12-22 20:24 ` [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given Tankut Baris Aktemur
2023-01-05 19:59   ` Tom Tromey
2023-01-05 19:57 ` [PATCH 1/2] testsuite: handle icc and icpc deprecated remarks Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).