From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-195.mimecast.com (us-smtp-delivery-195.mimecast.com [216.205.24.195]) by sourceware.org (Postfix) with ESMTP id D606C3836C38 for ; Sat, 16 Jan 2021 20:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D606C3836C38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mbari.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=brent@mbari.org Received: from sleet.shore.mbari.org (sleet.shore.mbari.org [134.89.12.10]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-591-25zdkjsDMluxoAPGcEfVGQ-1; Sat, 16 Jan 2021 15:48:22 -0500 X-MC-Unique: 25zdkjsDMluxoAPGcEfVGQ-1 Received: from localhost (localhost [127.0.0.1]) by sleet.shore.mbari.org (Postfix) with ESMTP id 5988B81288C59 for ; Sat, 16 Jan 2021 12:48:21 -0800 (PST) X-Virus-Scanned: amavisd-new at sleet.shore.mbari.org Received: from sleet.shore.mbari.org ([127.0.0.1]) by localhost (sleet.shore.mbari.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KYjQqK54M-xq for ; Sat, 16 Jan 2021 12:48:21 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by sleet.shore.mbari.org (Postfix) with ESMTP id 3D75E81288C4A for ; Sat, 16 Jan 2021 12:48:21 -0800 (PST) Received: from [192.168.6.194] (unknown [134.89.18.154]) by sleet.shore.mbari.org (Postfix) with ESMTPSA for ; Sat, 16 Jan 2021 12:48:21 -0800 (PST) To: gcc-help@gcc.gnu.org From: Brent Roman Subject: In GCC 10.2, -O2 optimization enables more than docs suggest Organization: MBARI Message-ID: <0de29d09-268f-613d-4cf3-338746488c18@mbari.org> Date: Sat, 16 Jan 2021 12:48:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:46.0) Gecko/20100101 Firefox/46.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: mbari.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jan 2021 20:48:25 -0000 My very old, highly modified Matz Ruby 1.87 interpreter stopped working=20 when Debian switched from GCC-9 to GCC-10 The Ruby interpreter binary output from GCC-10 segfaults. However, if I reduce optimization from -O2 to -O1, the resulting=20 binaries work fine. I'd like to find which specific -O2 optimization is causing the failure=20 when run through gcc-10. But, when I specified -O1 followed by options explicitly enabling all=20 the specific optimizations that are supposed to be enabled by -O2, the resulting binary works fine.=C2=A0 Conversely, when I specify -O2,=20 followed by explicit options to *disable* all those options, the=20 resulting binary fails. Does anyone know what -O2 enables aside from the options documented on: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Optimize-Options.html#Optimiz= e-Options Here's an example of a gcc invocation with -O2 followed by disabling all=20 the -O2 specific optimizations: gcc -O2 -g -Wclobbered -fno-stack-protector -fno-align-functions=20 -fno-align-jumps=C2=A0 -fno-align-labels=C2=A0 -fno-align-loops -fno-caller= -saves=C2=A0=20 -fno-code-hoisting=C2=A0 -fno-crossjumping -fno-cse-follow-jumps=C2=A0=20 -fno-cse-skip-blocks -fno-delete-null-pointer-checks=C2=A0 -fno-devirtualiz= e=20 -fno-devirtualize-speculatively=C2=A0 -fno-expensive-optimizations=20 -fno-finite-loops=C2=A0 -fno-gcse=C2=A0 -fno-gcse-lm -fno-hoist-adjacent-lo= ads=C2=A0=20 -fno-inline-functions -fno-inline-small-functions=C2=A0=20 -fno-indirect-inlining -fno-ipa-bit-cp=C2=A0 -fno-ipa-cp=C2=A0 -fno-ipa-icf= =C2=A0=20 -fno-ipa-ra -fno-ipa-sra=C2=A0 -fno-ipa-vrp=20 -fno-isolate-erroneous-paths-dereference=C2=A0 -fno-lra-remat=20 -fno-optimize-sibling-calls=C2=A0 -fno-optimize-strlen -fno-partial-inlinin= g=C2=A0=20 -fno-peephole2 -fno-reorder-blocks-and-partition=C2=A0 -fno-reorder-functio= ns=20 -fno-rerun-cse-after-loop=C2=A0=C2=A0 -fno-schedule-insns -fno-schedule-ins= ns2=C2=A0=20 -fno-sched-interblock=C2=A0 -fno-sched-spec -fno-store-merging=C2=A0=20 -fno-strict-aliasing=C2=A0 -fno-thread-jumps -fno-tree-builtin-call-dce=C2= =A0=20 -fno-tree-pre -fno-tree-switch-conversion=C2=A0 -fno-tree-tail-merge=20 -fno-tree-vrp=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -DRUBY_EXPORT -D_GNU_SOURCE=3D1= =C2=A0 -I. -I.=C2=A0=C2=A0=C2=A0 -c main.c Thanks! --=20 Brent Roman MBARI Software Engineer Tel: (831) 775-1808 mailto:brent@mbari.org http://www.mbari.org/~brent