From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83D733857C7A; Fri, 9 Sep 2022 10:32:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83D733857C7A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662719570; bh=LMWkWF+uz90v0CDimXfksVcvzcQESQHuFs9iKe8fvpQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Nn4ZHisfZm/zu57V2LPivhEEv03rc0Ze8teKB/2ZmED+CAxwJCzMX4PjVd6zvcBM1 3uUpyXyQ/NuhvZQt2owaqArlaljYIL+NssQIEOBhp5hCkSuMnk5l4vCxccda3s0Dn7 WCZfM7Q67RNCf/JSh3O384BK/cOAOraW9tzwGCQM= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/55522] -funsafe-math-optimizations is unexpectedly harmful, especially w/ -shared Date: Fri, 09 Sep 2022 10:32:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.6.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55522 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #17 from Richard Biener --- Note that when a shared library wants -ffast-math like behavior (FTZ, etc.) _not_ linking crtfastmath.o will cause its behavior to depend on the process loading it and whether that sets the appropriate flags or not. That might also cau= se highly surprising effects. That said, a "true fix" would redesign how these things work and make FTZ part of the instruction encoding. I suppose setting/restoring the control word around all public API of a translation unit (and with LTO a bit more optimized) would be prohibitly expensive. Short of dropping the feature or re-implementing it, for example in the dynamic loader via some ELF annotations with documented behavior on "mismatch", I don't see any fix for this bug besides asking users to conciously not link with -ffast-math when building shared libraries - unless that's intended.=