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