From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 64D523858D38 for ; Mon, 30 Jan 2023 04:24:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64D523858D38 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1675052652; bh=+uDYwAgXWUYBV8fNn04tHPzyustDGWNdhv7X9y+PVHc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iE7PksYvJi53fIR1WpnsneyYaAau5fuqUNn63FhclSHS36xvRqoUWznxtzyWLSQCo sXS6HB+BhpPfgq882QrqRRKmmh5d4LT+RC+IvzsbP4bjnx6yRFeHz33QvWyG2aDuK4 XV4lzMcIylLBpqPxoEOsZ8LVthn3Qy5mwSNV+xjw= Received: from [IPv6:240e:358:1141:bb00:dc73:854d:832e:2] (unknown [IPv6:240e:358:1141:bb00:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 185BA668E7; Sun, 29 Jan 2023 23:24:08 -0500 (EST) Message-ID: Subject: Re: Optimization auto-setting _FORTIFY_SOURCE ?? From: Xi Ruoyao To: Patrick Herbst Cc: gcc-help Date: Mon, 30 Jan 2023 12:23:57 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP,T_PDS_OTHER_BAD_TLD autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, 2023-01-29 at 18:05 -0500, Patrick Herbst via Gcc-help wrote: > Using GCC 9.4, I've noticed setting -O1 will set > _FORTIFY_SOURCE=3D2 >=20 > I'm able to see this by running > gcc -c -E -dM -O1 - < /dev/null | grep FORTIFY_SOURCE >=20 > But running the same command without -O1 doesn't set it. >=20 > Is this documented?=C2=A0 is this expected behavior?=C2=A0 I could not fi= nd any > reference to how optimization leads to setting this macro. >=20 > Any tips on where I can look, or what i'm missing to see this > connection? It's because your distro hacked GCC code to define _FORTIFY_SOURCE when optimization is enabled. Vanilla GCC does not have this behavior. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University