From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mx.groups.io with SMTP id smtpd.web09.3541.1659191087764093659 for ; Sat, 30 Jul 2022 07:24:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ImzPMed1; spf=pass (domain: gmail.com, ip: 209.85.214.180, mailfrom: ayushdevel1325@gmail.com) Received: by mail-pl1-f180.google.com with SMTP id o3so6882977ple.5 for ; Sat, 30 Jul 2022 07:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc; bh=1zLVOlaRycnrZvZ6VJ+dy0MbfzbX6yj4/97qu9PLcjg=; b=ImzPMed1zLVQA8NZaMLtyh4gpG1t+YX4vDNvWv3ulpNykDdlpRrRFPasjOleyLzW9v 2itvFYQjw55oZ1UJ5njkfQrhiW9Koh0M589kBbdQ4ngo2tY6hVxQNxnVto6T8zSMYFBb tU/b77/mrVykcLsEPmdQdafWdi1itxPvZv7Fum8yet3WF4pBoJ8tFQ6k56fZnYXoN/8J qwlh7YhqB4zMOi8xpSQO1sPh6smfjes1UbBbfvn+jQDFT+LaBKQMfAd+oJr7HRs4yEN2 V0yxQqzPF8k2v0Mdq8QQmUxOH1FQjAdThiT09lbdOlu7o0PE7Bg1X1CTyuIcO5l9QV5E DlJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=1zLVOlaRycnrZvZ6VJ+dy0MbfzbX6yj4/97qu9PLcjg=; b=7E5wkY/dscpphAymlOgJRnAeNsjWgQElXMD97zdhu2KY+gdReeNIE+lJMlmQBqfRKH DRmzxqxiz3sqeeAXG5LIDm1kY3seG9gs6IEAbT+w8x20XRIOsakfsKcP2cNnQ86lFYNn JTNbTYHiFjse+MScFRQU0/Kq+aR8E0z615zYJTttt2WAcGTjbwLz/1Xx4/Kv//V0d4dU 5YpAEG8mVfr+KfwD/mGo1b1WoYX0iryAg5BnC44naCRBtevIRb3WwKKAxyd72L6I4xj7 cI2TxgR+X5HZfW/hGdDmAXbOCs+OaYjYT7vOQ+0jTuQ/etK1uxYdEPNlspbStgVjJEMx RiJw== X-Gm-Message-State: ACgBeo3ZhKPWJ7u78uwARImW0AQFe90baIwNGu7QsfewBGpOzz5ed/W/ l1nM+64wbQ4At4SZ/ICNmKlcrB8/K30= X-Google-Smtp-Source: AA6agR6rUT0WHhIK+bEE9C4iLyM9LWM7EMtvxZrEMcVPgIMQh7SO79P/HF+k3s6OVSUMoWuZuNh+tw== X-Received: by 2002:a17:902:f68f:b0:16d:a4d6:6d0a with SMTP id l15-20020a170902f68f00b0016da4d66d0amr8561283plg.86.1659191086866; Sat, 30 Jul 2022 07:24:46 -0700 (PDT) Return-Path: Received: from ?IPV6:2401:4900:1f3e:60eb:c324:41d3:ede8:a68c? ([2401:4900:1f3e:60eb:c324:41d3:ede8:a68c]) by smtp.gmail.com with ESMTPSA id x9-20020a170902ec8900b0016c3affe60esm5964018plg.46.2022.07.30.07.24.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Jul 2022 07:24:46 -0700 (PDT) Message-ID: <19101926-8aa0-8424-444b-495386572c74@gmail.com> Date: Sat, 30 Jul 2022 19:55:31 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: edk2-devel-groups-io Cc: Mike Kinney , "mikuback@linux.microsoft.com" , Andrew Fish , "Gaibusab, Jabeena B" , "Yao, Jiewen" From: "Ayush Singh" Subject: Building C static Library for UEFI Content-Type: multipart/alternative; boundary="------------06G0WyHGimAjYSBD6mfd8d7t" Content-Language: en-US --------------06G0WyHGimAjYSBD6mfd8d7t Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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_dynamic_link [2]: https://github.com/tianocore/edk2/blob/e9150618ec91f79e70a1719ac8c198bee34a99be/BaseTools/Conf/build_rule.template --------------06G0WyHGimAjYSBD6mfd8d7t Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

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_dynamic_link

[2]: https://github.com/tianocore/edk2/blob/e9150618ec91f79e70a1719ac8c198bee34a99be/BaseTools/Conf/build_rule.template

--------------06G0WyHGimAjYSBD6mfd8d7t--