DemesneGH opened a new pull request, #139:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/139

   This PR upgrades the Rust toolchain and standard library to 
`nightly-2024-05-15`, and the libc crate to `0.2.153`, both ported for OP-TEE 
targets. 
   
   Additionally, it includes various build script adjustments and code 
modifications necessary for this upgrade.
   
   #### Changes:
   
   - Port libc 0.2.153 and add OP-TEE implementation:
     - https://github.com/DemesneGH/libc/tree/optee
   
   - Pin Rust src and add OP-TEE std implementation:
     - https://github.com/DemesneGH/rust/tree/optee-xargo
   
   - No Need to Port `compiler_builtins`:
     - Removing the link argument `link-dead-code` helps avoid linking errors 
with math functions such as "undefined reference to log10".
   
   - Unify OP-TEE Target Names:
     - "aarch64-unknown-optee" for AARCH64
     - "arm-unknown-optee" for ARM32
   
   - optee-utee-rs:
     - Macros: upgrade for `quote` and `syn`.
     - Temporarily remove `systest` as it's not compatible with the new Rust 
version.
   
   - Examples:
     - hotp-rs:
       - Workaround for the unexpected address of the slice with zero-length. 
For stable Rust, it's a normal address, but for nightly, it's `0x1`, causing a 
TA panic when dereferencing.
     - tls_client-rs:
       - Upgrade to Ring `0.16.20` and Rustls `0.21.0`.
       - Update TA source code to accommodate API changes.
   
   - Fix some warnings on new version:
     - Symbolic link to `.cargo/config.toml`: Xargo uses `.cargo.config`, not 
`.cargo/config.toml` (required for the new cargo version).
     - Change `build_dependencies` to `build-dependencies`: deprecated in favor 
of `build-dependencies` and will not work in the 2024 edition.
   
   #### Discussions:
   
   - Xargo or `-Zbuild-std` When building std from source:
     - `cargo -Zbuild-std` is the recommended feature but has a bug that 
`[patch.crates-io]` does not work. This prevents replacing all libc 
dependencies for Rust std. Reference: 
https://github.com/rust-lang/wg-cargo-std-aware/issues/78.
     - Once our target is upstream, we can use `cargo -Zbuild-std` since libc 
(with OP-TEE implementation) will be merged into the official source.
     - I have the experimental version of using `cargo -Zbuild-std` at 
https://github.com/DemesneGH/rust-optee-trustzone-sdk/tree/upgrade-std-202405.
     - Using Xargo for now, although it hasn't been updated in a long time.
   
   - Upstream the OP-TEE Targets:
     - Benefits:
       - No need for the target JSON file in the SDK root.
       - Stay up-to-date without pinning toolchain version.
       - Download Rust src via `rustup add components rust-src`.
       - (Optional) Use `cargo -Zbuild-std` instead of Xargo.
     - Other considerations:
       - Even after upstreaming to a `tier-3` target, we cannot install our 
target via `rustup`, so `build-std` is still needed.
       - For `Rustls` and `Ring` (which use optee-utee-rs APIs such as random 
and time), we still need to port, or open PR to add our target.
   
   #### TODOs:
   
   - ARM32 TAs bug fix:
     - Rustc bug when linking: Rust compiler generates `symbols.o` for ARM32 
Object files with EABI version 0, causing error `source object xxx.rlib has 
EABI version 5, but target ta-xxx has EABI versionĀ 0`. This can be fixed by 
applying a patch to the Rust compiler. A PR to the Rust repository will be made.
     - tls_client-rs TA ldelf error:
       - `User mode data-abort at address xxx (write permission fault)` before 
loading TA into an address.
   - Code polishing
   
   This PR is a work in progress. Any comments would be appreciated. Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to