From patchwork Sat Dec 22 17:16:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 1017883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-98751-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Hn32eYYX"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43MXGd6ZNwz9sCQ for ; Sun, 23 Dec 2018 04:16:41 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=Nvi iPzr5CX6yPW59QMrNje3R/NdF6AOukxQcZTZH18U7qLL/BwAgs8Kf4N72NipcguI 8gzh0Pd0a8UERLvoyosBbs40NL0s0oQPzJ+fIQsGII3iHZiFRx+aaFIH/2Yt1HCJ bxoI7cLRZYCP1wMuLv7O+goSIeQcmxXDnZuRqL6I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=VY5HVgb8G gNKRRk7h4tyB6+ee+4=; b=Hn32eYYX+y7uTue8y6O++9d8gfgL69rTBt9fN0xJY Somxtf/5CsZi4Rq97Ygf73AvWCJ+UHx+Wf863fwkhpYsq8ZIOJvfPa13Vbnaqqoj 9o3xRXzYmgkcYI7dIEr1sRdaC7JRiSeimVKd3tVWpmA3L3MIXTB03ez62EZFZmHi Y8= Received: (qmail 86315 invoked by alias); 22 Dec 2018 17:16:35 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 86306 invoked by uid 89); 22 Dec 2018 17:16:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH] Only build libm with -fno-math-errno Date: Sat, 22 Dec 2018 18:16:18 +0100 Message-Id: <20181222171618.15996-1-aurelien@aurel32.net> MIME-Version: 1.0 Commit 1294b1892e ("Add support for sqrt asm redirects") added the -fno-math-errno flag to build most of the glibc in order to enable GCC to inline math function. This allows GCC to optimize-out saving and restoring errno around function calls. In turn this causes strerror to set errno value to ENOMEM in case of an invalid error number and memory allocation error, which is not allowed by POSIX. This patch changes the build flags, building only libm with -fno-math-errno and all the remaining code with -fno-math-errno. This should be safe as libm doesn't contain any code saving and restoring errno. Tested on x86-64, no regression in the testsuite. Changelog: * Makeconfig: Build libm with -fno-math-errno but build the remaining code with -fmath-errno. --- ChangeLog | 6 ++++++ Makeconfig | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 881808dead..a64ce96bea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-12-22 Aurelien Jarno + + [BZ #24024] + * Makeconfig: Build libm with -fno-math-errno but build the remaining + code with -fmath-errno. + 2018-12-21 Joseph Myers [BZ #24023] diff --git a/Makeconfig b/Makeconfig index fbcf69e7c2..debdd3b357 100644 --- a/Makeconfig +++ b/Makeconfig @@ -831,8 +831,8 @@ endif # disable any optimization that assume default rounding mode. +math-flags = -frounding-math -# Build libc/libm using -fno-math-errno, but run testsuite with -fmath-errno. -+extra-math-flags = $(if $(filter libnldbl nonlib testsuite,$(in-module)),-fmath-errno,-fno-math-errno) +# Build libm using -fno-math-errno ++extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno) # We might want to compile with some stack-protection flag. ifneq ($(stack-protector),)