From patchwork Fri Apr 14 00:03:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Levinson X-Patchwork-Id: 3407 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp26841vsd; Thu, 13 Apr 2017 17:03:59 -0700 (PDT) X-Received: by 10.223.176.13 with SMTP id f13mr5255731wra.124.1492128239792; Thu, 13 Apr 2017 17:03:59 -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 10si401067wrv.17.2017.04.13.17.03.59; Thu, 13 Apr 2017 17:03:59 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 227F3688381; Fri, 14 Apr 2017 03:03:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from white.spiritone.com (white.spiritone.com [216.99.193.38]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17D04688381 for ; Fri, 14 Apr 2017 03:03:43 +0300 (EEST) Received: from [192.168.3.100] (184-100-162-109.ptld.qwest.net [184.100.162.109]) by white.spiritone.com (Postfix) with ESMTPSA id E624473402D3 for ; Thu, 13 Apr 2017 17:03:47 -0700 (PDT) To: FFmpeg development discussions and patches From: Aaron Levinson Message-ID: <06436432-eeb4-c5ee-b209-b2d95bcb024c@aracnet.com> Date: Thu, 13 Apr 2017 17:03:46 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Enhanced configure to improve compiler options associated with debugging with Visual C++ (MSVC) 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" From 558b957eb85a669899750b2e150eba7cdee8dcd9 Mon Sep 17 00:00:00 2001 From: Aaron Levinson Date: Thu, 13 Apr 2017 16:46:59 -0700 Subject: [PATCH] Enhanced configure to improve compiler options associated with debugging with Visual C++ (MSVC) Purpose: Enhanced configure to improve compiler options associated with debugging with Visual C++ (MSVC) Comments: -- configure: a) In msvc_common_flags() function, replaced the use of -Z7 with -Zi. Effectively, there was no point to using -Z7 anymore given than -debug is passed to the linker already (per the line "enabled debug && add_ldflags -debug" elsewhere in the file), which causes a .pdb to be generated anyway. -Z7 causes Codeview debug info to be placed in .obj files, while -Zi causes debug info to be placed in .pdb files. As a result of switching from -Z7 to -Zi, this may result in slightly faster builds with MSVC, since it is apparently slower to process Codeview debug info. b) In probe_cc() function, added _cflags_noopt declaration for MSVC. This is set to the following: "-Od -Og -MTd". See comments for more details. This is exposed when --disable-optimizations is used with configure. In addition, now adding -Zo (or -d2Zi+, depending on the compiler version) to all the different _cflags_ variables to make it easier to debug optimized builds. See changes and comments for further details. --- configure | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 684650a..7f2b653 100755 --- a/configure +++ b/configure @@ -3841,7 +3841,7 @@ msvc_common_flags(){ -std=c99) ;; # Common flags -fomit-frame-pointer) ;; - -g) echo -Z7 ;; + -g) echo -Zi ;; -fno-math-errno) ;; -fno-common) ;; -fno-signed-zeros) ;; @@ -4150,6 +4150,37 @@ probe_cc(){ _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" + # Need to use -Og with -Od because otherwise has link issues with + # "if (ARCH_...)" code. Unfortunately, this isn't quite the same as + # a fully debug build. If the Dead Code Elimination (DCE) compiler + # optimization requirement is ever removed, this can be replaced + # with just -Od. Note that the use of -Og results in a compiler + # deprecation warning. + # Also added -MTd to use the multithread, static, debug version of + # the run-time library. -MT appears to be the default otherwise. + # Possible TODO: revisit and potentially use -MD and -MDd for + # smaller binaries. + _cflags_noopt="-Od -Og -MTd" + cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p') + + # Make it easier to debug release builds. + # See https://msdn.microsoft.com/en-us/library/dn785163.aspx for more + # details. + # It may not be necessary to add -Zo to _cflags_noopt due to the use + # of -Od, but because -Og is also added currently, it is best to + # add -Zo for now to make sure the best debugging experience is + # possible. If the DCE compiler optimization requirement is ever + # removed, the _cflags_noopt lines can be removed. + if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then + _cflags_speed="${_cflags_speed} -Zo" + _cflags_size="${_cflags_size} -Zo" + _cflags_noopt="${_cflags_noopt} -Zo" + else + _cflags_speed="${_cflags_speed} -d2Zi+" + _cflags_size="${_cflags_size} -d2Zi+" + _cflags_noopt="${_cflags_noopt} -d2Zi+" + fi + if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else