From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from rn-mailsvcp-ppex-lapp44.apple.com (rn-mailsvcp-ppex-lapp44.apple.com [17.179.253.48]) by mx.groups.io with SMTP id smtpd.web11.15521.1660069960143197659 for ; Tue, 09 Aug 2022 11:32:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@apple.com header.s=20180706 header.b=Qe6DoiJT; spf=pass (domain: apple.com, ip: 17.179.253.48, mailfrom: afish@apple.com) Received: from pps.filterd (rn-mailsvcp-ppex-lapp44.rno.apple.com [127.0.0.1]) by rn-mailsvcp-ppex-lapp44.rno.apple.com (8.16.1.2/8.16.1.2) with SMTP id 279IAcFA024367; Tue, 9 Aug 2022 11:32:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=from : message-id : content-type : mime-version : subject : date : in-reply-to : cc : to : references; s=20180706; bh=9Qq8tQIsOra8TJI2S61+xHb7k6z6kJkPE1Vj0V1OCFo=; b=Qe6DoiJTb9gdWvrtb6QTLtTRQs/PjvNzl8CjRMptGq3yDWz379r6jOuj7m+YoNhDfBkS jbnKRWSq9ewEVcwkHyNFW4wN/OfJGgt53wzgHffKXSUWmcvvOPwnGI85e+maBtas08Bb hiNl8thhxkDJ7WYrNLC0HwBXGSS6XnuHggSsf+MWvdmq/mWQ1dwmXPZnJ1d+tptxS6Ka 6VI9X782UqXPNv76VxUy+jkSLhwmv1eiVkuybiNj5P7NzOdTCvNw0sI7B/gtCdqbGNCP EIAgjq/nFNE8acY07UuScimrlRjUezNrCZT5cNgYZwFlPxN5EBJkwyKTWdGxzHt+o5zp vQ== Received: from rn-mailsvcp-mta-lapp02.rno.apple.com (rn-mailsvcp-mta-lapp02.rno.apple.com [10.225.203.150]) by rn-mailsvcp-ppex-lapp44.rno.apple.com with ESMTP id 3hskt8s92h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 09 Aug 2022 11:32:39 -0700 Received: from rn-mailsvcp-mmp-lapp03.rno.apple.com (rn-mailsvcp-mmp-lapp03.rno.apple.com [17.179.253.16]) by rn-mailsvcp-mta-lapp02.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPS id <0RGD00EDG269P9F0@rn-mailsvcp-mta-lapp02.rno.apple.com>; Tue, 09 Aug 2022 11:32:34 -0700 (PDT) Received: from process_milters-daemon.rn-mailsvcp-mmp-lapp03.rno.apple.com by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) id <0RGD00500227OT00@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Tue, 09 Aug 2022 11:32:33 -0700 (PDT) X-Va-A: X-Va-T-CD: 42bcc3738539b68059edd2bc024c3397 X-Va-E-CD: 1d19ff8e0dc1477e0db873d2a2a61256 X-Va-R-CD: aadc08a6753be839f3d8644c8d805417 X-Va-CD: 0 X-Va-ID: 675686c2-d404-462f-a60f-769de28c59f1 X-V-A: X-V-T-CD: 42bcc3738539b68059edd2bc024c3397 X-V-E-CD: 1d19ff8e0dc1477e0db873d2a2a61256 X-V-R-CD: aadc08a6753be839f3d8644c8d805417 X-V-CD: 0 X-V-ID: e27f5b46-efee-4f4b-8d39-7e877f816e0b X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-08-09_03:2022-08-09,2022-08-09 signatures=0 Received: from smtpclient.apple (unknown [17.235.48.59]) by rn-mailsvcp-mmp-lapp03.rno.apple.com (Oracle Communications Messaging Server 8.1.0.18.20220407 64bit (built Apr 7 2022)) with ESMTPSA id <0RGD00BKQ268MF00@rn-mailsvcp-mmp-lapp03.rno.apple.com>; Tue, 09 Aug 2022 11:32:33 -0700 (PDT) From: "Andrew Fish" Message-id: <6F389C17-6413-44D7-B3EC-AE092026C118@apple.com> MIME-version: 1.0 (Mac OS X Mail 16.0 \(3731.0.8.1.1\)) Subject: Re: [edk2-devel] Building C static Library for UEFI Date: Tue, 09 Aug 2022 11:32:22 -0700 In-reply-to: <19101926-8aa0-8424-444b-495386572c74@gmail.com> Cc: Mike Kinney , "mikuback@linux.microsoft.com" , "Gaibusab, Jabeena B" , "Yao, Jiewen" To: edk2-devel-groups-io , ayushdevel1325@gmail.com References: <19101926-8aa0-8424-444b-495386572c74@gmail.com> X-Mailer: Apple Mail (2.3731.0.8.1.1) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-08-09_03:2022-08-09,2022-08-09 signatures=0 Content-type: multipart/alternative; boundary="Apple-Mail=_A6335590-8922-4C67-9EEE-76C2A97F2D3D" --Apple-Mail=_A6335590-8922-4C67-9EEE-76C2A97F2D3D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Did you figure this out? The per compiler flags come from BaseTools/Conf/tools_def.template. When yo= u do the edksetup.sh it gets copied to Conf/tools_def.ttxt and that is what= the build uses. The rules to generate makefiles come from BaseTools/Conf/b= uild_rule.template[2] and gets copied to Conf/build_rule.txt You can override the generic compiler flags via a [BuildOptions] section in= an INF [3] of DSC [4].=20 [1] https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/tools_def.= template [2] https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/build_rule= .template [3] https://github.com/tianocore/edk2/blob/master/UnitTestFrameworkPkg/Libr= ary/CmockaLib/CmockaLib.inf#L28=20 [4] https://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L1= 11 Thanks, Andrew Fish > On Jul 30, 2022, at 7:25 AM, Ayush Singh wrote= : >=20 > Hello everyone. There are some tests in Rust std that statically link to = a C static library to check ffi. Since if Rust is ever used in edk2, it wou= ld probably have to integrate with the existing C code. Thus, I thought rat= her than ignoring these tests, I wanted to make them work. >=20 > What Rust cargo needs is a static C library (`.lib`) to link against. I w= as not really able to find much about linking in UEFI applications. However= , from what I understand [1], edk2 already does do static link for C module= s, so it should technically be the same for Rust as well as long as a stati= c library can be generated from C code. I did look at the `build_rules` [2]= , but I don't know where the flags are defined. I think following rules: `C= -Code-File` -> `Object-File` should technically create a static library, bu= t would it work with projects outside edk2? Also, it would be great if some= one can also help me with the flags that need to be supplied if it can. >=20 >=20 >=20 > Yours Sincerely >=20 > Ayush Singh >=20 >=20 >=20 > [1]: https://edk2-docs.gitbook.io/edk-ii-build-specification/9_build_or_m= ake_stage/95_dynamic_link >=20 > [2]: https://github.com/tianocore/edk2/blob/e9150618ec91f79e70a1719ac8c19= 8bee34a99be/BaseTools/Conf/build_rule.template >=20 >=20 --Apple-Mail=_A6335590-8922-4C67-9EEE-76C2A97F2D3D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Did you figure this out?
<= br>
The per compiler flags come from BaseTools/Conf/tools_de= f.template. When you do the edksetup.sh it gets copied to Conf/tools_def.tt= xt and that is what the build uses. The rules to generate makefiles come fr= om BaseTools/Conf/build_rule.template[2] and gets copied to Conf/build= _rule.txt

You can override the generic compiler fl= ags via a [BuildOptions] section in an INF [3] of DSC [4]. 
[2] https://github.com/tianocore/edk2/blob/master/BaseTools/Conf/bui= ld_rule.template
[4] http= s://github.com/tianocore/edk2/blob/master/OvmfPkg/OvmfPkgX64.dsc#L111


Thanks,

And= rew Fish


On Jul= 30, 2022, at 7:25 AM, Ayush Singh <ayushdevel1325@gmail.com> wrote:<= /div>
=20 =20

Hello everyone. There are some tests in Rust std that statically link to a C static library to check ffi. Since if Rust is ever used in edk2, it would probably have to integrate with the existing C code. Thus, I thought rather than ignoring these tests, I wanted to make them work.

What Rust cargo needs is a static C= library (`.lib`) to link against. I was not really able to find much about linking in UEFI applications. However, from what I understand [1], edk2 already does do static link for C modules, so it should technically be the same for Rust as well as long as a static library can be generated from C code. I did look at the `build_rules` [2], but I don't know where the flags are defined. I think following rules: `C-Code-File` -> `Object-File` should technically create a static library, but would it work with projects outside edk2? Also, it would be great if someone can also help me with the flags that need to be supplied if it can.


Yours Sincerely

Ayush Singh


[1]: https://edk2= -docs.gitbook.io/edk-ii-build-specification/9_build_or_make_stage/95_dynami= c_link

[2]: https://github.com/tianocore/edk2/blob/e9150618ec91f79e70a1719ac8c= 198bee34a99be/BaseTools/Conf/build_rule.template

=20

--Apple-Mail=_A6335590-8922-4C67-9EEE-76C2A97F2D3D--