Understanding Rust Library Dependencies

I am writing for educational purposes the implemented Rust program for ARM. Since this is a bare metal system, I use only the main library. The library’s manual page states that corelib does not depend on anything, but memcpy, memcmpand memset, and the unwinding function (see https://doc.rust-lang.org/core/index.html ). However, especially if I use atomic types , I keep getting linker errors due to missing characters, such as __sync_val_compare_and_swap_4or __sync_lock_test_and_set_4, which indicates the missing compiler-rt library . I understand that compiler-rt should be on top of corelib. This is like a circular dependency, which should not be. In addition, I understand that the rt compiler, in turn, is OS dependent.

  • What part of my understanding is wrong?
  • How can I get a true independent corelib, or which parts of it are truly independent? I know that I could reimplement the missing functions, but they seem to be quite a lot. In addition, I know the built-in box-builder , but it still leaves me with unresolved characters.
+4
source share
1 answer

In the meantime, I found a solution. I share this in the hope that it will be useful for someone else.

As correctly stated in kennytm, the characters do not belong to compiler_rt. In addition, the characters are just random, the same as in the libgcc, cf functions here . Calls will be issued by llvm if the CPU does not support atomic commands, such as cmpxchg.

ARMv6 . Rust/llvm : JSON :

{  "llvm-target": "arm-none-eabihf",  
   "target-endian": "little",
   "target-pointer-width": "32", 
   "os": "none",
   "env": "eabihf", 
   "vendor": "unknown",
   "arch": "arm", 
   "linker": "arm-none-eabi-gcc",
   "linker-flavor": "gnu",
   "data-layout": "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64",
   "executables": true,
   "relocation-model": "static",
   "no-compiler-rt": true
}

, CPU ARMv5, . "cpu": "arm1176jzf-s", .

+1

Source: https://habr.com/ru/post/1677399/


All Articles