From patchwork Tue Oct 25 23:16:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1173 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp201147vsd; Tue, 25 Oct 2016 16:16:24 -0700 (PDT) X-Received: by 10.28.1.4 with SMTP id 4mr3273419wmb.10.1477437384776; Tue, 25 Oct 2016 16:16:24 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q188si6675162wma.120.2016.10.25.16.16.24; Tue, 25 Oct 2016 16:16:24 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@googlemail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5233689D19; Wed, 26 Oct 2016 02:16:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A02A689CFB for ; Wed, 26 Oct 2016 02:16:12 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id d128so2281209wmf.0 for ; Tue, 25 Oct 2016 16:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to; bh=n5DMJ0zR24eD5teAlF3I/PLkcu/PYRzKgGy+nMETucM=; b=jS6wMweCjbAjPcCMI4kMClh7bjPr+zRIF9mCM/lKSCKI28jHmflhmnyi+nKf0s5bKZ akPOPnIrrj63yHspcM9p7IjUof8b3pu99onVqxIRYNTzJHRoH/MlRFjGYk6bOeoJIuSE PY0zuCwN2aGVAQmRvMzShIsy46uIuiPiRTTrB1UetxUIcQ30lezap804gUw2QXZfu78y vvLHww7mLT8YpDTdXmzU9qefsXEMdT7uBiB4qZ23boJv2epoFNp17XbOQTnzStXRFw3S 9z6zr5ianRvuM4BLxFubqGgvMSlqgE7+gT36jbB3SxI8xf4jdxVdD0tyc6hJ280mTBeb D+AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to; bh=n5DMJ0zR24eD5teAlF3I/PLkcu/PYRzKgGy+nMETucM=; b=VVIvSiXcIeuNkji9Pvtqq8GadyOXYgDEN4C07ZN/MNzhd1mOgOpiWAoI5OcMOIfX/k klzLQTRf2DWA5u0AF2Vf2IHiLgyznbaJsVmyLRUVgQMZatwBVX8JrPKxZNfM2mIk8t2a CpeePcBSDCAgovVTWnt6vo4vvGnkFG3op64lV2E7/Yno/O5sAZMIonsWrFI32XMwp0yZ HzpT6s6jzkPe0sUDxf1VHx7LuR027TFLCSgju860yQcS6ddpv3p304qc3A8VYTDUJqc4 t0LOESn66F958PLuXVC6DotJaewQeWensFbrkENPWDAJW2kPRZI+QFIqLZGeuSOSXHTf qinQ== X-Gm-Message-State: ABUngvffRhaSPseV36dUjaiYs30FN8uaYdgN9vL0+kV2BjN/besXid85ZYXDsgvsAENdSg== X-Received: by 10.28.65.215 with SMTP id o206mr5793619wma.41.1477437374991; Tue, 25 Oct 2016 16:16:14 -0700 (PDT) Received: from [192.168.2.21] (p5B095228.dip0.t-ipconnect.de. [91.9.82.40]) by smtp.googlemail.com with ESMTPSA id w203sm6090814wmw.16.2016.10.25.16.16.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2016 16:16:14 -0700 (PDT) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: ffmpeg-devel@ffmpeg.org References: <8019a3b4-c436-a2fa-8d58-b7d387af4190@googlemail.com> Message-ID: <3cc24b4a-a4f4-ea25-501c-46c02ef68cd4@googlemail.com> Date: Wed, 26 Oct 2016 01:16:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] configure: make sure LTO does not optimize out the test functions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 25.10.2016 23:34, Carl Eugen Hoyos wrote: > 2016-10-25 19:19 GMT+02:00 Andreas Cadhalpun : > >> + # LTO could optimize out the test functions without this >> + echo "#if defined(__GNUC__) && __GNUC__ >= 4" >> + echo " #define USED __attribute__((used))" >> + echo "#else" >> + echo " #define USED" >> + echo "#endif" > > Why is the ugly #if - #else - #endif necessary? I'm under the impression that __attribute__((used)) is not available for all compilers, see e.g. libavutil/attributes.h. But thinking more about it, a better way is to actually use the functions so that LTO can't optimize them out. This avoids the ugly preprocessor checks. > Please mention ticket #5909 if it is related. Sure, new patch attached. By the way, this is not a regression in 3.1.5, but a fix included in that release allowed them to drop their distro-specific patch, exposing the problem with LTO. Best regards, Andreas From bb289a0b2b0948afa99227bcff188301c1143624 Mon Sep 17 00:00:00 2001 From: Andreas Cadhalpun Date: Tue, 25 Oct 2016 19:09:46 +0200 Subject: [PATCH] configure: make sure LTO does not optimize out the test functions Fixes trac ticket #5909 Bud-Id: https://bugs.gentoo.org/show_bug.cgi?id=598054 Signed-off-by: Andreas Cadhalpun --- configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 481f692..54faef1 100755 --- a/configure +++ b/configure @@ -1150,7 +1150,12 @@ check_func_headers(){ for func in $funcs; do echo "long check_$func(void) { return (long) $func; }" done - echo "int main(void) { return 0; }" + echo "int main(void) { int ret = 0;" + # LTO could optimize out the test functions without this + for func in $funcs; do + echo " ret |= ((intptr_t)check_$func) & 0xFFFF;" + done + echo "return ret; }" } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers } -- 2.9.3