From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.151.62.25; helo=mail-in2.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in2.apple.com (mail-out2.apple.com [17.151.62.25]) (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 B9D53222DE125 for ; Mon, 12 Feb 2018 15:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1518479415; x=2382393015; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z1Zy7SIRBUnOKYpVS82BYweLRMP11zFWR0XfyzK7Ink=; b=K9nGCiFMJ5jx2xtzK6e3MRikjSSnmWJSaHz/XHlWKdVSGSX+eIPOq8ut8QfaTXB7 tRjZaPWEPvph/rPXti6yhzML9zNUqel3Y9ehkvAsJVKiYi7WvtmUR3Cpda1OyqXd Bh7/uJ5vsTmHjPkdoKP9kio96ChUnlkTfkQiw9+Qw7xklNUpJ04XCKiL+Kz9FJjm uI27/LITmkB8JxTAMlGW5G43Di2u1G/G53zPVyoJq2P2wkSrlzct9AbPlntiNJHq QWMazNsNO0Dh71w6L3bLkcAbX8Yy7oluYD21uP/4/bthvxL2c86sYM2X0uPdMS/X I97dkCptFHg2jqapjQb1tg==; Received: from relay23.apple.com (relay23.apple.com [17.171.128.104]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in2.apple.com (Apple Secure Mail Relay) with SMTP id 9E.A6.13823.738228A5; Mon, 12 Feb 2018 15:50:15 -0800 (PST) X-AuditID: 11973e11-d4eb59e0000035ff-e3-5a822837e058 Received: from ma1-mmpp-sz08.apple.com (ma1-mmpp-sz08.apple.com [17.171.128.176]) by relay23.apple.com (Apple SCV relay) with SMTP id 7F.38.06106.328228A5; Mon, 12 Feb 2018 15:49:55 -0800 (PST) MIME-version: 1.0 Received: from [17.234.214.76] by ma1-mmpp-sz08.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180130 64bit (built Jan 30 2018)) with ESMTPSA id <0P4200H3AA73SX80@ma1-mmpp-sz08.apple.com>; Mon, 12 Feb 2018 15:49:55 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Message-id: <5A1529A5-CF88-41CB-8C5C-CBC83B1ABE43@apple.com> Date: Mon, 12 Feb 2018 15:49:51 -0800 In-reply-to: <2075235543.4680791.1518163989435@mail.yahoo.com> Cc: "edk2-devel@lists.01.org" To: Ruslan Nikolaev References: <774033816.4534639.1518139941905.ref@mail.yahoo.com> <774033816.4534639.1518139941905@mail.yahoo.com> <339D4678-56CB-4195-AD81-9AE7D0CA2B13@apple.com> <113792737.4648564.1518159755787@mail.yahoo.com> <409605137.4680848.1518160327442@mail.yahoo.com> <29D926A0-3F6B-47AB-AE2E-BE2F256EA8A0@apple.com> <2075235543.4680791.1518163989435@mail.yahoo.com> X-Mailer: Apple Mail (2.3445.5.20) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsUiuLohQ9dcoynKYOINIYs9h44yW8z85evA 5NE9+x+Lx6xZh5kCmKK4bFJSczLLUov07RK4MnZ0zWYtmBBe8WbmBrYGxtVeXYycHBICJhKX X71n7mLk4hASWMcksejndSaYxJFDvxghEocZJQ59+MQKkuAVEJT4MfkeC4jNLBAmsadjGTtE 0VdGif1nvrKBJIQFxCXendnEDGKzCShLrJj/gR2i2UZiT8sbZogaI4mX2xaBDWIRUJX4OeM+ 2GZOATuJ5T8vQC0wl5hx4QtYXERAV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7uy67eJ9ZJ1Z5VT5tz/f1Hy3MnT+ wORg8yNtpSvDd7VY3qcab29O7r37ZHOR8ak9kVczPopMsBZd6OzWX7ODf3e9lf1kJZbijERD Leai4kQA0kaSc1sCAAA= X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: Re: Patch to fix EFIAPI definition X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Feb 2018 23:44:26 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Feb 9, 2018, at 12:13 AM, Ruslan Nikolaev wrote: > > Sorry, I did not answer this question last time. It is basically may not be very easy to change if you already have some assembly code which makes use of a specific calling convention. Plus there may be benefits of using register-based calls elsewhere. > > I thought, since EFIAPI aims to define a specific calling convention regardless of compilation flags, why not specify regparm(0) there as well. > Rusian, The primary goal of EFIAPI is to make sure it produces the correct code with the set of compilers that are supported by the edk2 project: https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/tools_def.template Thus it has the values that work correctly with the supported toolchains. It is very hard to support some conceptual toolchain if a version of that toolchain is not checked in as there is no way to test it. Thanks, Andrew Fish > On Friday, February 9, 2018 2:17 AM, Andrew Fish wrote: > > > > >> On Feb 8, 2018, at 11:12 PM, Ruslan Nikolaev wrote: >> >> Well, what I was implying is that if MdePkg (Ia32) headers are included in some UEFI program which itself is compiled with some custom register-based calling convention, current EFIAPI definition is insufficient. >> Current definition with cdecl attribute merely forces caller stack clean-up in gcc/clang for Ia32 >> So, if I build with '-mrtd' option (a callee cleans up the stack) current EFIAPI definition will take care of it. However, if in addition to that I specify -mregparm=1,2,3 to pass some parameters in registers, cdecl will not take care of it. >> EFIAPI for Ia32 wants all parameters in the stack. Therefore, it should be reasonable to specify regparm(0) as part of EFIAPI definition as well, so that regardless of mregparm parameter the compiler will generate correct code. >> > > Ruslan, > > Thanks for the info. I guess I still have the question of if you are making firmware why not solve this problem with compiler flags in the 1st place. > > Thanks, > > Andrew Fish > >> >> On Friday, February 9, 2018 1:59 AM, Andrew Fish wrote: >> >> >> >> >> On Feb 8, 2018, at 5:32 PM, Ruslan Nikolaev wrote: >> I submitted a bug report and a patch: https://bugzilla.tianocore.org/show_bug.cgi?id=870 >> It is very straight-forward. Can someone review it, and, hopefully, commit the change? >> >> >> Ruslan, >> Was there an example of how to code this? Sorry if I missed it, I'm getting a lot of email these days. >> Also what is you usage model? Clang is very cross compiler friendly and you can specify a triple to support the ABI you need. To get EFI supported on macOS tools we ended up open sourcing a triple to support the EFIAPI. If you look in https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/tools_def.template you will see that you can use Xcode to build EFIAPI if you pass -target x86_64-pc-win32-macho. >> I guess I'm asking the question if you really need to support multiple ABIs with clang? The best way to solve this in clang is to make it support EFIAPI. If you don't need multiple ABIs take a look at what we did with -target x86_64-pc-win32-macho, which tells clang to build EFIABI, but output a mach-O executable (we need the mach-O for our debugger). Basically with clang you could upstream what you need into the compiler you are using for other things... >> Thanks, >> Andrew Fish >> >> - Ruslan >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel >> >> >> >> >> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > > > > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel