toolchain.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # 当前脚本用于初始化自定义的Rust工具链
  2. if [ -z "$(which cargo)" ]; then
  3. echo "尚未安装Rust,请先安装Rust"
  4. exit 1
  5. fi
  6. DRAGONOS_UNKNOWN_ELF_PATH=$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-dragonos
  7. mkdir -p ${DRAGONOS_UNKNOWN_ELF_PATH}/lib
  8. # 设置工具链配置文件
  9. echo \
  10. "{\
  11. \"arch\": \"x86_64\",
  12. \"code-model\": \"kernel\",
  13. \"cpu\": \"x86-64\",
  14. \"os\": \"dragonos\",
  15. \"target-endian\": \"little\",
  16. \"target-pointer-width\": \"64\",
  17. \"target-c-int-width\": \"32\",
  18. \"data-layout\": \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\",
  19. \"disable-redzone\": true,
  20. \"features\": \"-3dnow,-3dnowa,-avx,-avx2\",
  21. \"linker\": \"rust-lld\",
  22. \"linker-flavor\": \"ld.lld\",
  23. \"llvm-target\": \"x86_64-unknown-none\",
  24. \"max-atomic-width\": 64,
  25. \"panic-strategy\": \"abort\",
  26. \"position-independent-executables\": true,
  27. \"relro-level\": \"full\",
  28. \"stack-probes\": {
  29. \"kind\": \"inline-or-call\",
  30. \"min-llvm-version-for-inline\": [
  31. 16,
  32. 0,
  33. 0
  34. ]
  35. },
  36. \"static-position-independent-executables\": true,
  37. \"supported-sanitizers\": [
  38. \"kcfi\"
  39. ],
  40. \"target-pointer-width\": \"64\"
  41. }" > ${DRAGONOS_UNKNOWN_ELF_PATH}/target.json || exit 1