This is my first post in the community, if I violate any rules, please remind me so that I can adjust my behavior.
I'm using a custom build of rustc to build my toy OS on both riscv64gc-none-unknown-elf and loongarch64, with the latter currently achieved by the chip maker(It is currently supported by llvm but not officially by rust).
The source of the custom toolchain: custom toolchain for LoongArch64, which is no more than adding new registers and target names to the whitelist.
I also added the source in its other branch (the implementation of asm!
for this target) which is in the loongarch64-inline-asm
branch of the same repository to support inline assemble, but it doesn't seem relevant.
I should also mention that a simpler project (a hello world) compiles and functions correctly.
The RISC-V build seems OK and passed the usual test, but the LoongArch part fails with the following message:
/home/dragon/.rustup/toolchains/loongarch_build/lib/librustc_driver-de8e72b4eb256369.so(+0xf877f3)[0x7f62d6ac87f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f62d5789520]
/home/dragon/.rustup/toolchains/loongarch_build/lib/librustc_driver-de8e72b4eb256369.so(+0xc80f72)[0x7f62d67c1f72]
/home/dragon/.rustup/toolchains/loongarch_build/lib/librustc_driver-de8e72b4eb256369.so(+0x75aa5e0)[0x7f62dd0eb5e0]
warning: `os` (bin "os") generated 3 warnings
error: could not compile `os`; 3 warnings emitted
Caused by:
process didn't exit successfully: `rustc --crate-name os --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=208 --crate-type bin --emit=dep-info,link -C opt-level=1 -C embed-bitcode=no -C codegen-units=16 -C debuginfo=2 --cfg 'feature="board_2k500"' --cfg 'feature="default"' --cfg 'feature="la64"' --cfg 'feature="oom_handler"' --cfg 'feature="swap"' --cfg 'feature="zram"' -C metadata=3afb7dc35305610e -C extra-filename=-3afb7dc35305610e --out-dir '/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps' --target loongarch64-unknown-linux-gnu -C linker=loongarch64-unknown-linux-gnu-gcc -L 'dependency=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps' -L 'dependency=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/debug/deps' --extern 'bit_field=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libbit_field-ef8aa457a4ff067e.rlib' --extern 'bitflags=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libbitflags-80b518ec0819c643.rlib' --extern 'buddy_system_allocator=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libbuddy_system_allocator-28a6c2be444c4347.rlib' --extern 'downcast_rs=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libdowncast_rs-13eb980067103457.rlib' --extern 'embedded_hal=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libembedded_hal-3f2c291eecb1c401.rlib' --extern 'lazy_static=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/liblazy_static-9ebedb535cc6b21d.rlib' --extern 'log=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/liblog-563e72480f04789f.rlib' --extern 'lz4_flex=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/liblz4_flex-193d1f3dd51877d4.rlib' --extern 'nb=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libnb-4ae076da4e75358d.rlib' --extern 'num_enum=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libnum_enum-d1698705e9df0466.rlib' --extern 'rlibc=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/librlibc-a19bd3c055a6777a.rlib' --extern 'spin=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libspin-a599ee6ad9b7e90f.rlib' --extern 'virtio_drivers=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libvirtio_drivers-00084398b9c8c0c4.rlib' --extern 'xmas_elf=/home/dragon/文档/EduDept/Computer/MyCode/rCore/os_2021/os/target/loongarch64-unknown-linux-gnu/debug/deps/libxmas_elf-eaaedce7a6807433.rlib' -Clink-arg=-Tsrc/linker.ld -Cforce-frame-pointers=yes` (signal: 11, SIGSEGV: invalid memory reference)
Do you have clue or advice about this problem? Should I add more information to help the detection of this error? Thanks in advance.