From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by sourceware.org (Postfix) with ESMTPS id 612333858289 for ; Thu, 22 Dec 2022 20:24:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 612333858289 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671740678; x=1703276678; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=PA1tmBWuv/4Hm0QmDmUaLpecW2wSwaZVKDk68UpJd24=; b=BS6awGcieo/BY8fKqKDbHKUTMdK2fdRe4IHDEaXc7FprG/Q0gL55pA4u O1pJwIznT6C829u/vlyOQf2hZJ9RPLb0Tzt9F90aYYTjYLExZG8pP13nc JPIlzCeofjwQe4STDuDRTa4eFJa0w7O385MOFDf7AMIZhcke1uUFaNXxu aggo/aZjSLaam/lG7BtP4zAcP620ZDw8BBTLowSeAi3edBw4jjn8idAkT QfYwF17urW2rkDXexwFxcTQRv+YAtkal1GMMf2coow/smztEhYEem2dCP 1xH+wogLz+mUl+d5sPVqjeGd8R4v7Q6H4UHGGuUgWGMx6iMbryHHcagYT Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="347364688" X-IronPort-AV: E=Sophos;i="5.96,266,1665471600"; d="scan'208";a="347364688" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2022 12:24:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="653997913" X-IronPort-AV: E=Sophos;i="5.96,266,1665471600"; d="scan'208";a="653997913" Received: from ultl2604.iul.intel.com (HELO localhost) ([172.28.48.47]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2022 12:24:37 -0800 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH 2/2] testsuite: add -O0 to Intel compilers if no 'optimize' option is given Date: Thu, 22 Dec 2022 21:24:17 +0100 Message-Id: <20221222202417.2042422-2-tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222202417.2042422-1-tankut.baris.aktemur@intel.com> References: <20221222202417.2042422-1-tankut.baris.aktemur@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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::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::operator == FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB::operator==(GDB const&) FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB::harder(char) FAIL: gdb.cp/cmpd-minsyms.exp: gdb_breakpoint: set breakpoint at GDB::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::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 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