macOS: link clang_rt.osx to fix SME2 (__arm_tpidr2_*) link failures under rustc#498
Merged
HenryNdubuaku merged 7 commits intocactus-compute:mainfrom Mar 5, 2026
Merged
Conversation
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
Signed-off-by: Yujong Lee <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First appearance
Symptom
cargo test/cargo buildfails at the final link step on Apple Silicon with undefined symbols:___arm_tpidr2_save___arm_tpidr2_restore___arm_tpidr2_*byld)Root Cause
kernel_sme2.cpp) uses SME2 attributes/ABIs that reference__arm_tpidr2_*helper functions.libclang_rt.osx.a(inside the clang resource dir), not reliably bylibSystemin a way Rust picks up automatically.rustc, the final link invocation uses-nodefaultlibs, so the implicit “clang driver adds its runtime” behavior does not apply.__arm_tpidr2_*are present.What This PR Does
rust/cactus-sys/build.rs, on macOS only:clang --print-resource-dir.../lib/darwinto the native search pathlibclang_rt.osx.aviacargo:rustc-link-lib=static=clang_rt.osx__arm_tpidr2_*resolution deterministic under Rust’s-nodefaultlibslinking.Why Not “Allow Undefined” (
-Wl,-U)-Wl,-U,<sym>can make the link step succeed even if the symbol remains unresolved.cpu_has_sme2()is true but the symbols aren’t actually resolved in the final binary image.Correct Conditions for SME2 to Actually Run
Compile-time (build) condition
CMake BUILD_SME2ends up true).Link-time condition (this change)
__arm_tpidr2_*(libclang_rt.osx.a).Runtime condition
cpu_has_sme2()true).