Sign inSign up

mqylyl/riscv-gnu-toolchain

By mqylyl

•Updated about 2 years ago

riscv-gnu-toolchain

Image
Developer tools
0

87

mqylyl/riscv-gnu-toolchain repository overview

⁠run a container

docker run --name riscv64_elf_gcc \
-p 10022:22 \
-itd  mqylyl/riscv-gnu-toolchain:elf_gcc_qemu_HEADE_1358115

⁠enter the container

docker exec -it riscv64_elf_gcc /bin/bash

⁠get gcc version

riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/opt/riscv/libexec/gcc/riscv64-unknown-elf/13.2.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /opt/source/riscv-gnu-toolchain/gcc/configure --target=riscv64-unknown-elf --prefix=/opt/riscv --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=gc891d8dc23e --with-system-zlib --enable-tls --with-newlib --with-sysroot=/opt/riscv/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=.././gcc --enable-multilib --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket --with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-Os    -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os    -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (gc891d8dc23e)

⁠get qemu version

qemu-system-riscv64 -version
QEMU emulator version 9.0.1 (v9.0.1-dirty)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

⁠run hello world

cd ~
⁠edit hello_world.c
echo '#include <stdio.h>' > hello_world.c && \
echo 'int main() {' >> hello_world.c && \
echo '    printf("Hello, world!\n");' >> hello_world.c && \
echo '    return 0;' >> hello_world.c && \
echo '}' >> hello_world.c
⁠compile hello.c
riscv64-unknown-elf-gcc -march=rv64imafdc -mabi=lp64 -o hello_world hello_world.c
⁠run hello_world by qemu
qemu-riscv64 ./hello_world
Hello, world!
⁠view binary file format
file hello_world
hello_world: ELF 64-bit LSB executable, UCB RISC-V, RVC, soft-float ABI, version 1 (SYSV), statically linked, not stripped

Tag summary

Content type

Image

Digest

sha256:2c092e881…

Size

944.9 MB

Last updated

about 2 years ago

docker pull mqylyl/riscv-gnu-toolchain:elf_gcc_qemu_HEADE_1358115