Skip to content

Commit d5f1d25

Browse files
committed
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`: rust-lang/rust#29596 * PR for `cargo:rustc-link-arg-bins` in cargo build script: rust-lang/cargo#8441
1 parent 5e45e93 commit d5f1d25

File tree

1 file changed

+3
-0
lines changed
  • samplecode/switchless/app/src

1 file changed

+3
-0
lines changed

samplecode/switchless/app/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License..
1717

18+
#![feature(link_args)]
19+
#![link_args = "-Wl,--whole-archive -lsgx_uswitchless -Wl,--no-whole-archive"]
20+
1821
extern crate sgx_types;
1922
extern crate sgx_urts;
2023
use sgx_types::*;

0 commit comments

Comments
 (0)