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/09/18 09:44:33 UTC
(teaclave-trustzone-sdk) branch main updated: optee-utee-build: append OP-TEE libraries after Rust dependencies
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
The following commit(s) were added to refs/heads/main by this push:
new 67f3c09 optee-utee-build: append OP-TEE libraries after Rust dependencies
67f3c09 is described below
commit 67f3c098ead403646160040f465c86dc745967ef
Author: ivila <39...@qq.com>
AuthorDate: Fri Sep 18 17:11:38 2026 +0800
optee-utee-build: append OP-TEE libraries after Rust dependencies
---
crates/optee-utee-build/src/linker.rs | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/crates/optee-utee-build/src/linker.rs b/crates/optee-utee-build/src/linker.rs
index 065bb89..6659e10 100644
--- a/crates/optee-utee-build/src/linker.rs
+++ b/crates/optee-utee-build/src/linker.rs
@@ -105,25 +105,35 @@ impl Linker {
println!("cargo:rustc-link-search={}", search_path.display());
println!("cargo:rustc-link-lib=static=utee");
println!("cargo:rustc-link-lib=static=utils");
+ // Re-emit the libraries as trailing link args. rustc places
+ // `rustc-link-lib` inputs before the dependency rlibs, which combined
+ // with `--as-needed` drops archive members (e.g. memcmp/bcmp from
+ // libutils) that only later objects need. Debug builds then fail to
+ // link while release builds happen to inline those calls away.
+ self.link_arg("-lutee");
+ self.link_arg("-lutils");
println!("cargo:rustc-link-arg=-e__ta_entry");
println!("cargo:rustc-link-arg=-pie");
println!("cargo:rustc-link-arg=-Os");
- match self.linker_type {
- LinkerType::Cc => println!("cargo:rustc-link-arg=-Wl,--sort-section=alignment"),
- LinkerType::Ld => println!("cargo:rustc-link-arg=--sort-section=alignment"),
- };
+ self.link_arg("--sort-section=alignment");
let mut dyn_list = File::create(out_dir.join("dyn_list"))?;
writeln!(
dyn_list,
"{{ __elf_phdr_info; trace_ext_prefix; trace_level; ta_head; }};"
)?;
- match self.linker_type {
- LinkerType::Cc => println!("cargo:rustc-link-arg=-Wl,--dynamic-list=dyn_list"),
- LinkerType::Ld => println!("cargo:rustc-link-arg=--dynamic-list=dyn_list"),
- }
+ self.link_arg("--dynamic-list=dyn_list");
Ok(())
}
+
+ /// Emit one linker argument in `ld` form, translating it through the `cc`
+ /// driver when that is the configured linker.
+ fn link_arg(&self, arg: &str) {
+ match self.linker_type {
+ LinkerType::Cc => println!("cargo:rustc-link-arg=-Wl,{arg}"),
+ LinkerType::Ld => println!("cargo:rustc-link-arg={arg}"),
+ }
+ }
}
impl Linker {
@@ -138,10 +148,7 @@ impl Linker {
println!("cargo:rerun-if-env-changed={}", ENV_TARGET);
match env::var(ENV_TARGET) {
Ok(ref v) if v == "arm-unknown-linux-gnueabihf" || v == "arm-unknown-optee" => {
- match self.linker_type {
- LinkerType::Cc => println!("cargo:rustc-link-arg=-Wl,--no-warn-mismatch"),
- LinkerType::Ld => println!("cargo:rustc-link-arg=--no-warn-mismatch"),
- };
+ self.link_arg("--no-warn-mismatch");
}
_ => {}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org