From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2104) id 9F64C3858D38; Mon, 9 Jan 2023 08:56:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F64C3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673254611; bh=RUMENoN7UUdGEUnz4/nJt7jMluOtjifdouELVpcxGuY=; h=From:To:Subject:Date:From; b=CiyL95SQZ8xUk6WKb/FP7ku+24OyBI2RtKMk2a4JTvqjJ3tqGwlNNYqbYqk1V/7jd G/4ZSRAigZpH/bHuXwmFiJZK8f9ELLkWtlrP/DUWv6cn9OKSCbKDPNGYQAlpp6xtJZ LJ5tan4B3RpHdAjiBbMe+YdLvnoQF5ibrUy5rYAQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tankut Baris Aktemur To: gdb-cvs@sourceware.org Subject: [binutils-gdb] testsuite: add -O0 to Intel compilers if no 'optimize' option is given X-Act-Checkin: binutils-gdb X-Git-Author: Tankut Baris Aktemur X-Git-Refname: refs/heads/master X-Git-Oldrev: 0046ff60684eb16dcfafac350d37f4dc56c368e3 X-Git-Newrev: 23f3415896429142121e0acf8613caede0be35bf Message-Id: <20230109085651.9F64C3858D38@sourceware.org> Date: Mon, 9 Jan 2023 08:56:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D23f341589642= 9142121e0acf8613caede0be35bf commit 23f3415896429142121e0acf8613caede0be35bf Author: Tankut Baris Aktemur Date: Mon Jan 9 09:44:22 2023 +0100 testsuite: add -O0 to Intel compilers if no 'optimize' option is given =20 icpx/icx give the following warning if '-g' is used without '-O'. =20 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] =20 The warning makes dejagnu think that compilation has failed. E.g.: =20 $ make check TESTS=3D"gdb.cp/local.exp" RUNTESTFLAGS=3D"CXX_FOR_TARGE= T=3D'icpx' CC_FOR_TARGET=3Dicx" ... gdb compile failed, icpx: remark: Note that use of '-g' without any o= ptimization-level option will turn off most compiler optimizations similar = to use of '-O0'; use '-Rno-debug-disables-optimization' to disable this rem= ark [-Rdebug-disables-optimization] =20 =3D=3D=3D gdb Summary =3D=3D=3D =20 # of untested testcases 1 =20 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.: =20 $ make check TESTS=3D"gdb.cp/cmpd-minsyms.exp" RUNTESTFLAGS=3D"CXX_FO= R_TARGET=3D'icpx' CC_FOR_TARGET=3Dicx" ... FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB= ::a() const' FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB= ::b() volatile' FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at 'GDB= ::c() const volatile' FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<= int>::operator =3D=3D FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<= int>::operator=3D=3D(GDB 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::even_harder(char)" FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB<= int>::simple() =20 =3D=3D=3D gdb Summary =3D=3D=3D =20 # of expected passes 1 # of unexpected failures 9 =20 To fix both problems, pass the -O0 flag explicitly, if no optimization option is given. =20 With this patch we get, e.g.: =20 $ make check TESTS=3D"gdb.cp/cmpd-minsyms.exp gdb.cp/local.exp" RUNTE= STFLAGS=3D"CXX_FOR_TARGET=3D'icpx' CC_FOR_TARGET=3Dicx" ... =3D=3D=3D gdb Summary =3D=3D=3D =20 # of expected passes 19 # of known failures 1 =20 Approved-By: Tom Tromey Diff: --- 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 44f11a982dd..c41d4698d66 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4711,6 +4711,27 @@ proc gdb_compile {source dest type options} { lappend new_options "additional_flags=3D-diag-disable=3D10148" } =20 + # 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=3D*] =3D=3D -1 + && [lsearch $options additional_flags=3D-O*] =3D=3D -1} { + lappend new_options "optimize=3D-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 @@ -4755,6 +4776,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] !=3D -1 = } { # Fortran compile. set mod_path [standard_output_file ""] @@ -4764,6 +4800,11 @@ proc gdb_compile {source dest type options} { || [test_compiler_info {ifx-*} f90] } { lappend new_options "additional_flags=3D-module ${mod_path}" lappend new_options "additional_flags=3D-debug-parameters all" + + if {[lsearch $options optimize=3D*] =3D=3D -1 + && [lsearch $options additional_flags=3D-O*] =3D=3D -1} { + lappend new_options "optimize=3D-O0" + } } }