1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 08:26:17 +04:00
rCore/kernel/build-rv64

597 lines
17 KiB
Plaintext
Raw Normal View History

2018-12-17 10:58:16 +04:00
#!/bin/bash
# The contents are adopted from xbuild verbose output.
2018-12-28 18:20:21 +04:00
# Output files are in target/${ARCH}-blog_os/debug
#
# Usage:
# Just run
# $ ./run-qemu-script-custom-llc
#
2018-12-22 23:33:05 +04:00
# By default riscv64 is built. To build for riscv32,
# set the environment variable `RV32` to "1"
2018-12-17 10:58:16 +04:00
set -e
2018-12-26 05:47:00 +04:00
if [[ ${RV32} = 1 ]]; then
TARGET_ARCH=riscv32
COMPILER_RT_CFLAGS="-march=rv32ia -mabi=ilp32 -O3"
SFSIMG_CFLAGS="-march=rv32ia -mabi=ilp32"
else
TARGET_ARCH=riscv64
2018-12-22 23:33:05 +04:00
COMPILER_RT_CFLAGS="-march=rv64ia -mabi=lp64 -O3"
SFSIMG_CFLAGS="-march=rv64ia -mabi=lp64"
fi
UCORE_USER_IMAGE="../user/img/ucore-${TARGET_ARCH}.img"
2018-12-28 18:20:21 +04:00
LLC=$PWD/../tools/llc
RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/src
CARGO_PATH=~/.cargo
LLC_ARCH=${TARGET_ARCH}
2018-12-28 18:20:21 +04:00
OUTDIR=$PWD/target/${TARGET_ARCH}-blog_os/debug
TARGET_JSON=$PWD/${TARGET_ARCH}-blog_os.json
CC=${TARGET_ARCH}-unknown-elf-gcc
AR=${TARGET_ARCH}-unknown-elf-ar
OBJCOPY=${TARGET_ARCH}-unknown-elf-objcopy
QEMU=qemu-system-${TARGET_ARCH}
export SMP=4
2018-12-28 18:20:21 +04:00
#============================================================================
# Check env before build
mkdir -p ${OUTDIR}
# auto download K210 SDK lib
if [[ ${board} = k210 ]] && ! [[ -f ${OUTDIR}/libkendryte.a ]]
then
wget https://github.com/wangrunji0408/RustOS/releases/download/v0.1/libkendryte.a
mv libkendryte.a ${OUTDIR}
fi
# auto download llc
if ! [[ -f ${LLC} ]]
then
cd ../tools
if [[ $(uname) = Linux ]]; then
wget https://github.com/wangrunji0408/RustOS/releases/download/v0.1/llc-ubuntu
mv llc-ubuntu llc
else
wget https://github.com/wangrunji0408/RustOS/releases/download/v0.1/llc-macOS
mv llc-macOS llc
fi
chmod +x llc
cd ../kernel
fi
2018-12-28 18:20:21 +04:00
# if some crates are not exist, build for riscv32 first
if ! [[ -f $CARGO_PATH/git/checkouts/bit-vec-437fa4a002bd318d/9861a58*/src/lib.rs ]]
then
make kernel arch=riscv32 board=none
fi
#============================================================================
# Stupid long implementation
2018-12-17 10:58:16 +04:00
gen_full_rlib() {
2018-12-28 18:20:21 +04:00
PWD0=${PWD}
cd ${OUTDIR}
2018-12-20 21:50:52 +04:00
for X in ${CNAME}.*bc
2018-12-17 10:58:16 +04:00
do
2018-12-24 20:33:29 +04:00
${LLC} -march=${LLC_ARCH} -filetype=obj -mattr=+m,+c ${X}
2018-12-17 10:58:16 +04:00
done
for X in ${CNAME}.*o
do
2018-12-19 21:13:42 +04:00
${AR} r lib${CNAME}.rlib ${X}
2018-12-17 10:58:16 +04:00
done
2018-12-28 18:20:21 +04:00
cd ${PWD0}
2018-12-17 10:58:16 +04:00
}
#
# Basic dependencies
CNAME=core
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name ${CNAME} $RUST_SRC_PATH/libcore/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=3 \
-C debuginfo=2 \
-Z force-unstable-if-unmarked \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
2018-12-19 21:13:42 +04:00
# Note: In recent nightly, compiler_builtins has been removed from rust_src.
CNAME=compiler_builtins
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name compiler_builtins $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.2/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=3 \
-C debuginfo=2 \
-Z force-unstable-if-unmarked \
--cfg 'feature="compiler-builtins"' \
--cfg 'feature="mem"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=alloc
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name alloc $RUST_SRC_PATH/liballoc/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=3 \
-C debuginfo=2 \
-Z force-unstable-if-unmarked \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=semver_parser
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name semver_parser $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.7.0/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=cfg_if
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name cfg_if $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.6/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=spin
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name spin $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/spin-0.4.10/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
--cfg 'feature="const_fn"' \
--cfg 'feature="default"' \
--cfg 'feature="once"' \
--cfg 'feature="unstable"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=static_assertions
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name static_assertions $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/static_assertions-0.3.1/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bit_field
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bit_field $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/bit_field-0.9.0/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=zero
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name zero $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/zero-0.1.2/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bit_vec
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bit_vec $CARGO_PATH/git/checkouts/bit-vec-437fa4a002bd318d/9861a58*/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bitflags
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bitflags $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/bitflags-1.0.4/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
--cfg 'feature="default"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=volatile
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name volatile $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/volatile-0.2.5/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=once
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name once $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/once-0.3.3/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bbl
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bbl $PWD/../crate/bbl/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=log
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name log $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/log-0.4.6/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=linked_list_allocator
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name linked_list_allocator $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.6.3/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
--cfg 'feature="default"' \
--cfg 'feature="spin"' \
--cfg 'feature="use_spin"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=lazy_static
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name lazy_static $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.2.0/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
--cfg 'feature="spin"' \
--cfg 'feature="spin_no_std"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
2018-12-17 10:58:16 +04:00
#
CNAME=xmas_elf
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name xmas_elf $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/xmas-elf-0.6.2/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bit_allocator
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bit_allocator $PWD/../crate/bit-allocator/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=simple_filesystem
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
2018-12-28 18:20:21 +04:00
rustc --edition=2018 --crate-name simple_filesystem $CARGO_PATH/git/checkouts/simplefilesystem-rust-868ccb44dbeefdea/48b3c26*/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--extern bit_vec=${OUTDIR}/libbit_vec.rlib \
--extern spin=${OUTDIR}/libspin.rlib \
--extern static_assertions=${OUTDIR}/libstatic_assertions.rlib \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=ucore_process
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --edition=2018 --crate-name ucore_process $PWD/../crate/process/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
--extern log=${OUTDIR}/liblog.rlib \
--extern spin=${OUTDIR}/libspin.rlib \
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=ucore_memory
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --edition=2018 --crate-name ucore_memory $PWD/../crate/memory/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
--extern log=${OUTDIR}/liblog.rlib \
-L ${OUTDIR}
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=semver
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name semver $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/semver-0.9.0/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
--cfg 'feature="default"' \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
-L ${OUTDIR} \
--extern semver_parser=${OUTDIR}/libsemver_parser.rlib \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=rustc_version
# omit build_script_build
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name rustc_version $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/rustc_version-0.2.3/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
-L ${OUTDIR} \
--extern semver=${OUTDIR}/libsemver.rlib \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=bare_metal
# omit build_script_build
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
rustc --crate-name bare_metal $CARGO_PATH/registry/src/github.com-1ecc6299db9ec823/bare-metal-0.2.4/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
CNAME=riscv
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-19 21:13:42 +04:00
then
2018-12-28 13:00:59 +04:00
rustc --crate-name riscv $CARGO_PATH/git/checkouts/riscv-1e845b622ce46f1d/f7bea54*/src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--extern bare_metal=${OUTDIR}/libbare_metal.rlib \
--extern bit_field=${OUTDIR}/libbit_field.rlib \
--extern bitflags=${OUTDIR}/libbitflags.rlib \
--extern log=${OUTDIR}/liblog.rlib \
--cap-lints allow
gen_full_rlib
2018-12-19 21:13:42 +04:00
fi
# Hand generate build.rs
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/libatomic_rt.a ]]
2018-12-20 21:50:52 +04:00
then
2018-12-28 18:20:21 +04:00
${CC} src/arch/riscv32/compiler_rt.c ${COMPILER_RT_CFLAGS} -O3 -c -o ${OUTDIR}/compiler_rt.o
${AR} r ${OUTDIR}/libatomic_rt.a ${OUTDIR}/compiler_rt.o
2018-12-20 21:50:52 +04:00
fi
2018-12-28 18:20:21 +04:00
if ! [[ -f ${OUTDIR}/libsfsimg.a ]]
2018-12-20 21:50:52 +04:00
then
2018-12-28 18:20:21 +04:00
cat >${OUTDIR}/sfsimg.S <<EOF
.section .rodata
.align 12
.global _user_img_start
.global _user_img_end
_user_img_start:
.incbin "${UCORE_USER_IMAGE}"
_user_img_end:
EOF
2018-12-28 18:20:21 +04:00
if ! ${CC} ${OUTDIR}/sfsimg.S ${SFSIMG_CFLAGS} -c -o ${OUTDIR}/sfsimg.o
2018-12-26 16:29:22 +04:00
then
echo "You should manually create sfs image!"
exit 1
fi
2018-12-28 18:20:21 +04:00
${AR} r ${OUTDIR}/libsfsimg.a ${OUTDIR}/sfsimg.o
2018-12-20 21:50:52 +04:00
fi
2018-12-20 21:50:52 +04:00
#make sfsimg
2018-12-17 10:58:16 +04:00
CNAME=ucore
2018-12-28 18:20:21 +04:00
#if ! [[ -f ${OUTDIR}/${CNAME}.o ]]
2018-12-20 21:50:52 +04:00
#then
2018-12-28 18:20:21 +04:00
if [[ ${board} = k210 ]]; then
2018-12-22 23:33:05 +04:00
export UCORE_FEATURE_ARGS='--cfg feature="m_mode" --cfg feature="no_mmu" --cfg feature="board_k210"'
cp src/arch/riscv32/board/k210/linker.ld src/arch/riscv32/boot/linker64.ld
else
cp src/arch/riscv32/board/u540/linker.ld src/arch/riscv32/boot/linker64.ld
fi
2018-12-17 10:58:16 +04:00
rustc --edition=2018 --crate-name ucore src/lib.rs \
2018-12-20 21:50:52 +04:00
--color always --crate-type lib --emit=metadata,llvm-bc \
2018-12-17 10:58:16 +04:00
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
${UCORE_FEATURE_ARGS} \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--extern bbl=${OUTDIR}/libbbl.rlib \
--extern bit_allocator=${OUTDIR}/libbit_allocator.rlib \
--extern bit_field=${OUTDIR}/libbit_field.rlib \
--extern bitflags=${OUTDIR}/libbitflags.rlib \
--extern lazy_static=${OUTDIR}/liblazy_static.rlib \
--extern linked_list_allocator=${OUTDIR}/liblinked_list_allocator.rlib \
--extern log=${OUTDIR}/liblog.rlib \
--extern once=${OUTDIR}/libonce.rlib \
--extern riscv=${OUTDIR}/libriscv.rlib \
--extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \
--extern spin=${OUTDIR}/libspin.rlib \
--extern ucore_memory=${OUTDIR}/libucore_memory.rlib \
--extern ucore_process=${OUTDIR}/libucore_process.rlib \
--extern volatile=${OUTDIR}/libvolatile.rlib \
--extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \
-L native=${OUTDIR} -l static=sfsimg -l static=atomic_rt
2018-12-17 10:58:16 +04:00
gen_full_rlib
2018-12-20 21:50:52 +04:00
#fi
2018-12-17 10:58:16 +04:00
2018-12-28 18:20:21 +04:00
#if ! [[ -f ${OUTDIR}/ucore ]]
2018-12-20 21:50:52 +04:00
#then
2018-12-28 18:20:21 +04:00
if [[ ${board} = k210 ]]; then
2018-12-24 20:30:21 +04:00
export LINK_K210='-L native=kendryte'
fi
2018-12-26 16:29:22 +04:00
echo "rustc crate-type bin to ${TARGET_JSON}"
2018-12-17 10:58:16 +04:00
rustc --edition=2018 --crate-name ucore src/main.rs \
2018-12-19 21:13:42 +04:00
--color always --crate-type bin --emit=link \
2018-12-17 10:58:16 +04:00
-C opt-level=1 \
-C debuginfo=2 \
-C debug-assertions=on \
2018-12-28 18:20:21 +04:00
--out-dir ${OUTDIR} \
--target $TARGET_JSON \
2018-12-28 18:20:21 +04:00
-L ${OUTDIR} \
--extern bbl=${OUTDIR}/libbbl.rlib \
--extern bit_allocator=${OUTDIR}/libbit_allocator.rlib \
--extern bit_field=${OUTDIR}/libbit_field.rlib \
--extern bitflags=${OUTDIR}/libbitflags.rlib \
--extern lazy_static=${OUTDIR}/liblazy_static.rlib \
--extern linked_list_allocator=${OUTDIR}/liblinked_list_allocator.rlib \
--extern log=${OUTDIR}/liblog.rlib \
--extern once=${OUTDIR}/libonce.rlib \
--extern riscv=${OUTDIR}/libriscv.rlib \
--extern simple_filesystem=${OUTDIR}/libsimple_filesystem.rlib \
--extern spin=${OUTDIR}/libspin.rlib \
--extern ucore=${OUTDIR}/libucore.rlib \
--extern ucore_memory=${OUTDIR}/libucore_memory.rlib \
--extern ucore_process=${OUTDIR}/libucore_process.rlib \
--extern volatile=${OUTDIR}/libvolatile.rlib \
--extern xmas_elf=${OUTDIR}/libxmas_elf.rlib \
-L native=${OUTDIR} ${LINK_K210}
2018-12-20 21:50:52 +04:00
#fi