From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 337D72095DE72 for ; Tue, 22 Aug 2017 09:01:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 939CE859FA; Tue, 22 Aug 2017 16:04:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 939CE859FA Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-92.phx2.redhat.com [10.3.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CEFD5D724; Tue, 22 Aug 2017 16:04:05 +0000 (UTC) To: Paolo Bonzini , Ard Biesheuvel Cc: "Shi, Steven" , edk2-devel-01 , Alex Williamson , "Justen, Jordan L" , "Gao, Liming" , "Kinney, Michael D" References: <20170811003426.2332-1-lersek@redhat.com> <20170811003426.2332-2-lersek@redhat.com> <06C8AB66E78EE34A949939824ABE2B313B560EB2@shsmsx102.ccr.corp.intel.com> <787f4528-980e-8c71-2804-0e8be2c935aa@redhat.com> <06C8AB66E78EE34A949939824ABE2B313B56176B@shsmsx102.ccr.corp.intel.com> <092446e6-0900-7eb3-d071-b88abcdadfa9@redhat.com> <06C8AB66E78EE34A949939824ABE2B313B5673A1@shsmsx102.ccr.corp.intel.com> <3c593a67-bffc-45db-e65c-8d0242ddada4@redhat.com> From: Laszlo Ersek Message-ID: <41343c95-d7a7-fa07-1d45-93d30b75d163@redhat.com> Date: Tue, 22 Aug 2017 18:04:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 22 Aug 2017 16:04:09 +0000 (UTC) Subject: Re: [PATCH 1/1] BaseTools/tools_def.template: revert to large code model for X64/GCC5/LTO X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Aug 2017 16:01:37 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/22/17 16:15, Paolo Bonzini wrote: > On 22/08/2017 16:03, Ard Biesheuvel wrote: >> On 22 August 2017 at 14:27, Paolo Bonzini wrote: >>> On 22/08/2017 13:59, Laszlo Ersek wrote: >>>> This seems to suggest that "-pie" is the *master* switch (used only when >>>> linking), and "-fpie" is a *prerequisite* for it (to be used both when >>>> linking and compiling). Is this right? >>>> >>>> If so, then I think this is a gcc usability bug. We don't generally >>>> start our thinking from the linker side. The above implies that the >>>> simple (hosted) command line: >>>> >>>> $ gcc -o example -fpie source1.c source2.c >>>> >>>> could also result in miscompilation, because "-pie" is not given, only >>>> "-fpie". >>> >>> No, GCC should add -pie on its own. >>> >> >> I disagree. PIE linking and PIE code generation are two completely >> different things. > > What I'm saying is that GCC should add -pie on its own if you add -fpie > to the linker command line. Yes, that's my point, from a usability perspective. While I hope to understand Ard's explanation (and it seems to confirm that "-fpie" at compilation is a 'prerequisite' for "-pie" at linking), again, this simply isn't how humans think about building binaries. If we are required to call the compiler frontend for all purposes -- and we seem to be required --, then we shouldn't have to express the same end goal in different ways for different link-editing phases. > But that would require changes to the > compiler driver. > > That said, the extra "-Wl," in "-Wl,-pie" is not necessary; the compiler > driver knows "-pie" and swallows it when compiling (and passes it to the > linker). Now *that* I can get behind. If this works, then please let us do it -- replace "-fpie" with "-pie" in GCC44_X64_CC_FLAGS, and add no "-Wl," stuff to any DLINK defines. Thanks! Laszlo