This is an automated email from the ASF dual-hosted git repository.

dingyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-sgx-sdk.git


The following commit(s) were added to refs/heads/master by this push:
     new d5f1d25  Fix switchless sample code
     new 3eeaf9a  Merge pull request #260 from xu-cheng/switchless
d5f1d25 is described below

commit d5f1d2540488e5e36ff5887499ad527e0379a284
Author: Cheng XU <[email protected]>
AuthorDate: Sat Aug 1 01:48:26 2020 +0000

    Fix switchless sample code
    
    In order to use the switchless feature of the SGX, the app binary needs
    to be linked with the following flags.
    
    ```
    -Wl,--whole-archive -lsgx_uswitchless -Wl,--no-whole-archive
    ````
    
    Noted that there is currently no proper way to pass custom link flags to
    all the binaries in a cargo project. As such, the `link_args` macro need
    to be set for each of Rust files with `main` methods.
    
    References:
    
    * Build flags used in Intel SGX sample code: 
https://github.com/intel/linux-sgx/blob/ce4a18d9a0963b14f717cc7462241cfadd233f55/SampleCode/Switchless/Makefile#L104
    * Rust tracking issue on `link_args`: 
https://github.com/rust-lang/rust/issues/29596
    * PR for `cargo:rustc-link-arg-bins` in cargo build script: 
https://github.com/rust-lang/cargo/pull/8441
---
 samplecode/switchless/app/src/main.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/samplecode/switchless/app/src/main.rs 
b/samplecode/switchless/app/src/main.rs
index aa08f6a..4de1afd 100644
--- a/samplecode/switchless/app/src/main.rs
+++ b/samplecode/switchless/app/src/main.rs
@@ -15,6 +15,9 @@
 // specific language governing permissions and limitations
 // under the License..
 
+#![feature(link_args)]
+#![link_args = "-Wl,--whole-archive -lsgx_uswitchless -Wl,--no-whole-archive"]
+
 extern crate sgx_types;
 extern crate sgx_urts;
 use sgx_types::*;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to