You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by iv...@apache.org on 2026/03/17 15:38:25 UTC

(teaclave-trustzone-sdk) branch main updated (855efec -> 0601329)

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

ivila pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git


    from 855efec  std: migrate from xargo to cargo -Z build-std (#286)
     new 5fa0f4e  docker/dev: update scripts
     new 9f56f5e  cargo-optee: update for new building approach
     new 0601329  docs: remove Xargo related descriptions

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/ci.yml                 |  8 -------
 cargo-optee/README.md                    | 15 +++++++------
 cargo-optee/aarch64-unknown-optee.json   | 38 ++++++++++++++++----------------
 cargo-optee/arm-unknown-optee.json       |  5 +++--
 cargo-optee/src/ta_builder.rs            | 35 +++++++++++++++++++----------
 ci/build.sh                              | 14 ++++++++++++
 docs/emulate-and-dev-in-docker-std.md    |  2 +-
 scripts/runtime/config/ta/no-std/aarch64 |  4 ++--
 scripts/runtime/config/ta/no-std/arm32   |  4 ++--
 scripts/runtime/config/ta/std/aarch64    |  6 +++--
 scripts/runtime/config/ta/std/arm32      |  6 +++--
 scripts/setup-std/setup_rust_std.sh      | 30 ++++++++++++++-----------
 scripts/setup/install_dependencies.sh    |  3 ++-
 13 files changed, 99 insertions(+), 71 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


(teaclave-trustzone-sdk) 03/03: docs: remove Xargo related descriptions

Posted by iv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git

commit 060132977976dcb68ce97098e5b57857c6ecd408
Author: Yuan Zhuang <yu...@apache.org>
AuthorDate: Tue Mar 17 05:25:22 2026 +0000

    docs: remove Xargo related descriptions
---
 docs/emulate-and-dev-in-docker-std.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/emulate-and-dev-in-docker-std.md b/docs/emulate-and-dev-in-docker-std.md
index 08e6972..624d292 100644
--- a/docs/emulate-and-dev-in-docker-std.md
+++ b/docs/emulate-and-dev-in-docker-std.md
@@ -105,7 +105,7 @@ note these important target differences:
 
 | Configuration | TA Target | Build Tool | Host Target |
 |---------------|-----------|------------|-------------|
-| `std/*` | `*-unknown-optee` | `xargo` | `*-unknown-linux-gnu` |
+| `std/*` | `*-unknown-optee` | `cargo -Z build-std` | `*-unknown-linux-gnu` |
 | `no-std/*` | `*-unknown-linux-gnu` | `cargo` | `*-unknown-linux-gnu` |
 
 **Example std build output:**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


(teaclave-trustzone-sdk) 01/03: docker/dev: update scripts

Posted by iv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git

commit 5fa0f4ef362105823e00c5d914a8f99424c2d743
Author: Yuan Zhuang <yu...@apache.org>
AuthorDate: Tue Mar 17 05:22:09 2026 +0000

    docker/dev: update scripts
---
 .github/workflows/ci.yml                 |  8 --------
 scripts/runtime/config/ta/no-std/aarch64 |  4 ++--
 scripts/runtime/config/ta/no-std/arm32   |  4 ++--
 scripts/runtime/config/ta/std/aarch64    |  6 ++++--
 scripts/runtime/config/ta/std/arm32      |  6 ++++--
 scripts/setup-std/setup_rust_std.sh      | 30 +++++++++++++++++-------------
 scripts/setup/install_dependencies.sh    |  3 ++-
 7 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index eaf578a..4d2d3f7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -112,8 +112,6 @@ jobs:
         run: |
           # Run entrypoint.sh to set up the bash profile
           /entrypoint.sh true
-          # Install jq for JSON parsing
-          apt-get update && apt-get install -y jq
       - name: Test cargo-optee no-std build (aarch64)
         shell: bash -l {0}  # Use login shell to load the profile
         run: |
@@ -132,8 +130,6 @@ jobs:
         run: |
           # Run entrypoint.sh to set up the bash profile
           /entrypoint.sh true
-          # Install jq for JSON parsing
-          apt-get update && apt-get install -y jq
       - name: Test cargo-optee no-std build (arm32)
         shell: bash -l {0}  # Use login shell to load the profile
         run: |
@@ -158,8 +154,6 @@ jobs:
         run: |
           # Run entrypoint.sh to set up the bash profile
           /entrypoint.sh true
-          # Install jq for JSON parsing
-          apt-get update && apt-get install -y jq
       - name: Test cargo-optee std build (aarch64)
         shell: bash -l {0}  # Use login shell to load the profile
         run: |
@@ -180,8 +174,6 @@ jobs:
         run: |
           # Run entrypoint.sh to set up the bash profile
           /entrypoint.sh true
-          # Install jq for JSON parsing
-          apt-get update && apt-get install -y jq
       - name: Test cargo-optee std build (arm32)
         shell: bash -l {0}  # Use login shell to load the profile
         run: |
diff --git a/scripts/runtime/config/ta/no-std/aarch64 b/scripts/runtime/config/ta/no-std/aarch64
index f6dc9f0..c4598c8 100644
--- a/scripts/runtime/config/ta/no-std/aarch64
+++ b/scripts/runtime/config/ta/no-std/aarch64
@@ -19,7 +19,7 @@ export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm64"
 export TARGET_TA="aarch64-unknown-linux-gnu"
 export CROSS_COMPILE_TA="aarch64-linux-gnu-"
 
-# sdk example using this env to distinguish between xargo and cargo
-export BUILDER="cargo"
+# CARGO_FLAGS is empty for no-std TAs
+export CARGO_FLAGS=""
 # Initialize FEATURES as empty for no-std TAs
 export FEATURES=""
\ No newline at end of file
diff --git a/scripts/runtime/config/ta/no-std/arm32 b/scripts/runtime/config/ta/no-std/arm32
index 499ee57..974e347 100644
--- a/scripts/runtime/config/ta/no-std/arm32
+++ b/scripts/runtime/config/ta/no-std/arm32
@@ -19,7 +19,7 @@ export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm32"
 export TARGET_TA="arm-unknown-linux-gnueabihf"
 export CROSS_COMPILE_TA="arm-linux-gnueabihf-"
 
-# sdk example using this env to distinguish between xargo and cargo
-export BUILDER="cargo"
+# CARGO_FLAGS is empty for no-std TAs
+export CARGO_FLAGS=""
 # Initialize FEATURES as empty for no-std TAs
 export FEATURES=""
\ No newline at end of file
diff --git a/scripts/runtime/config/ta/std/aarch64 b/scripts/runtime/config/ta/std/aarch64
index e93fc5a..346b2c3 100644
--- a/scripts/runtime/config/ta/std/aarch64
+++ b/scripts/runtime/config/ta/std/aarch64
@@ -19,8 +19,10 @@ export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm64"
 export TARGET_TA="aarch64-unknown-optee"
 export CROSS_COMPILE_TA="aarch64-linux-gnu-"
 
-# sdk example using this env to distinguish between xargo and cargo
-export BUILDER="xargo"
+# CARGO_FLAGS for building std TAs with cargo -Z build-std
+export CARGO_FLAGS="-Z build-std=std,panic_abort"
+# rust library source for cargo -Z build-std
+export __CARGO_TESTS_ONLY_SRC_ROOT=$RUST_STD_DIR/rust/library
 # enable std feature for building std TAs (defined in TA's Cargo.toml and used in TA's Makefile)
 export FEATURES="--features std"
 
diff --git a/scripts/runtime/config/ta/std/arm32 b/scripts/runtime/config/ta/std/arm32
index 1cbc2b2..e3fddfc 100644
--- a/scripts/runtime/config/ta/std/arm32
+++ b/scripts/runtime/config/ta/std/arm32
@@ -19,8 +19,10 @@ export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm32"
 export TARGET_TA="arm-unknown-optee"
 export CROSS_COMPILE_TA="arm-linux-gnueabihf-"
 
-# sdk example using this env to distinguish between xargo and cargo
-export BUILDER="xargo"
+# CARGO_FLAGS for building std TAs with cargo -Z build-std
+export CARGO_FLAGS="-Z build-std=std,panic_abort"
+# rust library source for cargo -Z build-std
+export __CARGO_TESTS_ONLY_SRC_ROOT=$RUST_STD_DIR/rust/library
 # enable std feature for building std TAs (defined in TA's Cargo.toml and used in TA's Makefile)
 export FEATURES="--features std"
 
diff --git a/scripts/setup-std/setup_rust_std.sh b/scripts/setup-std/setup_rust_std.sh
index 2250f7c..b01c6d7 100755
--- a/scripts/setup-std/setup_rust_std.sh
+++ b/scripts/setup-std/setup_rust_std.sh
@@ -34,22 +34,26 @@ cd $RUST_STD_DIR
 # Set up Rust and Cargo environment (RUSTUP_HOME and CARGO_HOME are set in bootstrap_env)
 source ${CARGO_HOME}/env
 
-# install Xargo if not exist
-which xargo || cargo install xargo
-
 # initialize submodules: rust / libc with pinned versions for reproducible builds
-RUST_BRANCH=optee-xargo
-RUST_COMMIT=HEAD  # TODO: Pin to specific commit hash for reproducible builds
-LIBC_BRANCH=optee  
-LIBC_COMMIT=HEAD  # TODO: Pin to specific commit hash for reproducible builds
+RUST_TAG=1.93.1        # commit 01f6ddf7588f42ae2d7eb0a2f21d44e8e96674cf
+LIBC_TAG=0.2.182       # commit e879ee90b6cd8f79b352d4d4d1f8ca05f94f2f53
+
+echo "Cloning rust (tag: $RUST_TAG) and libc (tag: $LIBC_TAG)..."
+
+# Clone official Rust source at specific tag
+git clone --depth=1 --branch $RUST_TAG https://github.com/rust-lang/rust.git && \
+    (cd rust && \
+    git submodule update --init library/stdarch && \
+    git submodule update --init library/backtrace)
 
-echo "Cloning rust (branch: $RUST_BRANCH) and libc (branch: $LIBC_BRANCH)..."
+# Clone official libc at specific tag
+git clone --depth=1 --branch $LIBC_TAG https://github.com/rust-lang/libc.git
 
-git clone --depth=1 -b $RUST_BRANCH https://github.com/DemesneGH/rust.git && \
-       (cd rust && \
-       git submodule update --init library/stdarch && \
-       git submodule update --init library/backtrace)
+# Clone patches repository
+git clone --depth=1 https://github.com/apache/teaclave-crates.git patches
 
-git clone --depth=1 -b $LIBC_BRANCH https://github.com/DemesneGH/libc.git
+# Apply patches
+(cd rust && git apply ../patches/rust-1.93.1-01f6ddf/optee-0001-std-adaptation.patch)
+(cd libc && git apply ../patches/libc-0.2.182-e879ee9/optee-0001-libc-adaptation.patch)
 
 echo "rust-std initialized at $RUST_STD_DIR"
diff --git a/scripts/setup/install_dependencies.sh b/scripts/setup/install_dependencies.sh
index 16574ef..8702b92 100755
--- a/scripts/setup/install_dependencies.sh
+++ b/scripts/setup/install_dependencies.sh
@@ -78,4 +78,5 @@ apt-get update && \
     pip \
     ca-certificates \
     libgnutls28-dev \
-    socat
+    socat \
+    jq


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


(teaclave-trustzone-sdk) 02/03: cargo-optee: update for new building approach

Posted by iv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git

commit 9f56f5eeca0576873a959a46d885f8c8500d4a22
Author: Yuan Zhuang <yu...@apache.org>
AuthorDate: Tue Mar 17 05:24:37 2026 +0000

    cargo-optee: update for new building approach
---
 cargo-optee/README.md                  | 15 +++++++-------
 cargo-optee/aarch64-unknown-optee.json | 38 +++++++++++++++++-----------------
 cargo-optee/arm-unknown-optee.json     |  5 +++--
 cargo-optee/src/ta_builder.rs          | 35 ++++++++++++++++++++-----------
 ci/build.sh                            | 14 +++++++++++++
 5 files changed, 67 insertions(+), 40 deletions(-)

diff --git a/cargo-optee/README.md b/cargo-optee/README.md
index d4cc47f..2b0ba3f 100644
--- a/cargo-optee/README.md
+++ b/cargo-optee/README.md
@@ -40,7 +40,7 @@ signing automatically.
         │  ┌──────────────────▼─────────────────────┐  │
         │  │  3. Execute Build Pipeline             │  │
         │  │     - Run clippy (linting)             │  │
-        │  │     - Build binary: cargo/xargo + gcc  │  │
+        │  │     - Build binary: cargo + gcc        │  │
         │  │     - Strip symbols: objcopy           │  │
         │  │     - Sign TA: Python script (TA only) │  │
         │  └──────────────────┬─────────────────────┘  │
@@ -51,7 +51,7 @@ signing automatically.
         ┌──────────────────────────────────────────────┐
         │    Low-Level Tools (dependencies)            │
         │                                              │
-        │    - cargo/xargo: Rust compilation           │
+        │    - cargo: Rust compilation                 │
         │    - gcc: Linking with OP-TEE libraries      │
         │    - objcopy: Symbol stripping               │
         │    - Python script: TA signing (TA only)     │
@@ -307,9 +307,8 @@ cargo-optee build ta \
 - `--arch <ARCH>`: Target architecture (default: `aarch64`)
   - `aarch64`: ARM 64-bit architecture
   - `arm`: ARM 32-bit architecture
-- `--std`: Build with std support (uses xargo and custom target)
-- `--no-std`: Build without std support (uses cargo, mutually exclusive with
-  --std)
+- `--std`: Build with std support (uses `cargo -Z build-std` and custom target)
+- `--no-std`: Build without std support (mutually exclusive with --std)
 - `--signing-key <PATH>`: Path to signing key (default:
   `<ta-dev-kit-dir>/keys/default_ta.pem`)
 - `--uuid-path <PATH>`: Path to UUID file (default: `../uuid.txt`)
@@ -548,14 +547,16 @@ cd ./ta
 TA_DEV_KIT_DIR=/opt/optee/export-ta_arm32 \
 RUSTFLAGS="-C panic=abort" \
 RUST_TARGET_PATH=/tmp/cargo-optee-XXXXX \
-xargo clippy --target arm-unknown-optee --features std --release \
+__CARGO_TESTS_ONLY_SRC_ROOT=/path/to/rust/library \
+cargo -Z build-std=std,panic_abort clippy --target arm-unknown-optee --features std --release \
   --manifest-path ./ta/Cargo.toml
 
 # 2. Build
 TA_DEV_KIT_DIR=/opt/optee/export-ta_arm32 \
 RUSTFLAGS="-C panic=abort" \
 RUST_TARGET_PATH=/tmp/cargo-optee-XXXXX \
-xargo build --target arm-unknown-optee --features std --release \
+__CARGO_TESTS_ONLY_SRC_ROOT=/path/to/rust/library \
+cargo -Z build-std=std,panic_abort build --target arm-unknown-optee --features std --release \
   --manifest-path ./ta/Cargo.toml \
   --config target.arm-unknown-optee.linker="arm-linux-gnueabihf-gcc"
 
diff --git a/cargo-optee/aarch64-unknown-optee.json b/cargo-optee/aarch64-unknown-optee.json
index 4490014..bed042e 100644
--- a/cargo-optee/aarch64-unknown-optee.json
+++ b/cargo-optee/aarch64-unknown-optee.json
@@ -1,21 +1,21 @@
 {
-  "arch": "aarch64",
-  "data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
-  "features": "+strict-align",
-  "dynamic-linking": false,
-  "executables": true,
-  "has-rpath": true,
-  "linker-flavor": "ld",
-  "linker-is-gnu": true,
-  "llvm-target": "aarch64-unknown-linux-gnu",
-  "max-atomic-width": 128,
-  "os": "optee",
-  "position-independent-executables": true,
-  "relro-level": "full",
-  "target-c-int-width": "32",
-  "target-endian": "little",
-  "target-pointer-width": "64",
-  "vendor": "unknown",
-  "panic-strategy": "abort"
-}
+    "arch": "aarch64",
+    "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32",
+    "features": "+strict-align",
+    "dynamic-linking": false,
+    "executables": true,
+    "has-rpath": true,
+    "linker-flavor": "ld",
+    "linker-is-gnu": true,
+    "llvm-target": "aarch64-unknown-linux-gnu",
+    "max-atomic-width": 128,
+    "os": "optee",
+    "position-independent-executables": true,
+    "relro-level": "full",
+    "target-c-int-width": 32,
+    "target-endian": "little",
+    "target-pointer-width": 64,
+    "vendor": "unknown",
+    "panic-strategy": "abort"
+  }
   
\ No newline at end of file
diff --git a/cargo-optee/arm-unknown-optee.json b/cargo-optee/arm-unknown-optee.json
index 79cf125..1151d04 100644
--- a/cargo-optee/arm-unknown-optee.json
+++ b/cargo-optee/arm-unknown-optee.json
@@ -7,14 +7,15 @@
   "has-rpath": true,
   "linker-flavor": "ld",
   "linker-is-gnu": true,
+  "llvm-floatabi": "hard",
   "llvm-target": "arm-unknown-linux-gnueabihf",
   "max-atomic-width": 64,
   "os": "optee",
   "position-independent-executables": true,
   "relro-level": "full",
-  "target-c-int-width": "32",
+  "target-c-int-width": 32,
   "target-endian": "little",
-  "target-pointer-width": "32",
+  "target-pointer-width": 32,
   "vendor": "unknown",
   "panic-strategy": "abort",
   "singlethread": true
diff --git a/cargo-optee/src/ta_builder.rs b/cargo-optee/src/ta_builder.rs
index 6557de6..b58a019 100644
--- a/cargo-optee/src/ta_builder.rs
+++ b/cargo-optee/src/ta_builder.rs
@@ -326,12 +326,12 @@ fn setup_build_command(
         None
     };
 
-    // Determine builder (cargo or xargo)
-    let mut cmd = match config.std {
-        true => Command::new("xargo"),
-        false => cargo_command(),
-    };
+    // Always use cargo; std builds pass -Z build-std=std,panic_abort
+    let mut cmd = cargo_command();
     cmd.arg(command);
+    if config.std {
+        cmd.arg("-Z").arg("build-std=std,panic_abort");
+    }
     cmd.arg("--target").arg(&target);
 
     // Add --no-default-features if specified
@@ -359,13 +359,6 @@ fn setup_build_command(
         cmd.arg("--features").arg(features.join(","));
     }
 
-    // Add no-std specific flags to avoid the linking error of _Unwind_Resume
-    if !config.std {
-        cmd.arg("-Z").arg("build-std=core,alloc");
-        cmd.arg("-Z")
-            .arg("build-std-features=panic_immediate_abort");
-    }
-
     // Set RUSTFLAGS - preserve existing ones and add panic=abort
     let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
     if !rustflags.is_empty() {
@@ -391,6 +384,24 @@ fn setup_build_command(
         cmd.env("RUST_TARGET_PATH", temp_dir_ref.path());
     }
 
+    // Set __CARGO_TESTS_ONLY_SRC_ROOT for std builds (required by cargo -Z build-std)
+    if config.std {
+        let rust_src = env::var("__CARGO_TESTS_ONLY_SRC_ROOT")
+            .map(PathBuf::from)
+            .map_err(|_| anyhow::anyhow!(
+                "__CARGO_TESTS_ONLY_SRC_ROOT is not set.\n\
+                For std TA builds, set it to the Rust library source directory, e.g.:\n\
+                  export __CARGO_TESTS_ONLY_SRC_ROOT=/path/to/rust/library"
+            ))?;
+        if !rust_src.exists() {
+            anyhow::bail!(
+                "__CARGO_TESTS_ONLY_SRC_ROOT points to a non-existent path: {:?}",
+                rust_src
+            );
+        }
+        cmd.env("__CARGO_TESTS_ONLY_SRC_ROOT", &rust_src);
+    }
+
     Ok((cmd, temp_dir))
 }
 
diff --git a/ci/build.sh b/ci/build.sh
index 654b33f..8306c11 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -125,6 +125,20 @@ if [ -z "$OPTEE_CLIENT_EXPORT" ]; then
     exit 1
 fi
 
+# For std builds, __CARGO_TESTS_ONLY_SRC_ROOT must be set (required by cargo -Z build-std)
+if [ -n "$STD" ]; then
+    if [ -z "$__CARGO_TESTS_ONLY_SRC_ROOT" ]; then
+        if [ -n "$RUST_STD_DIR" ]; then
+            export __CARGO_TESTS_ONLY_SRC_ROOT="$RUST_STD_DIR/rust/library"
+        else
+            echo "Error: __CARGO_TESTS_ONLY_SRC_ROOT (or RUST_STD_DIR) must be set for std builds"
+            echo "  export __CARGO_TESTS_ONLY_SRC_ROOT=/path/to/rust/library"
+            exit 1
+        fi
+    fi
+    echo "  __CARGO_TESTS_ONLY_SRC_ROOT: $__CARGO_TESTS_ONLY_SRC_ROOT"
+fi
+
 echo "==========================================="
 echo "Installing with configuration:"
 echo "  ARCH_TA: $ARCH_TA"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org